it was weird. i pressed delete on a subfolder, i think one of the pages.off folders that i was using. and then, suddenly, nvim on windows 7 decided to delete every file in the directory. they weren't shred off the space time continuum, but just marked deleted. i had to pay $80 to get access to a software that could see them. bleh! just seeing all my work, a little over a week, was pretty heart shattering. but i remembered that long ago, a close friend said i could call them whenever i was feeling sad. i finally took them up on that offer. the first time i've ever called someone for emotional support. but it's ok. i got it back. and the site framework is better than ever. i'm gonna commit and push more often. the repo is private anyways.
86 lines
2.4 KiB
Text
86 lines
2.4 KiB
Text
// 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))
|
|
};
|
|
}
|