rollup 4.63.4 → 4.63.5
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/dist/bin/rollup +3 -3
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +46 -17
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +99 -47
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.d.ts +5 -7
- package/dist/rollup.js +9 -107
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/node-entry.js +147 -0
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +15 -13
- package/dist/shared/watch-cli.js +17 -8
- package/dist/shared/watch.js +99 -46
- package/package.json +26 -26
package/dist/bin/rollup
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*
|
|
3
3
|
@license
|
|
4
|
-
Rollup.js v4.63.
|
|
5
|
-
|
|
4
|
+
Rollup.js v4.63.5
|
|
5
|
+
Thu, 24 Sep 2026 10:07:23 GMT - commit 3722484c33c58b3ab0cbbfcca09b8f267d420329
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
8
8
|
|
|
@@ -27,7 +27,7 @@ require('node:perf_hooks');
|
|
|
27
27
|
require('node:url');
|
|
28
28
|
require('../getLogFilter.js');
|
|
29
29
|
|
|
30
|
-
const help = "rollup version 4.63.
|
|
30
|
+
const help = "rollup version 4.63.5\n=====================================\n\nUsage: rollup [options] <entry file>\n\nOptions:\n\n-c, --config <filename> Use this config file (if argument is used but value\n is unspecified, Rollup will try to load configuration files in\n the following order:\n rollup.config.mjs -> rollup.config.cjs -> rollup.config.js)\n-d, --dir <dirname> Directory for chunks (if absent, prints to stdout)\n-e, --external <ids> Comma-separate list of module IDs to exclude\n-f, --format <format> Type of output (amd, cjs, es, iife, umd, system)\n-g, --globals <pairs> Comma-separate list of `moduleID:Global` pairs\n-h, --help Show this help message\n-i, --input <filename> Input (alternative to <entry file>)\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n-n, --name <name> Name for UMD export\n-o, --file <output> Single output file (if absent, prints to stdout)\n-p, --plugin <plugin> Use the plugin specified (may be repeated)\n-v, --version Show version number\n-w, --watch Watch files in bundle and rebuild on changes\n--amd.autoId Generate the AMD ID based off the chunk name\n--amd.basePath <prefix> Path to prepend to auto generated AMD ID\n--amd.define <name> Function to use in place of `define`\n--amd.forceJsExtensionForImports Use `.js` extension in AMD imports\n--amd.id <id> ID for AMD module (default is anonymous)\n--assetFileNames <pattern> Name pattern for emitted assets\n--banner <text> Code to insert at top of bundle (outside wrapper)\n--chunkFileNames <pattern> Name pattern for emitted secondary chunks\n--compact Minify wrapper code\n--context <variable> Specify top-level `this` value\n--no-dynamicImportInCjs Write external dynamic CommonJS imports as require\n--entryFileNames <pattern> Name pattern for emitted entry chunks\n--environment <values> Settings passed to config file (see example)\n--no-esModule Do not add __esModule property\n--exports <mode> Specify export mode (auto, default, named, none)\n--extend Extend global variable defined by --name\n--no-externalImportAttributes Omit import attributes in \"es\" output\n--no-externalLiveBindings Do not generate code to support live bindings\n--failAfterWarnings Exit with an error if the build produced warnings\n--filterLogs <filter> Filter log messages\n--footer <text> Code to insert at end of bundle (outside wrapper)\n--forceExit Force exit the process when done\n--no-freeze Do not freeze namespace objects\n--generatedCode <preset> Which code features to use (es5/es2015)\n--generatedCode.arrowFunctions Use arrow functions in generated code\n--generatedCode.constBindings Use \"const\" in generated code\n--generatedCode.objectShorthand Use shorthand properties in generated code\n--no-generatedCode.reservedNamesAsProps Always quote reserved names as props\n--generatedCode.symbols Use symbols in generated code\n--hashCharacters <name> Use the specified character set for file hashes\n--no-hoistTransitiveImports Do not hoist transitive imports into entry chunks\n--importAttributesKey <name> Use the specified keyword for import attributes\n--no-indent Don't indent result\n--inlineDynamicImports Create single bundle when using dynamic imports\n--no-interop Do not include interop block\n--intro <text> Code to insert at top of bundle (inside wrapper)\n--logLevel <level> Which kind of logs to display\n--no-makeAbsoluteExternalsRelative Prevent normalization of external imports\n--maxParallelFileOps <value> How many files to read in parallel\n--minifyInternalExports Force or disable minification of internal exports\n--noConflict Generate a noConflict method for UMD globals\n--outro <text> Code to insert at end of bundle (inside wrapper)\n--perf Display performance timings\n--no-preserveEntrySignatures Avoid facade chunks for entry points\n--preserveModules Preserve module structure\n--preserveModulesRoot Put preserved modules under this path at root level\n--preserveSymlinks Do not follow symlinks when resolving files\n--no-reexportProtoFromExternal Ignore `__proto__` in star re-exports\n--no-sanitizeFileName Do not replace invalid characters in file names\n--shimMissingExports Create shim variables for missing exports\n--silent Don't print warnings\n--sourcemapBaseUrl <url> Emit absolute sourcemap URLs with given base\n--sourcemapDebugIds Emit unique debug ids in source and sourcemaps\n--sourcemapExcludeSources Do not include source code in source maps\n--sourcemapFile <file> Specify bundle position for source maps\n--sourcemapFileNames <pattern> Name pattern for emitted sourcemaps\n--stdin=ext Specify file extension used for stdin input\n--no-stdin Do not read \"-\" from stdin\n--no-strict Don't emit `\"use strict\";` in the generated modules\n--strictDeprecations Throw errors for deprecated features\n--no-systemNullSetters Do not replace empty SystemJS setters with `null`\n--no-treeshake Disable tree-shaking optimisations\n--no-treeshake.annotations Ignore pure call annotations\n--treeshake.correctVarValueBeforeDeclaration Deoptimize variables until declared\n--treeshake.manualPureFunctions <names> Manually declare functions as pure\n--no-treeshake.moduleSideEffects Assume modules have no side effects\n--no-treeshake.propertyReadSideEffects Ignore property access side effects\n--no-treeshake.tryCatchDeoptimization Do not turn off try-catch-tree-shaking\n--no-treeshake.unknownGlobalSideEffects Assume unknown globals do not throw\n--validate Validate output\n--waitForBundleInput Wait for bundle input files\n--watch.allowInputInsideOutputPath Whether the input path is allowed to be a\n subpath of the output path\n--watch.buildDelay <number> Throttle watch rebuilds\n--no-watch.clearScreen Do not clear the screen when rebuilding\n--watch.exclude <files> Exclude files from being watched\n--watch.include <files> Limit watching to specified files\n--watch.onBundleEnd <cmd> Shell command to run on `\"BUNDLE_END\"` event\n--watch.onBundleStart <cmd> Shell command to run on `\"BUNDLE_START\"` event\n--watch.onEnd <cmd> Shell command to run on `\"END\"` event\n--watch.onError <cmd> Shell command to run on `\"ERROR\"` event\n--watch.onStart <cmd> Shell command to run on `\"START\"` event\n--watch.skipWrite Do not write files to disk when watching\n\nExamples:\n\n# use settings in config file\nrollup -c\n\n# in config file, process.env.INCLUDE_DEPS === 'true'\n# and process.env.BUILD === 'production'\nrollup -c --environment INCLUDE_DEPS,BUILD:production\n\n# create CommonJS bundle.js from src/main.js\nrollup --format=cjs --file=bundle.js -- src/main.js\n\n# create self-executing IIFE using `window.jQuery`\n# and `window._` as external globals\nrollup -f iife --globals jquery:jQuery,lodash:_ \\\n -i src/app.js -o build/app.js -m build/app.js.map\n\nNotes:\n\n* When piping to stdout, only inline sourcemaps are permitted\n\nFor more information visit https://rollupjs.org\n";
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* @license
|
package/dist/es/getLogFilter.js
CHANGED
package/dist/es/parseAst.js
CHANGED
package/dist/es/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.63.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.63.5
|
|
4
|
+
Thu, 24 Sep 2026 10:07:23 GMT - commit 3722484c33c58b3ab0cbbfcca09b8f267d420329
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -27,7 +27,7 @@ function _mergeNamespaces(n, m) {
|
|
|
27
27
|
return Object.defineProperty(n, Symbol.toStringTag, { value: 'Module' });
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var version = "4.63.
|
|
30
|
+
var version = "4.63.5";
|
|
31
31
|
const pkg = {
|
|
32
32
|
version: version};
|
|
33
33
|
|
|
@@ -8685,6 +8685,8 @@ const builtinModules = [
|
|
|
8685
8685
|
"assert/strict",
|
|
8686
8686
|
"node:async_hooks",
|
|
8687
8687
|
"async_hooks",
|
|
8688
|
+
"node:bench",
|
|
8689
|
+
"node:bench/reporters",
|
|
8688
8690
|
"node:buffer",
|
|
8689
8691
|
"buffer",
|
|
8690
8692
|
"node:child_process",
|
|
@@ -20147,7 +20149,7 @@ function* concatLazy(iterables) {
|
|
|
20147
20149
|
* per dynamic entry to marks all dynamic entry dependencies as "dirty" and put
|
|
20148
20150
|
* them back into the iteration. As an additional optimization, we note for
|
|
20149
20151
|
* each dynamic entry which dynamic dependent entries have changed and only
|
|
20150
|
-
* intersect those entries again on subsequent
|
|
20152
|
+
* intersect those entries again on subsequent iterations.
|
|
20151
20153
|
*
|
|
20152
20154
|
* Then we remove the dynamic entries from the list of dependent entries for
|
|
20153
20155
|
* those chunks that are already loaded for that dynamic entry and create
|
|
@@ -23453,7 +23455,7 @@ function normalizeEntryModules(entryModules) {
|
|
|
23453
23455
|
}));
|
|
23454
23456
|
}
|
|
23455
23457
|
class Graph {
|
|
23456
|
-
constructor(options,
|
|
23458
|
+
constructor(options, registerWatchHooks) {
|
|
23457
23459
|
this.options = options;
|
|
23458
23460
|
this.astLru = flru(5);
|
|
23459
23461
|
this.cachedModules = new Map();
|
|
@@ -23488,12 +23490,12 @@ class Graph {
|
|
|
23488
23490
|
value[0]++;
|
|
23489
23491
|
}
|
|
23490
23492
|
}
|
|
23491
|
-
if (
|
|
23493
|
+
if (registerWatchHooks) {
|
|
23492
23494
|
this.watchMode = true;
|
|
23493
|
-
|
|
23494
|
-
|
|
23495
|
-
|
|
23496
|
-
|
|
23495
|
+
registerWatchHooks({
|
|
23496
|
+
closeWatcher: () => this.pluginDriver.hookParallel('closeWatcher', []),
|
|
23497
|
+
watchChange: (...parameters) => this.pluginDriver.hookParallel('watchChange', parameters)
|
|
23498
|
+
});
|
|
23497
23499
|
}
|
|
23498
23500
|
this.pluginDriver = new PluginDriver(this, options, options.plugins, this.pluginCache);
|
|
23499
23501
|
this.moduleLoader = new ModuleLoader(this, this.modulesById, this.options, this.pluginDriver);
|
|
@@ -24182,11 +24184,11 @@ Symbol.asyncDispose ??= Symbol('Symbol.asyncDispose');
|
|
|
24182
24184
|
function rollup(rawInputOptions) {
|
|
24183
24185
|
return rollupInternal(rawInputOptions, null);
|
|
24184
24186
|
}
|
|
24185
|
-
async function rollupInternal(rawInputOptions,
|
|
24186
|
-
const { options: inputOptions, unsetOptions: unsetInputOptions } = await getInputOptions(rawInputOptions,
|
|
24187
|
+
async function rollupInternal(rawInputOptions, registerWatchHooks) {
|
|
24188
|
+
const { options: inputOptions, unsetOptions: unsetInputOptions } = await getInputOptions(rawInputOptions, registerWatchHooks !== null);
|
|
24187
24189
|
initialiseTimers(inputOptions);
|
|
24188
24190
|
await initWasm();
|
|
24189
|
-
const graph = new Graph(inputOptions,
|
|
24191
|
+
const graph = new Graph(inputOptions, registerWatchHooks);
|
|
24190
24192
|
// remove the cache object from the memory after graph creation (cache is not used anymore)
|
|
24191
24193
|
const useCache = rawInputOptions.cache !== false;
|
|
24192
24194
|
if (rawInputOptions.cache) {
|
|
@@ -24712,6 +24714,15 @@ const fseventsImporter = /*#__PURE__*/Object.defineProperty({
|
|
|
24712
24714
|
loadFsEvents
|
|
24713
24715
|
}, Symbol.toStringTag, { value: 'Module' });
|
|
24714
24716
|
|
|
24717
|
+
function waitForAllAndRethrowFirstFailure(promises) {
|
|
24718
|
+
return Promise.allSettled(promises).then(results => {
|
|
24719
|
+
for (const result of results) {
|
|
24720
|
+
if (result.status === 'rejected') {
|
|
24721
|
+
throw result.reason;
|
|
24722
|
+
}
|
|
24723
|
+
}
|
|
24724
|
+
});
|
|
24725
|
+
}
|
|
24715
24726
|
class WatchEmitter {
|
|
24716
24727
|
constructor() {
|
|
24717
24728
|
this.currentHandlers = Object.create(null);
|
|
@@ -24720,7 +24731,8 @@ class WatchEmitter {
|
|
|
24720
24731
|
// Will be overwritten by Rollup
|
|
24721
24732
|
async close() { }
|
|
24722
24733
|
emit(event, ...parameters) {
|
|
24723
|
-
|
|
24734
|
+
// The async wrapper turns a synchronous throw into a rejection so that no sibling listener is skipped.
|
|
24735
|
+
return waitForAllAndRethrowFirstFailure([...this.getCurrentHandlers(event), ...this.getPersistentHandlers(event)].map(async (handler) => handler(...parameters)));
|
|
24724
24736
|
}
|
|
24725
24737
|
off(event, listener) {
|
|
24726
24738
|
const listeners = this.persistentHandlers[event];
|
|
@@ -24767,7 +24779,21 @@ class WatchEmitter {
|
|
|
24767
24779
|
|
|
24768
24780
|
function watch(configs) {
|
|
24769
24781
|
const emitter = new WatchEmitter();
|
|
24770
|
-
|
|
24782
|
+
let isClosed = false;
|
|
24783
|
+
// Until the watcher takes over closing, a close prevents its construction
|
|
24784
|
+
// and emits close itself, as no watcher will.
|
|
24785
|
+
emitter.close = async () => {
|
|
24786
|
+
if (isClosed)
|
|
24787
|
+
return;
|
|
24788
|
+
isClosed = true;
|
|
24789
|
+
try {
|
|
24790
|
+
await emitter.emit('close');
|
|
24791
|
+
}
|
|
24792
|
+
finally {
|
|
24793
|
+
emitter.removeAllListeners();
|
|
24794
|
+
}
|
|
24795
|
+
};
|
|
24796
|
+
watchInternal(configs, emitter, () => isClosed).catch(error => {
|
|
24771
24797
|
handleError(error);
|
|
24772
24798
|
});
|
|
24773
24799
|
return emitter;
|
|
@@ -24799,7 +24825,7 @@ function checkWatchConfig(config) {
|
|
|
24799
24825
|
}
|
|
24800
24826
|
}
|
|
24801
24827
|
}
|
|
24802
|
-
async function watchInternal(configs, emitter) {
|
|
24828
|
+
async function watchInternal(configs, emitter, wasClosed) {
|
|
24803
24829
|
const optionsList = await Promise.all(ensureArray(configs).map(config => mergeOptions(config, true)));
|
|
24804
24830
|
const watchOptionsList = optionsList.filter(config => config.watch !== false);
|
|
24805
24831
|
if (watchOptionsList.length === 0) {
|
|
@@ -24808,9 +24834,12 @@ async function watchInternal(configs, emitter) {
|
|
|
24808
24834
|
checkWatchConfig(watchOptionsList);
|
|
24809
24835
|
await loadFsEvents();
|
|
24810
24836
|
const { Watcher } = await import('./watch.js');
|
|
24837
|
+
if (wasClosed()) {
|
|
24838
|
+
return;
|
|
24839
|
+
}
|
|
24811
24840
|
new Watcher(watchOptionsList, emitter);
|
|
24812
24841
|
}
|
|
24813
24842
|
|
|
24814
24843
|
const VERSION = pkg.version;
|
|
24815
24844
|
|
|
24816
|
-
export { VERSION, createFilter$1 as createFilter, defineConfig, fseventsImporter, getAugmentedNamespace, getDefaultExportFromCjs, rollup, rollupInternal, watch };
|
|
24845
|
+
export { VERSION, createFilter$1 as createFilter, defineConfig, fseventsImporter, getAugmentedNamespace, getDefaultExportFromCjs, rollup, rollupInternal, waitForAllAndRethrowFirstFailure, watch };
|
package/dist/es/shared/watch.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.63.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.63.5
|
|
4
|
+
Thu, 24 Sep 2026 10:07:23 GMT - commit 3722484c33c58b3ab0cbbfcca09b8f267d420329
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
|
-
import { getAugmentedNamespace, fseventsImporter, getDefaultExportFromCjs, createFilter, rollupInternal } from './node-entry.js';
|
|
10
|
+
import { getAugmentedNamespace, fseventsImporter, getDefaultExportFromCjs, waitForAllAndRethrowFirstFailure, createFilter, rollupInternal } from './node-entry.js';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import process$1 from 'node:process';
|
|
13
13
|
import require$$0$1 from 'path';
|
|
@@ -9690,11 +9690,12 @@ const eventsRewrites = {
|
|
|
9690
9690
|
};
|
|
9691
9691
|
class Watcher {
|
|
9692
9692
|
constructor(optionsList, emitter) {
|
|
9693
|
+
this.closed = false;
|
|
9693
9694
|
this.buildDelay = 0;
|
|
9694
9695
|
this.buildTimeout = null;
|
|
9695
|
-
this.closed = false;
|
|
9696
9696
|
this.invalidatedIds = new Map();
|
|
9697
9697
|
this.rerun = false;
|
|
9698
|
+
// Starts held so that invalidations before the initial run only request a rerun.
|
|
9698
9699
|
this.running = true;
|
|
9699
9700
|
this.emitter = emitter;
|
|
9700
9701
|
emitter.close = this.close.bind(this);
|
|
@@ -9704,7 +9705,7 @@ class Watcher {
|
|
|
9704
9705
|
this.buildDelay = Math.max(this.buildDelay, watch.buildDelay);
|
|
9705
9706
|
}
|
|
9706
9707
|
}
|
|
9707
|
-
process$1.nextTick(() => this.
|
|
9708
|
+
process$1.nextTick(() => this.runExclusively(() => this.run()));
|
|
9708
9709
|
}
|
|
9709
9710
|
async close() {
|
|
9710
9711
|
if (this.closed)
|
|
@@ -9712,13 +9713,19 @@ class Watcher {
|
|
|
9712
9713
|
this.closed = true;
|
|
9713
9714
|
if (this.buildTimeout)
|
|
9714
9715
|
clearTimeout(this.buildTimeout);
|
|
9715
|
-
|
|
9716
|
-
|
|
9716
|
+
try {
|
|
9717
|
+
await waitForAllAndRethrowFirstFailure([
|
|
9718
|
+
...this.tasks.map(task => task.close()),
|
|
9719
|
+
this.emitter.emit('close')
|
|
9720
|
+
]);
|
|
9721
|
+
}
|
|
9722
|
+
finally {
|
|
9723
|
+
this.emitter.removeAllListeners();
|
|
9717
9724
|
}
|
|
9718
|
-
await this.emitter.emit('close');
|
|
9719
|
-
this.emitter.removeAllListeners();
|
|
9720
9725
|
}
|
|
9721
9726
|
invalidate(file) {
|
|
9727
|
+
if (this.closed)
|
|
9728
|
+
return;
|
|
9722
9729
|
if (file) {
|
|
9723
9730
|
const previousEvent = this.invalidatedIds.get(file.id);
|
|
9724
9731
|
const event = previousEvent ? eventsRewrites[previousEvent][file.event] : file.event;
|
|
@@ -9739,22 +9746,64 @@ class Watcher {
|
|
|
9739
9746
|
}
|
|
9740
9747
|
if (this.buildTimeout)
|
|
9741
9748
|
clearTimeout(this.buildTimeout);
|
|
9742
|
-
this.buildTimeout = setTimeout(
|
|
9749
|
+
this.buildTimeout = setTimeout(() => {
|
|
9743
9750
|
this.buildTimeout = null;
|
|
9744
|
-
|
|
9745
|
-
await Promise.all([...this.invalidatedIds].map(([id, event]) => this.emitter.emit('change', id, { event })));
|
|
9746
|
-
this.invalidatedIds.clear();
|
|
9747
|
-
await this.emitter.emit('restart');
|
|
9748
|
-
this.emitter.removeListenersForCurrentRun();
|
|
9749
|
-
await this.run();
|
|
9750
|
-
}
|
|
9751
|
-
catch (error) {
|
|
9752
|
-
await this.reportError(error);
|
|
9753
|
-
}
|
|
9751
|
+
this.runExclusively(() => this.announceChangesAndRebuild());
|
|
9754
9752
|
}, this.buildDelay);
|
|
9755
9753
|
}
|
|
9756
|
-
async
|
|
9754
|
+
// The running flag spans the whole cycle, including async listeners, so
|
|
9755
|
+
// that invalidations meanwhile only request a rerun.
|
|
9756
|
+
async runExclusively(cycle) {
|
|
9757
|
+
this.running = true;
|
|
9758
|
+
try {
|
|
9759
|
+
await cycle();
|
|
9760
|
+
}
|
|
9761
|
+
catch (error) {
|
|
9762
|
+
await this.reportError(error);
|
|
9763
|
+
}
|
|
9764
|
+
finally {
|
|
9765
|
+
this.running = false;
|
|
9766
|
+
}
|
|
9767
|
+
if (this.rerun) {
|
|
9768
|
+
this.rerun = false;
|
|
9769
|
+
this.invalidate();
|
|
9770
|
+
}
|
|
9771
|
+
}
|
|
9772
|
+
async announceChangesAndRebuild() {
|
|
9773
|
+
await this.announcePendingChanges();
|
|
9774
|
+
if (this.closed || !this.hasInvalidatedTask())
|
|
9775
|
+
return;
|
|
9776
|
+
await this.emitter.emit('restart');
|
|
9777
|
+
await this.announcePendingChanges();
|
|
9778
|
+
if (this.closed)
|
|
9779
|
+
return;
|
|
9780
|
+
this.emitter.removeListenersForCurrentRun();
|
|
9781
|
+
await this.run();
|
|
9782
|
+
}
|
|
9783
|
+
// The upcoming run consumes announced changes via the task flags, making
|
|
9784
|
+
// their rerun requests obsolete. The reset must directly follow the last
|
|
9785
|
+
// emptiness check so that no change slips through unannounced.
|
|
9786
|
+
async announcePendingChanges() {
|
|
9787
|
+
while (this.invalidatedIds.size > 0 && !this.closed) {
|
|
9788
|
+
await this.announceChangeBatch();
|
|
9789
|
+
}
|
|
9790
|
+
this.rerun = false;
|
|
9791
|
+
}
|
|
9792
|
+
// Cleared before emitting so that changes arriving during slow hooks,
|
|
9793
|
+
// including follow-ups of the same file, form the next batch instead of
|
|
9794
|
+
// being dropped with this one.
|
|
9795
|
+
async announceChangeBatch() {
|
|
9796
|
+
const changes = [...this.invalidatedIds];
|
|
9757
9797
|
this.invalidatedIds.clear();
|
|
9798
|
+
await waitForAllAndRethrowFirstFailure(changes.flatMap(([id, event]) => [
|
|
9799
|
+
...this.tasks.map(task => task.announceChange(id, event)),
|
|
9800
|
+
this.emitter.emit('change', id, { event })
|
|
9801
|
+
]));
|
|
9802
|
+
}
|
|
9803
|
+
hasInvalidatedTask() {
|
|
9804
|
+
return this.tasks.some(task => task.isInvalidated());
|
|
9805
|
+
}
|
|
9806
|
+
async reportError(error) {
|
|
9758
9807
|
await this.emitter.emit('event', {
|
|
9759
9808
|
code: 'ERROR',
|
|
9760
9809
|
error,
|
|
@@ -9765,37 +9814,26 @@ class Watcher {
|
|
|
9765
9814
|
});
|
|
9766
9815
|
}
|
|
9767
9816
|
async run() {
|
|
9768
|
-
this.
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
this.
|
|
9772
|
-
|
|
9773
|
-
await this.emitter.emit('event', {
|
|
9774
|
-
code: 'START'
|
|
9775
|
-
});
|
|
9776
|
-
for (const task of this.tasks) {
|
|
9777
|
-
await task.run();
|
|
9778
|
-
}
|
|
9779
|
-
}
|
|
9780
|
-
finally {
|
|
9781
|
-
this.running = false;
|
|
9817
|
+
await this.emitter.emit('event', {
|
|
9818
|
+
code: 'START'
|
|
9819
|
+
});
|
|
9820
|
+
for (const task of this.tasks) {
|
|
9821
|
+
await task.run();
|
|
9782
9822
|
}
|
|
9823
|
+
if (this.closed)
|
|
9824
|
+
return;
|
|
9783
9825
|
await this.emitter.emit('event', {
|
|
9784
9826
|
code: 'END'
|
|
9785
9827
|
});
|
|
9786
|
-
if (this.rerun) {
|
|
9787
|
-
this.rerun = false;
|
|
9788
|
-
this.invalidate();
|
|
9789
|
-
}
|
|
9790
9828
|
}
|
|
9791
9829
|
}
|
|
9792
9830
|
class Task {
|
|
9793
9831
|
constructor(watcher, options) {
|
|
9794
9832
|
this.cache = { modules: [] };
|
|
9795
9833
|
this.watchFiles = [];
|
|
9796
|
-
this.closed = false;
|
|
9797
9834
|
this.invalidated = true;
|
|
9798
9835
|
this.watched = new Set();
|
|
9836
|
+
this.watchHooks = null;
|
|
9799
9837
|
this.watcher = watcher;
|
|
9800
9838
|
this.options = options;
|
|
9801
9839
|
this.skipWrite = Boolean(options.watch && options.watch.skipWrite);
|
|
@@ -9813,9 +9851,14 @@ class Task {
|
|
|
9813
9851
|
ignoreInitial: true
|
|
9814
9852
|
});
|
|
9815
9853
|
}
|
|
9816
|
-
|
|
9817
|
-
this.
|
|
9854
|
+
async announceChange(id, event) {
|
|
9855
|
+
await this.watchHooks?.watchChange(id, { event });
|
|
9856
|
+
}
|
|
9857
|
+
async close() {
|
|
9818
9858
|
this.fileWatcher.close();
|
|
9859
|
+
const watchHooks = this.watchHooks;
|
|
9860
|
+
this.watchHooks = null;
|
|
9861
|
+
await watchHooks?.closeWatcher();
|
|
9819
9862
|
}
|
|
9820
9863
|
invalidate(id, details) {
|
|
9821
9864
|
this.invalidated = true;
|
|
@@ -9830,8 +9873,11 @@ class Task {
|
|
|
9830
9873
|
this.watcher.invalidate({ event: details.event, id });
|
|
9831
9874
|
this.watchOptions.onInvalidate?.(id);
|
|
9832
9875
|
}
|
|
9876
|
+
isInvalidated() {
|
|
9877
|
+
return this.invalidated;
|
|
9878
|
+
}
|
|
9833
9879
|
async run() {
|
|
9834
|
-
if (!this.invalidated)
|
|
9880
|
+
if (!this.invalidated || this.watcher.closed)
|
|
9835
9881
|
return;
|
|
9836
9882
|
this.invalidated = false;
|
|
9837
9883
|
const options = {
|
|
@@ -9844,16 +9890,22 @@ class Task {
|
|
|
9844
9890
|
input: this.options.input,
|
|
9845
9891
|
output: this.outputFiles
|
|
9846
9892
|
});
|
|
9893
|
+
if (this.watcher.closed) {
|
|
9894
|
+
return;
|
|
9895
|
+
}
|
|
9847
9896
|
let result = null;
|
|
9848
9897
|
try {
|
|
9849
|
-
result = await rollupInternal(options,
|
|
9850
|
-
|
|
9898
|
+
result = await rollupInternal(options, watchHooks => {
|
|
9899
|
+
if (!this.watcher.closed)
|
|
9900
|
+
this.watchHooks = watchHooks;
|
|
9901
|
+
});
|
|
9902
|
+
if (this.watcher.closed) {
|
|
9851
9903
|
return;
|
|
9852
9904
|
}
|
|
9853
9905
|
this.updateWatchedFiles(result);
|
|
9854
9906
|
if (!this.skipWrite) {
|
|
9855
9907
|
await Promise.all(this.outputs.map(output => result.write(output)));
|
|
9856
|
-
if (this.closed) {
|
|
9908
|
+
if (this.watcher.closed) {
|
|
9857
9909
|
return;
|
|
9858
9910
|
}
|
|
9859
9911
|
this.updateWatchedFiles(result);
|
|
@@ -9867,7 +9919,7 @@ class Task {
|
|
|
9867
9919
|
});
|
|
9868
9920
|
}
|
|
9869
9921
|
catch (error) {
|
|
9870
|
-
if (!this.closed) {
|
|
9922
|
+
if (!this.watcher.closed) {
|
|
9871
9923
|
if (Array.isArray(error.watchFiles)) {
|
|
9872
9924
|
for (const id of error.watchFiles) {
|
|
9873
9925
|
this.watchFile(id);
|
package/dist/getLogFilter.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/parseAst.js
CHANGED
package/dist/rollup.d.ts
CHANGED
|
@@ -1081,16 +1081,14 @@ export interface AwaitingEventEmitter<T extends Record<string, (...parameters: a
|
|
|
1081
1081
|
off<K extends keyof T>(event: K, listener: AwaitedEventListener<T, K>): this;
|
|
1082
1082
|
/**
|
|
1083
1083
|
* Registers an event listener that will be awaited before Rollup continues.
|
|
1084
|
-
* All listeners
|
|
1085
|
-
*
|
|
1084
|
+
* All listeners are invoked and awaited in parallel. Rollup waits until all
|
|
1085
|
+
* of them have settled and then throws the first rejection, if any.
|
|
1086
1086
|
*/
|
|
1087
1087
|
on<K extends keyof T>(event: K, listener: AwaitedEventListener<T, K>): this;
|
|
1088
1088
|
/**
|
|
1089
|
-
* Registers an event listener
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
-
* Listeners are removed automatically when removeListenersForCurrentRun is
|
|
1093
|
-
* called, which happens automatically after each run.
|
|
1089
|
+
* Registers an event listener like `on`. Listeners are removed automatically
|
|
1090
|
+
* when removeListenersForCurrentRun is called, which happens right before each
|
|
1091
|
+
* rebuild, after the changes that triggered it were announced.
|
|
1094
1092
|
*/
|
|
1095
1093
|
onCurrentRun<K extends keyof T>(
|
|
1096
1094
|
event: K,
|