// createCachedDescriptors function createCachedDescriptors(dirname, options, alias) { const { plugins, presets, passPerPreset } = options; return { options: optionsWithResolvedBrowserslistConfigFile(options, dirname), plugins: plugins ? () => createCachedPluginDescriptors(plugins, dirname)(alias) : () => handlerOf([]), presets: presets ? () => createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => handlerOf([]) }; } // createDescriptor function* createDescriptor(pair, dirname, { type, alias, ownPass }) { const desc = (0, _item.getItemDescriptor)(pair); if (desc) { return desc; } let name; let options; let value = pair; if (Array.isArray(value)) { if (value.length === 3) { [value, options, name] = value; } else { [value, options] = value; } } let file = undefined; let filepath = null; if (typeof value === "string") { if (typeof type !== "string") { throw new Error("To resolve a string-based item, the type of item must be given"); } const resolver = type === "plugin" ? _index.loadPlugin : _index.loadPreset; const request = value; ({ filepath, value } = yield* resolver(value, dirname)); file = { request, resolved: filepath }; } if (!value) { throw new Error(`Unexpected falsy value: ${String(value)}`); } if (typeof value === "object" && value.__esModule) { if (value.default) { value = value.default; } else { throw new Error("Must export a default export when using ES6 modules."); } } if (typeof value !== "object" && typeof value !== "function") { throw new Error(`Unsupported format: ${typeof value}. Expected an object or a function.`); } if (filepath !== null && typeof value === "object" && value) { throw new Error(`Plugin/Preset files are not allowed to export objects, only functions. In ${filepath}`); } return { name, alias: filepath || alias, value, options, dirname, ownPass, file }; } // createUncachedDescriptors function createUncachedDescriptors(dirname, options, alias) { return { options: optionsWithResolvedBrowserslistConfigFile(options, dirname), plugins: (0, _functional.once)(() => createPluginDescriptors(options.plugins || [], dirname, alias)), presets: (0, _functional.once)(() => createPresetDescriptors(options.presets || [], dirname, alias, !!options.passPerPreset)) }; }