整理桌面
This commit is contained in:
4559
node_modules/rollup/dist/shared/index.js
generated
vendored
Normal file
4559
node_modules/rollup/dist/shared/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
607
node_modules/rollup/dist/shared/loadConfigFile.js
generated
vendored
Normal file
607
node_modules/rollup/dist/shared/loadConfigFile.js
generated
vendored
Normal file
@@ -0,0 +1,607 @@
|
||||
/*
|
||||
@license
|
||||
Rollup.js v2.60.1
|
||||
Mon, 22 Nov 2021 07:50:11 GMT - commit 649074e14131b490ff9dfe26e94632ff458c4970
|
||||
|
||||
|
||||
https://github.com/rollup/rollup
|
||||
|
||||
Released under the MIT License.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
const tty = require('tty');
|
||||
const rollup = require('./rollup.js');
|
||||
const mergeOptions = require('./mergeOptions.js');
|
||||
|
||||
function _interopNamespaceDefault(e) {
|
||||
const n = Object.create(null);
|
||||
if (e) {
|
||||
for (const k in e) {
|
||||
n[k] = e[k];
|
||||
}
|
||||
}
|
||||
n.default = e;
|
||||
return n;
|
||||
}
|
||||
|
||||
const fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
||||
const path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
||||
const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
|
||||
|
||||
const env = process.env;
|
||||
|
||||
const isDisabled = "NO_COLOR" in env;
|
||||
const isForced = "FORCE_COLOR" in env;
|
||||
const isWindows = process.platform === "win32";
|
||||
|
||||
const isCompatibleTerminal =
|
||||
tty__namespace && tty__namespace.isatty(1) && env.TERM && env.TERM !== "dumb";
|
||||
|
||||
const isCI =
|
||||
"CI" in env &&
|
||||
("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
||||
|
||||
let enabled =
|
||||
!isDisabled && (isForced || isWindows || isCompatibleTerminal || isCI);
|
||||
|
||||
const raw = (open, close, searchRegex, replaceValue) => (s) =>
|
||||
enabled
|
||||
? open +
|
||||
(~(s += "").indexOf(close, 4) // skip opening \x1b[
|
||||
? s.replace(searchRegex, replaceValue)
|
||||
: s) +
|
||||
close
|
||||
: s;
|
||||
|
||||
const init = (open, close) => {
|
||||
return raw(
|
||||
`\x1b[${open}m`,
|
||||
`\x1b[${close}m`,
|
||||
new RegExp(`\\x1b\\[${close}m`, "g"),
|
||||
`\x1b[${open}m`
|
||||
)
|
||||
};
|
||||
|
||||
const options = Object.defineProperty({}, "enabled", {
|
||||
get: () => enabled,
|
||||
set: (value) => (enabled = value),
|
||||
});
|
||||
const bold = raw("\x1b[1m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[1m");
|
||||
const dim = raw("\x1b[2m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[2m");
|
||||
const underline = init(4, 24);
|
||||
const red = init(31, 39);
|
||||
const green = init(32, 39);
|
||||
const yellow = init(33, 39);
|
||||
const cyan = init(36, 39);
|
||||
const gray = init(90, 39);
|
||||
|
||||
// @see https://no-color.org
|
||||
// @see https://www.npmjs.com/package/chalk
|
||||
if (process.env.FORCE_COLOR === '0' || process.env.NO_COLOR) {
|
||||
options.enabled = false;
|
||||
}
|
||||
// log to stderr to keep `rollup main.js > bundle.js` from breaking
|
||||
const stderr = console.error.bind(console);
|
||||
function handleError(err, recover = false) {
|
||||
let description = err.message || err;
|
||||
if (err.name)
|
||||
description = `${err.name}: ${description}`;
|
||||
const message = (err.plugin ? `(plugin ${err.plugin}) ${description}` : description) || err;
|
||||
stderr(bold(red(`[!] ${bold(message.toString())}`)));
|
||||
if (err.url) {
|
||||
stderr(cyan(err.url));
|
||||
}
|
||||
if (err.loc) {
|
||||
stderr(`${rollup.relativeId((err.loc.file || err.id))} (${err.loc.line}:${err.loc.column})`);
|
||||
}
|
||||
else if (err.id) {
|
||||
stderr(rollup.relativeId(err.id));
|
||||
}
|
||||
if (err.frame) {
|
||||
stderr(dim(err.frame));
|
||||
}
|
||||
if (err.stack) {
|
||||
stderr(dim(err.stack));
|
||||
}
|
||||
stderr('');
|
||||
if (!recover)
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function batchWarnings() {
|
||||
let count = 0;
|
||||
let deferredWarnings = new Map();
|
||||
let warningOccurred = false;
|
||||
return {
|
||||
add: (warning) => {
|
||||
count += 1;
|
||||
warningOccurred = true;
|
||||
if (warning.code in deferredHandlers) {
|
||||
rollup.getOrCreate(deferredWarnings, warning.code, () => []).push(warning);
|
||||
}
|
||||
else if (warning.code in immediateHandlers) {
|
||||
immediateHandlers[warning.code](warning);
|
||||
}
|
||||
else {
|
||||
title(warning.message);
|
||||
if (warning.url)
|
||||
info(warning.url);
|
||||
const id = (warning.loc && warning.loc.file) || warning.id;
|
||||
if (id) {
|
||||
const loc = warning.loc
|
||||
? `${rollup.relativeId(id)} (${warning.loc.line}:${warning.loc.column})`
|
||||
: rollup.relativeId(id);
|
||||
stderr(bold(rollup.relativeId(loc)));
|
||||
}
|
||||
if (warning.frame)
|
||||
info(warning.frame);
|
||||
}
|
||||
},
|
||||
get count() {
|
||||
return count;
|
||||
},
|
||||
flush: () => {
|
||||
if (count === 0)
|
||||
return;
|
||||
const codes = Array.from(deferredWarnings.keys()).sort((a, b) => deferredWarnings.get(b).length - deferredWarnings.get(a).length);
|
||||
for (const code of codes) {
|
||||
deferredHandlers[code](deferredWarnings.get(code));
|
||||
}
|
||||
deferredWarnings = new Map();
|
||||
count = 0;
|
||||
},
|
||||
get warningOccurred() {
|
||||
return warningOccurred;
|
||||
}
|
||||
};
|
||||
}
|
||||
const immediateHandlers = {
|
||||
MISSING_NODE_BUILTINS: warning => {
|
||||
title(`Missing shims for Node.js built-ins`);
|
||||
stderr(`Creating a browser bundle that depends on ${rollup.printQuotedStringList(warning.modules)}. You might need to include https://github.com/snowpackjs/rollup-plugin-polyfill-node`);
|
||||
},
|
||||
UNKNOWN_OPTION: warning => {
|
||||
title(`You have passed an unrecognized option`);
|
||||
stderr(warning.message);
|
||||
}
|
||||
};
|
||||
const deferredHandlers = {
|
||||
CIRCULAR_DEPENDENCY(warnings) {
|
||||
title(`Circular dependenc${warnings.length > 1 ? 'ies' : 'y'}`);
|
||||
const displayed = warnings.length > 5 ? warnings.slice(0, 3) : warnings;
|
||||
for (const warning of displayed) {
|
||||
stderr(warning.cycle.join(' -> '));
|
||||
}
|
||||
if (warnings.length > displayed.length) {
|
||||
stderr(`...and ${warnings.length - displayed.length} more`);
|
||||
}
|
||||
},
|
||||
EMPTY_BUNDLE(warnings) {
|
||||
title(`Generated${warnings.length === 1 ? ' an' : ''} empty ${warnings.length > 1 ? 'chunks' : 'chunk'}`);
|
||||
stderr(warnings.map(warning => warning.chunkName).join(', '));
|
||||
},
|
||||
EVAL(warnings) {
|
||||
title('Use of eval is strongly discouraged');
|
||||
info('https://rollupjs.org/guide/en/#avoiding-eval');
|
||||
showTruncatedWarnings(warnings);
|
||||
},
|
||||
MISSING_EXPORT(warnings) {
|
||||
title('Missing exports');
|
||||
info('https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module');
|
||||
for (const warning of warnings) {
|
||||
stderr(bold(warning.importer));
|
||||
stderr(`${warning.missing} is not exported by ${warning.exporter}`);
|
||||
stderr(gray(warning.frame));
|
||||
}
|
||||
},
|
||||
MISSING_GLOBAL_NAME(warnings) {
|
||||
title(`Missing global variable ${warnings.length > 1 ? 'names' : 'name'}`);
|
||||
stderr(`Use output.globals to specify browser global variable names corresponding to external modules`);
|
||||
for (const warning of warnings) {
|
||||
stderr(`${bold(warning.source)} (guessing '${warning.guess}')`);
|
||||
}
|
||||
},
|
||||
MIXED_EXPORTS: warnings => {
|
||||
title('Mixing named and default exports');
|
||||
info(`https://rollupjs.org/guide/en/#outputexports`);
|
||||
stderr(bold('The following entry modules are using named and default exports together:'));
|
||||
const displayedWarnings = warnings.length > 5 ? warnings.slice(0, 3) : warnings;
|
||||
for (const warning of displayedWarnings) {
|
||||
stderr(rollup.relativeId(warning.id));
|
||||
}
|
||||
if (displayedWarnings.length < warnings.length) {
|
||||
stderr(`...and ${warnings.length - displayedWarnings.length} other entry modules`);
|
||||
}
|
||||
stderr(`\nConsumers of your bundle will have to use chunk['default'] to access their default export, which may not be what you want. Use \`output.exports: 'named'\` to disable this warning`);
|
||||
},
|
||||
NAMESPACE_CONFLICT(warnings) {
|
||||
title(`Conflicting re-exports`);
|
||||
for (const warning of warnings) {
|
||||
stderr(`"${bold(rollup.relativeId(warning.reexporter))}" re-exports "${warning.name}" from both "${rollup.relativeId(warning.sources[0])}" and "${rollup.relativeId(warning.sources[1])}" (will be ignored)`);
|
||||
}
|
||||
},
|
||||
NON_EXISTENT_EXPORT(warnings) {
|
||||
title(`Import of non-existent ${warnings.length > 1 ? 'exports' : 'export'}`);
|
||||
showTruncatedWarnings(warnings);
|
||||
},
|
||||
PLUGIN_WARNING(warnings) {
|
||||
var _a;
|
||||
const nestedByPlugin = nest(warnings, 'plugin');
|
||||
for (const { key: plugin, items } of nestedByPlugin) {
|
||||
const nestedByMessage = nest(items, 'message');
|
||||
let lastUrl = '';
|
||||
for (const { key: message, items } of nestedByMessage) {
|
||||
title(`Plugin ${plugin}: ${message}`);
|
||||
for (const warning of items) {
|
||||
if (warning.url && warning.url !== lastUrl)
|
||||
info((lastUrl = warning.url));
|
||||
const id = warning.id || ((_a = warning.loc) === null || _a === void 0 ? void 0 : _a.file);
|
||||
if (id) {
|
||||
let loc = rollup.relativeId(id);
|
||||
if (warning.loc) {
|
||||
loc += `: (${warning.loc.line}:${warning.loc.column})`;
|
||||
}
|
||||
stderr(bold(loc));
|
||||
}
|
||||
if (warning.frame)
|
||||
info(warning.frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
SOURCEMAP_BROKEN(warnings) {
|
||||
title(`Broken sourcemap`);
|
||||
info('https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect');
|
||||
const plugins = [
|
||||
...new Set(warnings.map(warning => warning.plugin).filter(Boolean))
|
||||
];
|
||||
stderr(`Plugins that transform code (such as ${rollup.printQuotedStringList(plugins)}) should generate accompanying sourcemaps`);
|
||||
},
|
||||
THIS_IS_UNDEFINED(warnings) {
|
||||
title('`this` has been rewritten to `undefined`');
|
||||
info('https://rollupjs.org/guide/en/#error-this-is-undefined');
|
||||
showTruncatedWarnings(warnings);
|
||||
},
|
||||
UNRESOLVED_IMPORT(warnings) {
|
||||
title('Unresolved dependencies');
|
||||
info('https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency');
|
||||
const dependencies = new Map();
|
||||
for (const warning of warnings) {
|
||||
rollup.getOrCreate(dependencies, warning.source, () => []).push(warning.importer);
|
||||
}
|
||||
for (const dependency of dependencies.keys()) {
|
||||
const importers = dependencies.get(dependency);
|
||||
stderr(`${bold(dependency)} (imported by ${importers.join(', ')})`);
|
||||
}
|
||||
},
|
||||
UNUSED_EXTERNAL_IMPORT(warnings) {
|
||||
title('Unused external imports');
|
||||
for (const warning of warnings) {
|
||||
stderr(warning.names +
|
||||
' imported from external module "' +
|
||||
warning.source +
|
||||
'" but never used in ' +
|
||||
rollup.printQuotedStringList(warning.sources.map(id => rollup.relativeId(id))));
|
||||
}
|
||||
}
|
||||
};
|
||||
function title(str) {
|
||||
stderr(bold(yellow(`(!) ${str}`)));
|
||||
}
|
||||
function info(url) {
|
||||
stderr(gray(url));
|
||||
}
|
||||
function nest(array, prop) {
|
||||
const nested = [];
|
||||
const lookup = new Map();
|
||||
for (const item of array) {
|
||||
const key = item[prop];
|
||||
rollup.getOrCreate(lookup, key, () => {
|
||||
const items = {
|
||||
items: [],
|
||||
key
|
||||
};
|
||||
nested.push(items);
|
||||
return items;
|
||||
}).items.push(item);
|
||||
}
|
||||
return nested;
|
||||
}
|
||||
function showTruncatedWarnings(warnings) {
|
||||
const nestedByModule = nest(warnings, 'id');
|
||||
const displayedByModule = nestedByModule.length > 5 ? nestedByModule.slice(0, 3) : nestedByModule;
|
||||
for (const { key: id, items } of displayedByModule) {
|
||||
stderr(bold(rollup.relativeId(id)));
|
||||
stderr(gray(items[0].frame));
|
||||
if (items.length > 1) {
|
||||
stderr(`...and ${items.length - 1} other ${items.length > 2 ? 'occurrences' : 'occurrence'}`);
|
||||
}
|
||||
}
|
||||
if (nestedByModule.length > displayedByModule.length) {
|
||||
stderr(`\n...and ${nestedByModule.length - displayedByModule.length} other files`);
|
||||
}
|
||||
}
|
||||
|
||||
const stdinName = '-';
|
||||
let stdinResult = null;
|
||||
function stdinPlugin(arg) {
|
||||
const suffix = typeof arg == 'string' && arg.length ? '.' + arg : '';
|
||||
return {
|
||||
load(id) {
|
||||
if (id === stdinName || id.startsWith(stdinName + '.')) {
|
||||
return stdinResult || (stdinResult = readStdin());
|
||||
}
|
||||
},
|
||||
name: 'stdin',
|
||||
resolveId(id) {
|
||||
if (id === stdinName) {
|
||||
return id + suffix;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function readStdin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunks = [];
|
||||
process.stdin.setEncoding('utf8');
|
||||
process.stdin
|
||||
.on('data', chunk => chunks.push(chunk))
|
||||
.on('end', () => {
|
||||
const result = chunks.join('');
|
||||
resolve(result);
|
||||
})
|
||||
.on('error', err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function waitForInputPlugin() {
|
||||
return {
|
||||
async buildStart(options) {
|
||||
const inputSpecifiers = Array.isArray(options.input)
|
||||
? options.input
|
||||
: Object.keys(options.input);
|
||||
let lastAwaitedSpecifier = null;
|
||||
checkSpecifiers: while (true) {
|
||||
for (const specifier of inputSpecifiers) {
|
||||
if ((await this.resolve(specifier)) === null) {
|
||||
if (lastAwaitedSpecifier !== specifier) {
|
||||
stderr(`waiting for input ${bold(specifier)}...`);
|
||||
lastAwaitedSpecifier = specifier;
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
continue checkSpecifiers;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
name: 'wait-for-input'
|
||||
};
|
||||
}
|
||||
|
||||
async function addCommandPluginsToInputOptions(inputOptions, command) {
|
||||
if (command.stdin !== false) {
|
||||
inputOptions.plugins.push(stdinPlugin(command.stdin));
|
||||
}
|
||||
if (command.waitForBundleInput === true) {
|
||||
inputOptions.plugins.push(waitForInputPlugin());
|
||||
}
|
||||
await addPluginsFromCommandOption(command.plugin, inputOptions);
|
||||
}
|
||||
async function addPluginsFromCommandOption(commandPlugin, inputOptions) {
|
||||
if (commandPlugin) {
|
||||
const plugins = Array.isArray(commandPlugin) ? commandPlugin : [commandPlugin];
|
||||
for (const plugin of plugins) {
|
||||
if (/[={}]/.test(plugin)) {
|
||||
// -p plugin=value
|
||||
// -p "{transform(c,i){...}}"
|
||||
await loadAndRegisterPlugin(inputOptions, plugin);
|
||||
}
|
||||
else {
|
||||
// split out plugins joined by commas
|
||||
// -p node-resolve,commonjs,buble
|
||||
for (const p of plugin.split(',')) {
|
||||
await loadAndRegisterPlugin(inputOptions, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
async function loadAndRegisterPlugin(inputOptions, pluginText) {
|
||||
let plugin = null;
|
||||
let pluginArg = undefined;
|
||||
if (pluginText[0] === '{') {
|
||||
// -p "{transform(c,i){...}}"
|
||||
plugin = new Function('return ' + pluginText);
|
||||
}
|
||||
else {
|
||||
const match = pluginText.match(/^([@./\\\w|^{}-]+)(=(.*))?$/);
|
||||
if (match) {
|
||||
// -p plugin
|
||||
// -p plugin=arg
|
||||
pluginText = match[1];
|
||||
pluginArg = new Function('return ' + match[3])();
|
||||
}
|
||||
else {
|
||||
throw new Error(`Invalid --plugin argument format: ${JSON.stringify(pluginText)}`);
|
||||
}
|
||||
if (!/^\.|^rollup-plugin-|[@/\\]/.test(pluginText)) {
|
||||
// Try using plugin prefix variations first if applicable.
|
||||
// Prefix order is significant - left has higher precedence.
|
||||
for (const prefix of ['@rollup/plugin-', 'rollup-plugin-']) {
|
||||
try {
|
||||
plugin = await requireOrImport(prefix + pluginText);
|
||||
break;
|
||||
}
|
||||
catch (_a) {
|
||||
// if this does not work, we try requiring the actual name below
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plugin) {
|
||||
try {
|
||||
if (pluginText[0] == '.')
|
||||
pluginText = path__namespace.resolve(pluginText);
|
||||
plugin = await requireOrImport(pluginText);
|
||||
}
|
||||
catch (err) {
|
||||
throw new Error(`Cannot load plugin "${pluginText}": ${err.message}.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
// some plugins do not use `module.exports` for their entry point,
|
||||
// in which case we try the named default export and the plugin name
|
||||
if (typeof plugin === 'object') {
|
||||
plugin = plugin.default || plugin[getCamelizedPluginBaseName(pluginText)];
|
||||
}
|
||||
if (!plugin) {
|
||||
throw new Error(`Cannot find entry for plugin "${pluginText}". The plugin needs to export a function either as "default" or "${getCamelizedPluginBaseName(pluginText)}" for Rollup to recognize it.`);
|
||||
}
|
||||
inputOptions.plugins.push(typeof plugin === 'function' ? plugin.call(plugin, pluginArg) : plugin);
|
||||
}
|
||||
function getCamelizedPluginBaseName(pluginText) {
|
||||
var _a;
|
||||
return (((_a = pluginText.match(/(@rollup\/plugin-|rollup-plugin-)(.+)$/)) === null || _a === void 0 ? void 0 : _a[2]) || pluginText)
|
||||
.split(/[\\/]/)
|
||||
.slice(-1)[0]
|
||||
.split('.')[0]
|
||||
.split('-')
|
||||
.map((part, index) => (index === 0 || !part ? part : part[0].toUpperCase() + part.slice(1)))
|
||||
.join('');
|
||||
}
|
||||
async function requireOrImport(pluginPath) {
|
||||
try {
|
||||
return require(pluginPath);
|
||||
}
|
||||
catch (_a) {
|
||||
return import(pluginPath);
|
||||
}
|
||||
}
|
||||
|
||||
function supportsNativeESM() {
|
||||
return Number(/^v(\d+)/.exec(process.version)[1]) >= 13;
|
||||
}
|
||||
async function loadAndParseConfigFile(fileName, commandOptions = {}) {
|
||||
const configs = await loadConfigFile(fileName, commandOptions);
|
||||
const warnings = batchWarnings();
|
||||
try {
|
||||
const normalizedConfigs = [];
|
||||
for (const config of configs) {
|
||||
const options = mergeOptions.mergeOptions(config, commandOptions, warnings.add);
|
||||
await addCommandPluginsToInputOptions(options, commandOptions);
|
||||
normalizedConfigs.push(options);
|
||||
}
|
||||
return { options: normalizedConfigs, warnings };
|
||||
}
|
||||
catch (err) {
|
||||
warnings.flush();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
async function loadConfigFile(fileName, commandOptions) {
|
||||
const extension = path__namespace.extname(fileName);
|
||||
const configFileExport = commandOptions.configPlugin ||
|
||||
!(extension === '.cjs' || (extension === '.mjs' && supportsNativeESM()))
|
||||
? await getDefaultFromTranspiledConfigFile(fileName, commandOptions)
|
||||
: extension === '.cjs'
|
||||
? getDefaultFromCjs(require(fileName))
|
||||
: (await import(url.pathToFileURL(fileName).href)).default;
|
||||
return getConfigList(configFileExport, commandOptions);
|
||||
}
|
||||
function getDefaultFromCjs(namespace) {
|
||||
return namespace.__esModule ? namespace.default : namespace;
|
||||
}
|
||||
async function getDefaultFromTranspiledConfigFile(fileName, commandOptions) {
|
||||
const warnings = batchWarnings();
|
||||
const inputOptions = {
|
||||
external: (id) => (id[0] !== '.' && !path__namespace.isAbsolute(id)) || id.slice(-5, id.length) === '.json',
|
||||
input: fileName,
|
||||
onwarn: warnings.add,
|
||||
plugins: [],
|
||||
treeshake: false
|
||||
};
|
||||
await addPluginsFromCommandOption(commandOptions.configPlugin, inputOptions);
|
||||
const bundle = await rollup.rollup(inputOptions);
|
||||
if (!commandOptions.silent && warnings.count > 0) {
|
||||
stderr(bold(`loaded ${rollup.relativeId(fileName)} with warnings`));
|
||||
warnings.flush();
|
||||
}
|
||||
const { output: [{ code }] } = await bundle.generate({
|
||||
exports: 'named',
|
||||
format: 'cjs',
|
||||
plugins: [
|
||||
{
|
||||
name: 'transpile-import-meta',
|
||||
resolveImportMeta(property, { moduleId }) {
|
||||
if (property === 'url') {
|
||||
return `'${url.pathToFileURL(moduleId).href}'`;
|
||||
}
|
||||
if (property == null) {
|
||||
return `{url:'${url.pathToFileURL(moduleId).href}'}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
return loadConfigFromBundledFile(fileName, code);
|
||||
}
|
||||
async function loadConfigFromBundledFile(fileName, bundledCode) {
|
||||
const resolvedFileName = fs__namespace.realpathSync(fileName);
|
||||
const extension = path__namespace.extname(resolvedFileName);
|
||||
const defaultLoader = require.extensions[extension];
|
||||
require.extensions[extension] = (module, requiredFileName) => {
|
||||
if (requiredFileName === resolvedFileName) {
|
||||
module._compile(bundledCode, requiredFileName);
|
||||
}
|
||||
else {
|
||||
defaultLoader(module, requiredFileName);
|
||||
}
|
||||
};
|
||||
delete require.cache[resolvedFileName];
|
||||
try {
|
||||
const config = getDefaultFromCjs(require(fileName));
|
||||
require.extensions[extension] = defaultLoader;
|
||||
return config;
|
||||
}
|
||||
catch (err) {
|
||||
if (err.code === 'ERR_REQUIRE_ESM') {
|
||||
return rollup.error({
|
||||
code: 'TRANSPILED_ESM_CONFIG',
|
||||
message: `While loading the Rollup configuration from "${rollup.relativeId(fileName)}", Node tried to require an ES module from a CommonJS file, which is not supported. A common cause is if there is a package.json file with "type": "module" in the same folder. You can try to fix this by changing the extension of your configuration file to ".cjs" or ".mjs" depending on the content, which will prevent Rollup from trying to preprocess the file but rather hand it to Node directly.`,
|
||||
url: 'https://rollupjs.org/guide/en/#using-untranspiled-config-files'
|
||||
});
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
async function getConfigList(configFileExport, commandOptions) {
|
||||
const config = await (typeof configFileExport === 'function'
|
||||
? configFileExport(commandOptions)
|
||||
: configFileExport);
|
||||
if (Object.keys(config).length === 0) {
|
||||
return rollup.error({
|
||||
code: 'MISSING_CONFIG',
|
||||
message: 'Config file must export an options object, or an array of options objects',
|
||||
url: 'https://rollupjs.org/guide/en/#configuration-files'
|
||||
});
|
||||
}
|
||||
return Array.isArray(config) ? config : [config];
|
||||
}
|
||||
|
||||
exports.addCommandPluginsToInputOptions = addCommandPluginsToInputOptions;
|
||||
exports.batchWarnings = batchWarnings;
|
||||
exports.bold = bold;
|
||||
exports.cyan = cyan;
|
||||
exports.green = green;
|
||||
exports.handleError = handleError;
|
||||
exports.loadAndParseConfigFile = loadAndParseConfigFile;
|
||||
exports.stderr = stderr;
|
||||
exports.stdinName = stdinName;
|
||||
exports.underline = underline;
|
||||
//# sourceMappingURL=loadConfigFile.js.map
|
172
node_modules/rollup/dist/shared/mergeOptions.js
generated
vendored
Normal file
172
node_modules/rollup/dist/shared/mergeOptions.js
generated
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
@license
|
||||
Rollup.js v2.60.1
|
||||
Mon, 22 Nov 2021 07:50:11 GMT - commit 649074e14131b490ff9dfe26e94632ff458c4970
|
||||
|
||||
|
||||
https://github.com/rollup/rollup
|
||||
|
||||
Released under the MIT License.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const rollup = require('./rollup.js');
|
||||
|
||||
const commandAliases = {
|
||||
c: 'config',
|
||||
d: 'dir',
|
||||
e: 'external',
|
||||
f: 'format',
|
||||
g: 'globals',
|
||||
h: 'help',
|
||||
i: 'input',
|
||||
m: 'sourcemap',
|
||||
n: 'name',
|
||||
o: 'file',
|
||||
p: 'plugin',
|
||||
v: 'version',
|
||||
w: 'watch'
|
||||
};
|
||||
function mergeOptions(config, rawCommandOptions = { external: [], globals: undefined }, defaultOnWarnHandler = rollup.defaultOnWarn) {
|
||||
const command = getCommandOptions(rawCommandOptions);
|
||||
const inputOptions = mergeInputOptions(config, command, defaultOnWarnHandler);
|
||||
const warn = inputOptions.onwarn;
|
||||
if (command.output) {
|
||||
Object.assign(command, command.output);
|
||||
}
|
||||
const outputOptionsArray = rollup.ensureArray(config.output);
|
||||
if (outputOptionsArray.length === 0)
|
||||
outputOptionsArray.push({});
|
||||
const outputOptions = outputOptionsArray.map(singleOutputOptions => mergeOutputOptions(singleOutputOptions, command, warn));
|
||||
rollup.warnUnknownOptions(command, Object.keys(inputOptions).concat(Object.keys(outputOptions[0]).filter(option => option !== 'sourcemapPathTransform'), Object.keys(commandAliases), 'config', 'environment', 'plugin', 'silent', 'failAfterWarnings', 'stdin', 'waitForBundleInput', 'configPlugin'), 'CLI flags', warn, /^_$|output$|config/);
|
||||
inputOptions.output = outputOptions;
|
||||
return inputOptions;
|
||||
}
|
||||
function getCommandOptions(rawCommandOptions) {
|
||||
const external = rawCommandOptions.external && typeof rawCommandOptions.external === 'string'
|
||||
? rawCommandOptions.external.split(',')
|
||||
: [];
|
||||
return {
|
||||
...rawCommandOptions,
|
||||
external,
|
||||
globals: typeof rawCommandOptions.globals === 'string'
|
||||
? rawCommandOptions.globals.split(',').reduce((globals, globalDefinition) => {
|
||||
const [id, variableName] = globalDefinition.split(':');
|
||||
globals[id] = variableName;
|
||||
if (external.indexOf(id) === -1) {
|
||||
external.push(id);
|
||||
}
|
||||
return globals;
|
||||
}, Object.create(null))
|
||||
: undefined
|
||||
};
|
||||
}
|
||||
function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
|
||||
const getOption = (name) => { var _a; return (_a = overrides[name]) !== null && _a !== void 0 ? _a : config[name]; };
|
||||
const inputOptions = {
|
||||
acorn: getOption('acorn'),
|
||||
acornInjectPlugins: config.acornInjectPlugins,
|
||||
cache: config.cache,
|
||||
context: getOption('context'),
|
||||
experimentalCacheExpiry: getOption('experimentalCacheExpiry'),
|
||||
external: getExternal(config, overrides),
|
||||
inlineDynamicImports: getOption('inlineDynamicImports'),
|
||||
input: getOption('input') || [],
|
||||
makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'),
|
||||
manualChunks: getOption('manualChunks'),
|
||||
maxParallelFileReads: getOption('maxParallelFileReads'),
|
||||
moduleContext: getOption('moduleContext'),
|
||||
onwarn: getOnWarn(config, defaultOnWarnHandler),
|
||||
perf: getOption('perf'),
|
||||
plugins: rollup.ensureArray(config.plugins),
|
||||
preserveEntrySignatures: getOption('preserveEntrySignatures'),
|
||||
preserveModules: getOption('preserveModules'),
|
||||
preserveSymlinks: getOption('preserveSymlinks'),
|
||||
shimMissingExports: getOption('shimMissingExports'),
|
||||
strictDeprecations: getOption('strictDeprecations'),
|
||||
treeshake: getObjectOption(config, overrides, 'treeshake', rollup.objectifyOptionWithPresets(rollup.treeshakePresets, 'treeshake', 'false, true, ')),
|
||||
watch: getWatch(config, overrides, 'watch')
|
||||
};
|
||||
rollup.warnUnknownOptions(config, Object.keys(inputOptions), 'input options', inputOptions.onwarn, /^output$/);
|
||||
return inputOptions;
|
||||
}
|
||||
const getExternal = (config, overrides) => {
|
||||
const configExternal = config.external;
|
||||
return typeof configExternal === 'function'
|
||||
? (source, importer, isResolved) => configExternal(source, importer, isResolved) || overrides.external.indexOf(source) !== -1
|
||||
: rollup.ensureArray(configExternal).concat(overrides.external);
|
||||
};
|
||||
const getOnWarn = (config, defaultOnWarnHandler) => config.onwarn
|
||||
? warning => config.onwarn(warning, defaultOnWarnHandler)
|
||||
: defaultOnWarnHandler;
|
||||
const getObjectOption = (config, overrides, name, objectifyValue = value => (typeof value === 'object' ? value : {})) => {
|
||||
const commandOption = normalizeObjectOptionValue(overrides[name], objectifyValue);
|
||||
const configOption = normalizeObjectOptionValue(config[name], objectifyValue);
|
||||
if (commandOption !== undefined) {
|
||||
return commandOption && { ...configOption, ...commandOption };
|
||||
}
|
||||
return configOption;
|
||||
};
|
||||
const getWatch = (config, overrides, name) => config.watch !== false && getObjectOption(config, overrides, name);
|
||||
const normalizeObjectOptionValue = (optionValue, objectifyValue) => {
|
||||
if (!optionValue) {
|
||||
return optionValue;
|
||||
}
|
||||
if (Array.isArray(optionValue)) {
|
||||
return optionValue.reduce((result, value) => value && result && { ...result, ...objectifyValue(value) }, {});
|
||||
}
|
||||
return objectifyValue(optionValue);
|
||||
};
|
||||
function mergeOutputOptions(config, overrides, warn) {
|
||||
const getOption = (name) => { var _a; return (_a = overrides[name]) !== null && _a !== void 0 ? _a : config[name]; };
|
||||
const outputOptions = {
|
||||
amd: getObjectOption(config, overrides, 'amd'),
|
||||
assetFileNames: getOption('assetFileNames'),
|
||||
banner: getOption('banner'),
|
||||
chunkFileNames: getOption('chunkFileNames'),
|
||||
compact: getOption('compact'),
|
||||
dir: getOption('dir'),
|
||||
dynamicImportFunction: getOption('dynamicImportFunction'),
|
||||
entryFileNames: getOption('entryFileNames'),
|
||||
esModule: getOption('esModule'),
|
||||
exports: getOption('exports'),
|
||||
extend: getOption('extend'),
|
||||
externalLiveBindings: getOption('externalLiveBindings'),
|
||||
file: getOption('file'),
|
||||
footer: getOption('footer'),
|
||||
format: getOption('format'),
|
||||
freeze: getOption('freeze'),
|
||||
generatedCode: getObjectOption(config, overrides, 'generatedCode', rollup.objectifyOptionWithPresets(rollup.generatedCodePresets, 'output.generatedCode', '')),
|
||||
globals: getOption('globals'),
|
||||
hoistTransitiveImports: getOption('hoistTransitiveImports'),
|
||||
indent: getOption('indent'),
|
||||
inlineDynamicImports: getOption('inlineDynamicImports'),
|
||||
interop: getOption('interop'),
|
||||
intro: getOption('intro'),
|
||||
manualChunks: getOption('manualChunks'),
|
||||
minifyInternalExports: getOption('minifyInternalExports'),
|
||||
name: getOption('name'),
|
||||
namespaceToStringTag: getOption('namespaceToStringTag'),
|
||||
noConflict: getOption('noConflict'),
|
||||
outro: getOption('outro'),
|
||||
paths: getOption('paths'),
|
||||
plugins: rollup.ensureArray(config.plugins),
|
||||
preferConst: getOption('preferConst'),
|
||||
preserveModules: getOption('preserveModules'),
|
||||
preserveModulesRoot: getOption('preserveModulesRoot'),
|
||||
sanitizeFileName: getOption('sanitizeFileName'),
|
||||
sourcemap: getOption('sourcemap'),
|
||||
sourcemapExcludeSources: getOption('sourcemapExcludeSources'),
|
||||
sourcemapFile: getOption('sourcemapFile'),
|
||||
sourcemapPathTransform: getOption('sourcemapPathTransform'),
|
||||
strict: getOption('strict'),
|
||||
systemNullSetters: getOption('systemNullSetters'),
|
||||
validate: getOption('validate')
|
||||
};
|
||||
rollup.warnUnknownOptions(config, Object.keys(outputOptions), 'output options', warn);
|
||||
return outputOptions;
|
||||
}
|
||||
|
||||
exports.commandAliases = commandAliases;
|
||||
exports.mergeOptions = mergeOptions;
|
||||
//# sourceMappingURL=mergeOptions.js.map
|
23628
node_modules/rollup/dist/shared/rollup.js
generated
vendored
Normal file
23628
node_modules/rollup/dist/shared/rollup.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
455
node_modules/rollup/dist/shared/watch-cli.js
generated
vendored
Normal file
455
node_modules/rollup/dist/shared/watch-cli.js
generated
vendored
Normal file
@@ -0,0 +1,455 @@
|
||||
/*
|
||||
@license
|
||||
Rollup.js v2.60.1
|
||||
Mon, 22 Nov 2021 07:50:11 GMT - commit 649074e14131b490ff9dfe26e94632ff458c4970
|
||||
|
||||
|
||||
https://github.com/rollup/rollup
|
||||
|
||||
Released under the MIT License.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const index = require('./index.js');
|
||||
const loadConfigFile_js = require('./loadConfigFile.js');
|
||||
const cli = require('../bin/rollup');
|
||||
const rollup = require('./rollup.js');
|
||||
const require$$0 = require('assert');
|
||||
const require$$0$1 = require('events');
|
||||
require('path');
|
||||
require('util');
|
||||
require('stream');
|
||||
require('os');
|
||||
require('url');
|
||||
require('tty');
|
||||
require('./mergeOptions.js');
|
||||
require('module');
|
||||
require('crypto');
|
||||
|
||||
function timeZone(date = new Date()) {
|
||||
const offset = date.getTimezoneOffset();
|
||||
const absOffset = Math.abs(offset);
|
||||
const hours = Math.floor(absOffset / 60);
|
||||
const minutes = absOffset % 60;
|
||||
const minutesOut = minutes > 0 ? ':' + ('0' + minutes).slice(-2) : '';
|
||||
return (offset < 0 ? '+' : '-') + hours + minutesOut;
|
||||
}
|
||||
|
||||
function dateTime(options = {}) {
|
||||
let {
|
||||
date = new Date(),
|
||||
local = true,
|
||||
showTimeZone = false,
|
||||
showMilliseconds = false
|
||||
} = options;
|
||||
|
||||
if (local) {
|
||||
// Offset the date so it will return the correct value when getting the ISO string.
|
||||
date = new Date(date.getTime() - (date.getTimezoneOffset() * 60000));
|
||||
}
|
||||
|
||||
let end = '';
|
||||
|
||||
if (showTimeZone) {
|
||||
end = ' UTC' + (local ? timeZone(date) : '');
|
||||
}
|
||||
|
||||
if (showMilliseconds && date.getUTCMilliseconds() > 0) {
|
||||
end = ` ${date.getUTCMilliseconds()}ms${end}`;
|
||||
}
|
||||
|
||||
return date
|
||||
.toISOString()
|
||||
.replace(/T/, ' ')
|
||||
.replace(/\..+/, end);
|
||||
}
|
||||
|
||||
var signalExit = {exports: {}};
|
||||
|
||||
var signals$1 = {exports: {}};
|
||||
|
||||
(function (module) {
|
||||
// This is not the set of all possible signals.
|
||||
//
|
||||
// It IS, however, the set of all signals that trigger
|
||||
// an exit on either Linux or BSD systems. Linux is a
|
||||
// superset of the signal names supported on BSD, and
|
||||
// the unknown signals just fail to register, so we can
|
||||
// catch that easily enough.
|
||||
//
|
||||
// Don't bother with SIGKILL. It's uncatchable, which
|
||||
// means that we can't fire any callbacks anyway.
|
||||
//
|
||||
// If a user does happen to register a handler on a non-
|
||||
// fatal signal like SIGWINCH or something, and then
|
||||
// exit, it'll end up firing `process.emit('exit')`, so
|
||||
// the handler will be fired anyway.
|
||||
//
|
||||
// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
|
||||
// artificially, inherently leave the process in a
|
||||
// state from which it is not safe to try and enter JS
|
||||
// listeners.
|
||||
module.exports = [
|
||||
'SIGABRT',
|
||||
'SIGALRM',
|
||||
'SIGHUP',
|
||||
'SIGINT',
|
||||
'SIGTERM'
|
||||
];
|
||||
|
||||
if (process.platform !== 'win32') {
|
||||
module.exports.push(
|
||||
'SIGVTALRM',
|
||||
'SIGXCPU',
|
||||
'SIGXFSZ',
|
||||
'SIGUSR2',
|
||||
'SIGTRAP',
|
||||
'SIGSYS',
|
||||
'SIGQUIT',
|
||||
'SIGIOT'
|
||||
// should detect profiler and enable/disable accordingly.
|
||||
// see #21
|
||||
// 'SIGPROF'
|
||||
);
|
||||
}
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
module.exports.push(
|
||||
'SIGIO',
|
||||
'SIGPOLL',
|
||||
'SIGPWR',
|
||||
'SIGSTKFLT',
|
||||
'SIGUNUSED'
|
||||
);
|
||||
}
|
||||
}(signals$1));
|
||||
|
||||
// Note: since nyc uses this module to output coverage, any lines
|
||||
// that are in the direct sync flow of nyc's outputCoverage are
|
||||
// ignored, since we can never get coverage for them.
|
||||
// grab a reference to node's real process object right away
|
||||
var process$1 = rollup.commonjsGlobal.process;
|
||||
// some kind of non-node environment, just no-op
|
||||
if (typeof process$1 !== 'object' || !process$1) {
|
||||
signalExit.exports = function () {};
|
||||
} else {
|
||||
var assert = require$$0;
|
||||
var signals = signals$1.exports;
|
||||
var isWin = /^win/i.test(process$1.platform);
|
||||
|
||||
var EE = require$$0$1;
|
||||
/* istanbul ignore if */
|
||||
if (typeof EE !== 'function') {
|
||||
EE = EE.EventEmitter;
|
||||
}
|
||||
|
||||
var emitter;
|
||||
if (process$1.__signal_exit_emitter__) {
|
||||
emitter = process$1.__signal_exit_emitter__;
|
||||
} else {
|
||||
emitter = process$1.__signal_exit_emitter__ = new EE();
|
||||
emitter.count = 0;
|
||||
emitter.emitted = {};
|
||||
}
|
||||
|
||||
// Because this emitter is a global, we have to check to see if a
|
||||
// previous version of this library failed to enable infinite listeners.
|
||||
// I know what you're about to say. But literally everything about
|
||||
// signal-exit is a compromise with evil. Get used to it.
|
||||
if (!emitter.infinite) {
|
||||
emitter.setMaxListeners(Infinity);
|
||||
emitter.infinite = true;
|
||||
}
|
||||
|
||||
signalExit.exports = function (cb, opts) {
|
||||
if (rollup.commonjsGlobal.process !== process$1) {
|
||||
return
|
||||
}
|
||||
assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
|
||||
|
||||
if (loaded === false) {
|
||||
load();
|
||||
}
|
||||
|
||||
var ev = 'exit';
|
||||
if (opts && opts.alwaysLast) {
|
||||
ev = 'afterexit';
|
||||
}
|
||||
|
||||
var remove = function () {
|
||||
emitter.removeListener(ev, cb);
|
||||
if (emitter.listeners('exit').length === 0 &&
|
||||
emitter.listeners('afterexit').length === 0) {
|
||||
unload();
|
||||
}
|
||||
};
|
||||
emitter.on(ev, cb);
|
||||
|
||||
return remove
|
||||
};
|
||||
|
||||
var unload = function unload () {
|
||||
if (!loaded || rollup.commonjsGlobal.process !== process$1) {
|
||||
return
|
||||
}
|
||||
loaded = false;
|
||||
|
||||
signals.forEach(function (sig) {
|
||||
try {
|
||||
process$1.removeListener(sig, sigListeners[sig]);
|
||||
} catch (er) {}
|
||||
});
|
||||
process$1.emit = originalProcessEmit;
|
||||
process$1.reallyExit = originalProcessReallyExit;
|
||||
emitter.count -= 1;
|
||||
};
|
||||
signalExit.exports.unload = unload;
|
||||
|
||||
var emit = function emit (event, code, signal) {
|
||||
if (emitter.emitted[event]) {
|
||||
return
|
||||
}
|
||||
emitter.emitted[event] = true;
|
||||
emitter.emit(event, code, signal);
|
||||
};
|
||||
|
||||
// { <signal>: <listener fn>, ... }
|
||||
var sigListeners = {};
|
||||
signals.forEach(function (sig) {
|
||||
sigListeners[sig] = function listener () {
|
||||
if (process$1 !== rollup.commonjsGlobal.process) {
|
||||
return
|
||||
}
|
||||
// If there are no other listeners, an exit is coming!
|
||||
// Simplest way: remove us and then re-send the signal.
|
||||
// We know that this will kill the process, so we can
|
||||
// safely emit now.
|
||||
var listeners = process$1.listeners(sig);
|
||||
if (listeners.length === emitter.count) {
|
||||
unload();
|
||||
emit('exit', null, sig);
|
||||
/* istanbul ignore next */
|
||||
emit('afterexit', null, sig);
|
||||
/* istanbul ignore next */
|
||||
if (isWin && sig === 'SIGHUP') {
|
||||
// "SIGHUP" throws an `ENOSYS` error on Windows,
|
||||
// so use a supported signal instead
|
||||
sig = 'SIGINT';
|
||||
}
|
||||
process$1.kill(process$1.pid, sig);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
signalExit.exports.signals = function () {
|
||||
return signals
|
||||
};
|
||||
|
||||
var loaded = false;
|
||||
|
||||
var load = function load () {
|
||||
if (loaded || process$1 !== rollup.commonjsGlobal.process) {
|
||||
return
|
||||
}
|
||||
loaded = true;
|
||||
|
||||
// This is the number of onSignalExit's that are in play.
|
||||
// It's important so that we can count the correct number of
|
||||
// listeners on signals, and don't wait for the other one to
|
||||
// handle it instead of us.
|
||||
emitter.count += 1;
|
||||
|
||||
signals = signals.filter(function (sig) {
|
||||
try {
|
||||
process$1.on(sig, sigListeners[sig]);
|
||||
return true
|
||||
} catch (er) {
|
||||
return false
|
||||
}
|
||||
});
|
||||
|
||||
process$1.emit = processEmit;
|
||||
process$1.reallyExit = processReallyExit;
|
||||
};
|
||||
signalExit.exports.load = load;
|
||||
|
||||
var originalProcessReallyExit = process$1.reallyExit;
|
||||
var processReallyExit = function processReallyExit (code) {
|
||||
if (process$1 !== rollup.commonjsGlobal.process) {
|
||||
return
|
||||
}
|
||||
process$1.exitCode = code || 0;
|
||||
emit('exit', process$1.exitCode, null);
|
||||
/* istanbul ignore next */
|
||||
emit('afterexit', process$1.exitCode, null);
|
||||
/* istanbul ignore next */
|
||||
originalProcessReallyExit.call(process$1, process$1.exitCode);
|
||||
};
|
||||
|
||||
var originalProcessEmit = process$1.emit;
|
||||
var processEmit = function processEmit (ev, arg) {
|
||||
if (ev === 'exit' && process$1 === rollup.commonjsGlobal.process) {
|
||||
if (arg !== undefined) {
|
||||
process$1.exitCode = arg;
|
||||
}
|
||||
var ret = originalProcessEmit.apply(this, arguments);
|
||||
emit('exit', process$1.exitCode, null);
|
||||
/* istanbul ignore next */
|
||||
emit('afterexit', process$1.exitCode, null);
|
||||
return ret
|
||||
} else {
|
||||
return originalProcessEmit.apply(this, arguments)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const onExit = signalExit.exports;
|
||||
|
||||
const CLEAR_SCREEN = '\u001Bc';
|
||||
function getResetScreen(configs, allowClearScreen) {
|
||||
let clearScreen = allowClearScreen;
|
||||
for (const config of configs) {
|
||||
if (config.watch && config.watch.clearScreen === false) {
|
||||
clearScreen = false;
|
||||
}
|
||||
}
|
||||
if (clearScreen) {
|
||||
return (heading) => loadConfigFile_js.stderr(CLEAR_SCREEN + heading);
|
||||
}
|
||||
let firstRun = true;
|
||||
return (heading) => {
|
||||
if (firstRun) {
|
||||
loadConfigFile_js.stderr(heading);
|
||||
firstRun = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async function watch(command) {
|
||||
process.env.ROLLUP_WATCH = 'true';
|
||||
const isTTY = process.stderr.isTTY;
|
||||
const silent = command.silent;
|
||||
let configs;
|
||||
let warnings;
|
||||
let watcher;
|
||||
let configWatcher;
|
||||
const configFile = command.config ? cli.getConfigPath(command.config) : null;
|
||||
onExit(close);
|
||||
process.on('uncaughtException', close);
|
||||
if (!process.stdin.isTTY) {
|
||||
process.stdin.on('end', close);
|
||||
process.stdin.resume();
|
||||
}
|
||||
async function loadConfigFromFileAndTrack(configFile) {
|
||||
let reloadingConfig = false;
|
||||
let aborted = false;
|
||||
let configFileData = null;
|
||||
configWatcher = index.chokidar.watch(configFile).on('change', () => reloadConfigFile());
|
||||
await reloadConfigFile();
|
||||
async function reloadConfigFile() {
|
||||
try {
|
||||
const newConfigFileData = fs.readFileSync(configFile, 'utf-8');
|
||||
if (newConfigFileData === configFileData) {
|
||||
return;
|
||||
}
|
||||
if (reloadingConfig) {
|
||||
aborted = true;
|
||||
return;
|
||||
}
|
||||
if (configFileData) {
|
||||
loadConfigFile_js.stderr(`\nReloading updated config...`);
|
||||
}
|
||||
configFileData = newConfigFileData;
|
||||
reloadingConfig = true;
|
||||
({ options: configs, warnings } = await loadConfigFile_js.loadAndParseConfigFile(configFile, command));
|
||||
reloadingConfig = false;
|
||||
if (aborted) {
|
||||
aborted = false;
|
||||
reloadConfigFile();
|
||||
}
|
||||
else {
|
||||
if (watcher) {
|
||||
watcher.close();
|
||||
}
|
||||
start(configs);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
configs = [];
|
||||
reloadingConfig = false;
|
||||
loadConfigFile_js.handleError(err, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (configFile) {
|
||||
await loadConfigFromFileAndTrack(configFile);
|
||||
}
|
||||
else {
|
||||
({ options: configs, warnings } = await cli.loadConfigFromCommand(command));
|
||||
start(configs);
|
||||
}
|
||||
const resetScreen = getResetScreen(configs, isTTY);
|
||||
function start(configs) {
|
||||
try {
|
||||
watcher = rollup.watch(configs);
|
||||
}
|
||||
catch (err) {
|
||||
return loadConfigFile_js.handleError(err);
|
||||
}
|
||||
watcher.on('event', event => {
|
||||
switch (event.code) {
|
||||
case 'ERROR':
|
||||
warnings.flush();
|
||||
loadConfigFile_js.handleError(event.error, true);
|
||||
break;
|
||||
case 'START':
|
||||
if (!silent) {
|
||||
resetScreen(loadConfigFile_js.underline(`rollup v${rollup.version}`));
|
||||
}
|
||||
break;
|
||||
case 'BUNDLE_START':
|
||||
if (!silent) {
|
||||
let input = event.input;
|
||||
if (typeof input !== 'string') {
|
||||
input = Array.isArray(input)
|
||||
? input.join(', ')
|
||||
: Object.values(input).join(', ');
|
||||
}
|
||||
loadConfigFile_js.stderr(loadConfigFile_js.cyan(`bundles ${loadConfigFile_js.bold(input)} → ${loadConfigFile_js.bold(event.output.map(rollup.relativeId).join(', '))}...`));
|
||||
}
|
||||
break;
|
||||
case 'BUNDLE_END':
|
||||
warnings.flush();
|
||||
if (!silent)
|
||||
loadConfigFile_js.stderr(loadConfigFile_js.green(`created ${loadConfigFile_js.bold(event.output.map(rollup.relativeId).join(', '))} in ${loadConfigFile_js.bold(cli.ms(event.duration))}`));
|
||||
if (event.result && event.result.getTimings) {
|
||||
cli.printTimings(event.result.getTimings());
|
||||
}
|
||||
break;
|
||||
case 'END':
|
||||
if (!silent && isTTY) {
|
||||
loadConfigFile_js.stderr(`\n[${dateTime()}] waiting for changes...`);
|
||||
}
|
||||
}
|
||||
if ('result' in event && event.result) {
|
||||
event.result.close().catch(error => loadConfigFile_js.handleError(error, true));
|
||||
}
|
||||
});
|
||||
}
|
||||
function close(code) {
|
||||
process.removeListener('uncaughtException', close);
|
||||
// removing a non-existent listener is a no-op
|
||||
process.stdin.removeListener('end', close);
|
||||
if (watcher)
|
||||
watcher.close();
|
||||
if (configWatcher)
|
||||
configWatcher.close();
|
||||
if (code) {
|
||||
process.exit(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.watch = watch;
|
||||
//# sourceMappingURL=watch-cli.js.map
|
304
node_modules/rollup/dist/shared/watch.js
generated
vendored
Normal file
304
node_modules/rollup/dist/shared/watch.js
generated
vendored
Normal file
@@ -0,0 +1,304 @@
|
||||
/*
|
||||
@license
|
||||
Rollup.js v2.60.1
|
||||
Mon, 22 Nov 2021 07:50:11 GMT - commit 649074e14131b490ff9dfe26e94632ff458c4970
|
||||
|
||||
|
||||
https://github.com/rollup/rollup
|
||||
|
||||
Released under the MIT License.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const rollup = require('./rollup.js');
|
||||
const mergeOptions = require('./mergeOptions.js');
|
||||
const require$$2 = require('os');
|
||||
const index = require('./index.js');
|
||||
require('crypto');
|
||||
require('fs');
|
||||
require('events');
|
||||
require('util');
|
||||
require('stream');
|
||||
|
||||
function _interopNamespaceDefault(e) {
|
||||
const n = Object.create(null);
|
||||
if (e) {
|
||||
for (const k in e) {
|
||||
n[k] = e[k];
|
||||
}
|
||||
}
|
||||
n.default = e;
|
||||
return n;
|
||||
}
|
||||
|
||||
const path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
||||
|
||||
class FileWatcher {
|
||||
constructor(task, chokidarOptions) {
|
||||
this.transformWatchers = new Map();
|
||||
this.chokidarOptions = chokidarOptions;
|
||||
this.task = task;
|
||||
this.watcher = this.createWatcher(null);
|
||||
}
|
||||
close() {
|
||||
this.watcher.close();
|
||||
for (const watcher of this.transformWatchers.values()) {
|
||||
watcher.close();
|
||||
}
|
||||
}
|
||||
unwatch(id) {
|
||||
this.watcher.unwatch(id);
|
||||
const transformWatcher = this.transformWatchers.get(id);
|
||||
if (transformWatcher) {
|
||||
this.transformWatchers.delete(id);
|
||||
transformWatcher.close();
|
||||
}
|
||||
}
|
||||
watch(id, isTransformDependency) {
|
||||
if (isTransformDependency) {
|
||||
const watcher = this.transformWatchers.get(id) || this.createWatcher(id);
|
||||
watcher.add(id);
|
||||
this.transformWatchers.set(id, watcher);
|
||||
}
|
||||
else {
|
||||
this.watcher.add(id);
|
||||
}
|
||||
}
|
||||
createWatcher(transformWatcherId) {
|
||||
const task = this.task;
|
||||
const isLinux = require$$2.platform() === 'linux';
|
||||
const isTransformDependency = transformWatcherId !== null;
|
||||
const handleChange = (id, event) => {
|
||||
const changedId = transformWatcherId || id;
|
||||
if (isLinux) {
|
||||
// unwatching and watching fixes an issue with chokidar where on certain systems,
|
||||
// a file that was unlinked and immediately recreated would create a change event
|
||||
// but then no longer any further events
|
||||
watcher.unwatch(changedId);
|
||||
watcher.add(changedId);
|
||||
}
|
||||
task.invalidate(changedId, { event, isTransformDependency });
|
||||
};
|
||||
const watcher = index.chokidar
|
||||
.watch([], this.chokidarOptions)
|
||||
.on('add', id => handleChange(id, 'create'))
|
||||
.on('change', id => handleChange(id, 'update'))
|
||||
.on('unlink', id => handleChange(id, 'delete'));
|
||||
return watcher;
|
||||
}
|
||||
}
|
||||
|
||||
const eventsRewrites = {
|
||||
create: {
|
||||
create: 'buggy',
|
||||
delete: null,
|
||||
update: 'create'
|
||||
},
|
||||
delete: {
|
||||
create: 'update',
|
||||
delete: 'buggy',
|
||||
update: 'buggy'
|
||||
},
|
||||
update: {
|
||||
create: 'buggy',
|
||||
delete: 'delete',
|
||||
update: 'update'
|
||||
}
|
||||
};
|
||||
class Watcher {
|
||||
constructor(configs, emitter) {
|
||||
this.buildDelay = 0;
|
||||
this.buildTimeout = null;
|
||||
this.invalidatedIds = new Map();
|
||||
this.rerun = false;
|
||||
this.running = true;
|
||||
this.emitter = emitter;
|
||||
emitter.close = this.close.bind(this);
|
||||
this.tasks = configs.map(config => new Task(this, config));
|
||||
this.buildDelay = configs.reduce((buildDelay, { watch }) => watch && typeof watch.buildDelay === 'number'
|
||||
? Math.max(buildDelay, watch.buildDelay)
|
||||
: buildDelay, this.buildDelay);
|
||||
process.nextTick(() => this.run());
|
||||
}
|
||||
close() {
|
||||
if (this.buildTimeout)
|
||||
clearTimeout(this.buildTimeout);
|
||||
for (const task of this.tasks) {
|
||||
task.close();
|
||||
}
|
||||
this.emitter.emit('close');
|
||||
this.emitter.removeAllListeners();
|
||||
}
|
||||
invalidate(file) {
|
||||
if (file) {
|
||||
const prevEvent = this.invalidatedIds.get(file.id);
|
||||
const event = prevEvent ? eventsRewrites[prevEvent][file.event] : file.event;
|
||||
if (event === 'buggy') {
|
||||
//TODO: throws or warn? Currently just ignore, uses new event
|
||||
this.invalidatedIds.set(file.id, file.event);
|
||||
}
|
||||
else if (event === null) {
|
||||
this.invalidatedIds.delete(file.id);
|
||||
}
|
||||
else {
|
||||
this.invalidatedIds.set(file.id, event);
|
||||
}
|
||||
}
|
||||
if (this.running) {
|
||||
this.rerun = true;
|
||||
return;
|
||||
}
|
||||
if (this.buildTimeout)
|
||||
clearTimeout(this.buildTimeout);
|
||||
this.buildTimeout = setTimeout(() => {
|
||||
this.buildTimeout = null;
|
||||
for (const [id, event] of this.invalidatedIds.entries()) {
|
||||
this.emitter.emit('change', id, { event });
|
||||
}
|
||||
this.invalidatedIds.clear();
|
||||
this.emitter.emit('restart');
|
||||
this.run();
|
||||
}, this.buildDelay);
|
||||
}
|
||||
async run() {
|
||||
this.running = true;
|
||||
this.emitter.emit('event', {
|
||||
code: 'START'
|
||||
});
|
||||
for (const task of this.tasks) {
|
||||
await task.run();
|
||||
}
|
||||
this.running = false;
|
||||
this.emitter.emit('event', {
|
||||
code: 'END'
|
||||
});
|
||||
if (this.rerun) {
|
||||
this.rerun = false;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
class Task {
|
||||
constructor(watcher, config) {
|
||||
this.cache = { modules: [] };
|
||||
this.watchFiles = [];
|
||||
this.closed = false;
|
||||
this.invalidated = true;
|
||||
this.watched = new Set();
|
||||
this.watcher = watcher;
|
||||
this.skipWrite = Boolean(config.watch && config.watch.skipWrite);
|
||||
this.options = mergeOptions.mergeOptions(config);
|
||||
this.outputs = this.options.output;
|
||||
this.outputFiles = this.outputs.map(output => {
|
||||
if (output.file || output.dir)
|
||||
return path__namespace.resolve(output.file || output.dir);
|
||||
return undefined;
|
||||
});
|
||||
const watchOptions = this.options.watch || {};
|
||||
this.filter = rollup.createFilter(watchOptions.include, watchOptions.exclude);
|
||||
this.fileWatcher = new FileWatcher(this, {
|
||||
...watchOptions.chokidar,
|
||||
disableGlobbing: true,
|
||||
ignoreInitial: true
|
||||
});
|
||||
}
|
||||
close() {
|
||||
this.closed = true;
|
||||
this.fileWatcher.close();
|
||||
}
|
||||
invalidate(id, details) {
|
||||
this.invalidated = true;
|
||||
if (details.isTransformDependency) {
|
||||
for (const module of this.cache.modules) {
|
||||
if (module.transformDependencies.indexOf(id) === -1)
|
||||
continue;
|
||||
// effective invalidation
|
||||
module.originalCode = null;
|
||||
}
|
||||
}
|
||||
this.watcher.invalidate({ event: details.event, id });
|
||||
}
|
||||
async run() {
|
||||
if (!this.invalidated)
|
||||
return;
|
||||
this.invalidated = false;
|
||||
const options = {
|
||||
...this.options,
|
||||
cache: this.cache
|
||||
};
|
||||
const start = Date.now();
|
||||
this.watcher.emitter.emit('event', {
|
||||
code: 'BUNDLE_START',
|
||||
input: this.options.input,
|
||||
output: this.outputFiles
|
||||
});
|
||||
let result = null;
|
||||
try {
|
||||
result = await rollup.rollupInternal(options, this.watcher.emitter);
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
this.updateWatchedFiles(result);
|
||||
this.skipWrite || (await Promise.all(this.outputs.map(output => result.write(output))));
|
||||
this.watcher.emitter.emit('event', {
|
||||
code: 'BUNDLE_END',
|
||||
duration: Date.now() - start,
|
||||
input: this.options.input,
|
||||
output: this.outputFiles,
|
||||
result
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
if (!this.closed) {
|
||||
if (Array.isArray(error.watchFiles)) {
|
||||
for (const id of error.watchFiles) {
|
||||
this.watchFile(id);
|
||||
}
|
||||
}
|
||||
if (error.id) {
|
||||
this.cache.modules = this.cache.modules.filter(module => module.id !== error.id);
|
||||
}
|
||||
}
|
||||
this.watcher.emitter.emit('event', {
|
||||
code: 'ERROR',
|
||||
error,
|
||||
result
|
||||
});
|
||||
}
|
||||
}
|
||||
updateWatchedFiles(result) {
|
||||
const previouslyWatched = this.watched;
|
||||
this.watched = new Set();
|
||||
this.watchFiles = result.watchFiles;
|
||||
this.cache = result.cache;
|
||||
for (const id of this.watchFiles) {
|
||||
this.watchFile(id);
|
||||
}
|
||||
for (const module of this.cache.modules) {
|
||||
for (const depId of module.transformDependencies) {
|
||||
this.watchFile(depId, true);
|
||||
}
|
||||
}
|
||||
for (const id of previouslyWatched) {
|
||||
if (!this.watched.has(id)) {
|
||||
this.fileWatcher.unwatch(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
watchFile(id, isTransformDependency = false) {
|
||||
if (!this.filter(id))
|
||||
return;
|
||||
this.watched.add(id);
|
||||
if (this.outputFiles.some(file => file === id)) {
|
||||
throw new Error('Cannot import the generated bundle');
|
||||
}
|
||||
// this is necessary to ensure that any 'renamed' files
|
||||
// continue to be watched following an error
|
||||
this.fileWatcher.watch(id, isTransformDependency);
|
||||
}
|
||||
}
|
||||
|
||||
exports.Task = Task;
|
||||
exports.Watcher = Watcher;
|
||||
//# sourceMappingURL=watch.js.map
|
Reference in New Issue
Block a user