rollup 2.59.0 → 2.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/bin/rollup +5 -5
- package/dist/es/rollup.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +65 -28
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.browser.js.map +1 -1
- package/dist/rollup.d.ts +1 -0
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +26 -15
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +65 -28
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
package/dist/rollup.d.ts
CHANGED
|
@@ -198,6 +198,7 @@ export interface PluginContext extends MinimalPluginContext {
|
|
|
198
198
|
getWatchFiles: () => string[];
|
|
199
199
|
/** @deprecated Use `this.resolve` instead */
|
|
200
200
|
isExternal: IsExternal;
|
|
201
|
+
load: (options: { id: string } & Partial<PartialNull<ModuleOptions>>) => Promise<ModuleInfo>;
|
|
201
202
|
/** @deprecated Use `this.getModuleIds` instead */
|
|
202
203
|
moduleIds: IterableIterator<string>;
|
|
203
204
|
parse: (input: string, options?: any) => AcornNode;
|
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.60.0
|
|
4
|
+
Fri, 12 Nov 2021 05:12:41 GMT - commit 8d98341bf746d4baa57bbd730b1fa6449555cfca
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -385,33 +385,35 @@ function waitForInputPlugin() {
|
|
|
385
385
|
};
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
-
function addCommandPluginsToInputOptions(inputOptions, command) {
|
|
388
|
+
async function addCommandPluginsToInputOptions(inputOptions, command) {
|
|
389
389
|
if (command.stdin !== false) {
|
|
390
390
|
inputOptions.plugins.push(stdinPlugin(command.stdin));
|
|
391
391
|
}
|
|
392
392
|
if (command.waitForBundleInput === true) {
|
|
393
393
|
inputOptions.plugins.push(waitForInputPlugin());
|
|
394
394
|
}
|
|
395
|
-
addPluginsFromCommandOption(command.plugin, inputOptions);
|
|
395
|
+
await addPluginsFromCommandOption(command.plugin, inputOptions);
|
|
396
396
|
}
|
|
397
|
-
function addPluginsFromCommandOption(commandPlugin, inputOptions) {
|
|
397
|
+
async function addPluginsFromCommandOption(commandPlugin, inputOptions) {
|
|
398
398
|
if (commandPlugin) {
|
|
399
399
|
const plugins = Array.isArray(commandPlugin) ? commandPlugin : [commandPlugin];
|
|
400
400
|
for (const plugin of plugins) {
|
|
401
401
|
if (/[={}]/.test(plugin)) {
|
|
402
402
|
// -p plugin=value
|
|
403
403
|
// -p "{transform(c,i){...}}"
|
|
404
|
-
loadAndRegisterPlugin(inputOptions, plugin);
|
|
404
|
+
await loadAndRegisterPlugin(inputOptions, plugin);
|
|
405
405
|
}
|
|
406
406
|
else {
|
|
407
407
|
// split out plugins joined by commas
|
|
408
408
|
// -p node-resolve,commonjs,buble
|
|
409
|
-
plugin.split(',')
|
|
409
|
+
for (const p of plugin.split(',')) {
|
|
410
|
+
await loadAndRegisterPlugin(inputOptions, p);
|
|
411
|
+
}
|
|
410
412
|
}
|
|
411
413
|
}
|
|
412
414
|
}
|
|
413
415
|
}
|
|
414
|
-
function loadAndRegisterPlugin(inputOptions, pluginText) {
|
|
416
|
+
async function loadAndRegisterPlugin(inputOptions, pluginText) {
|
|
415
417
|
let plugin = null;
|
|
416
418
|
let pluginArg = undefined;
|
|
417
419
|
if (pluginText[0] === '{') {
|
|
@@ -434,7 +436,7 @@ function loadAndRegisterPlugin(inputOptions, pluginText) {
|
|
|
434
436
|
// Prefix order is significant - left has higher precedence.
|
|
435
437
|
for (const prefix of ['@rollup/plugin-', 'rollup-plugin-']) {
|
|
436
438
|
try {
|
|
437
|
-
plugin =
|
|
439
|
+
plugin = await requireOrImport(prefix + pluginText);
|
|
438
440
|
break;
|
|
439
441
|
}
|
|
440
442
|
catch (_a) {
|
|
@@ -446,7 +448,7 @@ function loadAndRegisterPlugin(inputOptions, pluginText) {
|
|
|
446
448
|
try {
|
|
447
449
|
if (pluginText[0] == '.')
|
|
448
450
|
pluginText = path__namespace.resolve(pluginText);
|
|
449
|
-
plugin =
|
|
451
|
+
plugin = await requireOrImport(pluginText);
|
|
450
452
|
}
|
|
451
453
|
catch (err) {
|
|
452
454
|
throw new Error(`Cannot load plugin "${pluginText}": ${err.message}.`);
|
|
@@ -473,6 +475,14 @@ function getCamelizedPluginBaseName(pluginText) {
|
|
|
473
475
|
.map((part, index) => (index === 0 || !part ? part : part[0].toUpperCase() + part.slice(1)))
|
|
474
476
|
.join('');
|
|
475
477
|
}
|
|
478
|
+
async function requireOrImport(pluginPath) {
|
|
479
|
+
try {
|
|
480
|
+
return require(pluginPath);
|
|
481
|
+
}
|
|
482
|
+
catch (_a) {
|
|
483
|
+
return import(pluginPath);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
476
486
|
|
|
477
487
|
function supportsNativeESM() {
|
|
478
488
|
return Number(/^v(\d+)/.exec(process.version)[1]) >= 13;
|
|
@@ -481,11 +491,12 @@ async function loadAndParseConfigFile(fileName, commandOptions = {}) {
|
|
|
481
491
|
const configs = await loadConfigFile(fileName, commandOptions);
|
|
482
492
|
const warnings = batchWarnings();
|
|
483
493
|
try {
|
|
484
|
-
const normalizedConfigs =
|
|
494
|
+
const normalizedConfigs = [];
|
|
495
|
+
for (const config of configs) {
|
|
485
496
|
const options = mergeOptions.mergeOptions(config, commandOptions, warnings.add);
|
|
486
|
-
addCommandPluginsToInputOptions(options, commandOptions);
|
|
487
|
-
|
|
488
|
-
}
|
|
497
|
+
await addCommandPluginsToInputOptions(options, commandOptions);
|
|
498
|
+
normalizedConfigs.push(options);
|
|
499
|
+
}
|
|
489
500
|
return { options: normalizedConfigs, warnings };
|
|
490
501
|
}
|
|
491
502
|
catch (err) {
|
|
@@ -515,7 +526,7 @@ async function getDefaultFromTranspiledConfigFile(fileName, commandOptions) {
|
|
|
515
526
|
plugins: [],
|
|
516
527
|
treeshake: false
|
|
517
528
|
};
|
|
518
|
-
addPluginsFromCommandOption(commandOptions.configPlugin, inputOptions);
|
|
529
|
+
await addPluginsFromCommandOption(commandOptions.configPlugin, inputOptions);
|
|
519
530
|
const bundle = await rollup.rollup(inputOptions);
|
|
520
531
|
if (!commandOptions.silent && warnings.count > 0) {
|
|
521
532
|
stderr(bold(`loaded ${rollup.relativeId(fileName)} with warnings`));
|
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.60.0
|
|
4
|
+
Fri, 12 Nov 2021 05:12:41 GMT - commit 8d98341bf746d4baa57bbd730b1fa6449555cfca
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -26,7 +26,7 @@ function _interopNamespaceDefault(e) {
|
|
|
26
26
|
return n;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
var version$1 = "2.
|
|
29
|
+
var version$1 = "2.60.0";
|
|
30
30
|
|
|
31
31
|
function ensureArray$1(items) {
|
|
32
32
|
if (Array.isArray(items)) {
|
|
@@ -12358,7 +12358,7 @@ class Module {
|
|
|
12358
12358
|
return Array.from(module.implicitlyLoadedBefore, getId);
|
|
12359
12359
|
},
|
|
12360
12360
|
get importedIds() {
|
|
12361
|
-
return Array.from(module.sources, source => module.resolvedIds[source].id);
|
|
12361
|
+
return Array.from(module.sources, source => { var _a; return (_a = module.resolvedIds[source]) === null || _a === void 0 ? void 0 : _a.id; }).filter(Boolean);
|
|
12362
12362
|
},
|
|
12363
12363
|
get importers() {
|
|
12364
12364
|
return module.importers.sort();
|
|
@@ -22021,6 +22021,7 @@ class ModuleLoader {
|
|
|
22021
22021
|
this.implicitEntryModules = new Set();
|
|
22022
22022
|
this.indexedEntryModules = [];
|
|
22023
22023
|
this.latestLoadModulesPromise = Promise.resolve();
|
|
22024
|
+
this.moduleLoadPromises = new Map();
|
|
22024
22025
|
this.nextEntryModuleIndex = 0;
|
|
22025
22026
|
this.readQueue = new Queue();
|
|
22026
22027
|
this.resolveId = async (source, importer, customOptions, isEntry, skip = null) => {
|
|
@@ -22082,6 +22083,9 @@ class ModuleLoader {
|
|
|
22082
22083
|
}
|
|
22083
22084
|
return module;
|
|
22084
22085
|
}
|
|
22086
|
+
preloadModule(resolvedId) {
|
|
22087
|
+
return this.fetchModule(this.addDefaultsToResolvedId(resolvedId), undefined, false, true).then(module => module.info);
|
|
22088
|
+
}
|
|
22085
22089
|
addDefaultsToResolvedId(resolvedId) {
|
|
22086
22090
|
var _a, _b;
|
|
22087
22091
|
if (!resolvedId) {
|
|
@@ -22182,39 +22186,45 @@ class ModuleLoader {
|
|
|
22182
22186
|
}
|
|
22183
22187
|
}
|
|
22184
22188
|
}
|
|
22185
|
-
|
|
22189
|
+
// If this is a preload, then this method always waits for the dependencies of the module to be resolved.
|
|
22190
|
+
// Otherwise if the module does not exist, it waits for the module and all its dependencies to be loaded.
|
|
22191
|
+
// Otherwise it returns immediately.
|
|
22192
|
+
async fetchModule({ id, meta, moduleSideEffects, syntheticNamedExports }, importer, isEntry, isPreload) {
|
|
22186
22193
|
const existingModule = this.modulesById.get(id);
|
|
22187
22194
|
if (existingModule instanceof Module) {
|
|
22188
|
-
|
|
22189
|
-
existingModule.info.isEntry = true;
|
|
22190
|
-
this.implicitEntryModules.delete(existingModule);
|
|
22191
|
-
for (const dependant of existingModule.implicitlyLoadedAfter) {
|
|
22192
|
-
dependant.implicitlyLoadedBefore.delete(existingModule);
|
|
22193
|
-
}
|
|
22194
|
-
existingModule.implicitlyLoadedAfter.clear();
|
|
22195
|
-
}
|
|
22195
|
+
await this.handleExistingModule(existingModule, isEntry, isPreload);
|
|
22196
22196
|
return existingModule;
|
|
22197
22197
|
}
|
|
22198
22198
|
const module = new Module(this.graph, id, this.options, isEntry, moduleSideEffects, syntheticNamedExports, meta);
|
|
22199
22199
|
this.modulesById.set(id, module);
|
|
22200
22200
|
this.graph.watchFiles[id] = true;
|
|
22201
|
-
|
|
22202
|
-
|
|
22203
|
-
|
|
22204
|
-
|
|
22205
|
-
|
|
22206
|
-
...resolveDynamicImportPromises
|
|
22207
|
-
|
|
22208
|
-
|
|
22209
|
-
|
|
22210
|
-
/* rejections thrown here are also handled within PluginDriver - they are safe to ignore */
|
|
22201
|
+
const loadPromise = this.addModuleSource(id, importer, module).then(() => [
|
|
22202
|
+
this.getResolveStaticDependencyPromises(module),
|
|
22203
|
+
this.getResolveDynamicImportPromises(module)
|
|
22204
|
+
]);
|
|
22205
|
+
const loadAndResolveDependenciesPromise = loadPromise
|
|
22206
|
+
.then(([resolveStaticDependencyPromises, resolveDynamicImportPromises]) => Promise.all([...resolveStaticDependencyPromises, ...resolveDynamicImportPromises]))
|
|
22207
|
+
.then(() => this.pluginDriver.hookParallel('moduleParsed', [module.info]));
|
|
22208
|
+
loadAndResolveDependenciesPromise.catch(() => {
|
|
22209
|
+
/* avoid unhandled promise rejections */
|
|
22211
22210
|
});
|
|
22211
|
+
if (isPreload) {
|
|
22212
|
+
this.moduleLoadPromises.set(module, loadPromise);
|
|
22213
|
+
await loadPromise;
|
|
22214
|
+
}
|
|
22215
|
+
else {
|
|
22216
|
+
await this.fetchModuleDependencies(module, ...(await loadPromise));
|
|
22217
|
+
// To handle errors when resolving dependencies or in moduleParsed
|
|
22218
|
+
await loadAndResolveDependenciesPromise;
|
|
22219
|
+
}
|
|
22220
|
+
return module;
|
|
22221
|
+
}
|
|
22222
|
+
async fetchModuleDependencies(module, resolveStaticDependencyPromises, resolveDynamicDependencyPromises) {
|
|
22212
22223
|
await Promise.all([
|
|
22213
22224
|
this.fetchStaticDependencies(module, resolveStaticDependencyPromises),
|
|
22214
|
-
this.fetchDynamicDependencies(module,
|
|
22225
|
+
this.fetchDynamicDependencies(module, resolveDynamicDependencyPromises)
|
|
22215
22226
|
]);
|
|
22216
22227
|
module.linkImports();
|
|
22217
|
-
return module;
|
|
22218
22228
|
}
|
|
22219
22229
|
fetchResolvedDependency(source, importer, resolvedId) {
|
|
22220
22230
|
if (resolvedId.external) {
|
|
@@ -22229,7 +22239,7 @@ class ModuleLoader {
|
|
|
22229
22239
|
return Promise.resolve(externalModule);
|
|
22230
22240
|
}
|
|
22231
22241
|
else {
|
|
22232
|
-
return this.fetchModule(resolvedId, importer, false);
|
|
22242
|
+
return this.fetchModule(resolvedId, importer, false, false);
|
|
22233
22243
|
}
|
|
22234
22244
|
}
|
|
22235
22245
|
async fetchStaticDependencies(module, resolveStaticDependencyPromises) {
|
|
@@ -22300,6 +22310,26 @@ class ModuleLoader {
|
|
|
22300
22310
|
this.handleResolveId(await this.resolveId(source, module.id, EMPTY_OBJECT, false), source, module.id))
|
|
22301
22311
|
]);
|
|
22302
22312
|
}
|
|
22313
|
+
async handleExistingModule(module, isEntry, isPreload) {
|
|
22314
|
+
const loadPromise = this.moduleLoadPromises.get(module);
|
|
22315
|
+
if (isPreload) {
|
|
22316
|
+
await loadPromise;
|
|
22317
|
+
return;
|
|
22318
|
+
}
|
|
22319
|
+
if (isEntry) {
|
|
22320
|
+
module.info.isEntry = true;
|
|
22321
|
+
this.implicitEntryModules.delete(module);
|
|
22322
|
+
for (const dependant of module.implicitlyLoadedAfter) {
|
|
22323
|
+
dependant.implicitlyLoadedBefore.delete(module);
|
|
22324
|
+
}
|
|
22325
|
+
module.implicitlyLoadedAfter.clear();
|
|
22326
|
+
}
|
|
22327
|
+
if (loadPromise) {
|
|
22328
|
+
this.moduleLoadPromises.delete(module);
|
|
22329
|
+
await this.fetchModuleDependencies(module, ...(await loadPromise));
|
|
22330
|
+
}
|
|
22331
|
+
return;
|
|
22332
|
+
}
|
|
22303
22333
|
handleResolveId(resolvedId, source, importer) {
|
|
22304
22334
|
if (resolvedId === null) {
|
|
22305
22335
|
if (isRelative(source)) {
|
|
@@ -22336,7 +22366,7 @@ class ModuleLoader {
|
|
|
22336
22366
|
}
|
|
22337
22367
|
return this.fetchModule(this.addDefaultsToResolvedId(typeof resolveIdResult === 'object'
|
|
22338
22368
|
? resolveIdResult
|
|
22339
|
-
: { id: resolveIdResult }), undefined, isEntry);
|
|
22369
|
+
: { id: resolveIdResult }), undefined, isEntry, false);
|
|
22340
22370
|
}
|
|
22341
22371
|
async resolveDynamicImport(module, specifier, importer) {
|
|
22342
22372
|
const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
|
|
@@ -22464,12 +22494,16 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22464
22494
|
getModuleInfo: graph.getModuleInfo,
|
|
22465
22495
|
getWatchFiles: () => Object.keys(graph.watchFiles),
|
|
22466
22496
|
isExternal: getDeprecatedContextHandler((id, parentId, isResolved = false) => options.external(id, parentId, isResolved), 'isExternal', 'resolve', plugin.name, true, options),
|
|
22497
|
+
load(resolvedId) {
|
|
22498
|
+
return graph.moduleLoader.preloadModule(resolvedId);
|
|
22499
|
+
},
|
|
22467
22500
|
meta: {
|
|
22468
22501
|
rollupVersion: version$1,
|
|
22469
22502
|
watchMode: graph.watchMode
|
|
22470
22503
|
},
|
|
22471
22504
|
get moduleIds() {
|
|
22472
22505
|
function* wrappedModuleIds() {
|
|
22506
|
+
// We are wrapping this in a generator to only show the message once we are actually iterating
|
|
22473
22507
|
warnDeprecation({
|
|
22474
22508
|
message: `Accessing "this.moduleIds" on the plugin context by plugin ${plugin.name} is deprecated. The "this.getModuleIds" plugin context function should be used instead.`,
|
|
22475
22509
|
plugin: plugin.name
|
|
@@ -23090,12 +23124,15 @@ const getHasModuleSideEffects = (moduleSideEffectsOption, pureExternalModules) =
|
|
|
23090
23124
|
return (id, external) => !(external && isPureExternalModule(id));
|
|
23091
23125
|
};
|
|
23092
23126
|
|
|
23127
|
+
// https://datatracker.ietf.org/doc/html/rfc2396
|
|
23128
|
+
// eslint-disable-next-line no-control-regex
|
|
23129
|
+
const INVALID_CHAR_RE = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g;
|
|
23093
23130
|
function sanitizeFileName(name) {
|
|
23094
23131
|
const match = /^[a-z]:/i.exec(name);
|
|
23095
23132
|
const driveLetter = match ? match[0] : '';
|
|
23096
23133
|
// A `:` is only allowed as part of a windows drive letter (ex: C:\foo)
|
|
23097
23134
|
// Otherwise, avoid them because they can refer to NTFS alternate data streams.
|
|
23098
|
-
return driveLetter + name.substr(driveLetter.length).replace(
|
|
23135
|
+
return driveLetter + name.substr(driveLetter.length).replace(INVALID_CHAR_RE, '_');
|
|
23099
23136
|
}
|
|
23100
23137
|
|
|
23101
23138
|
function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED