rollup 2.69.1 → 2.70.1
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 +44 -0
- package/dist/bin/rollup +2 -3
- package/dist/es/rollup.browser.js +3 -4
- package/dist/es/rollup.js +2 -3
- package/dist/es/shared/rollup.js +132 -95
- package/dist/es/shared/watch.js +22 -11
- package/dist/loadConfigFile.js +2 -3
- package/dist/rollup.browser.js +3 -4
- package/dist/rollup.browser.js.map +1 -1
- package/dist/rollup.d.ts +33 -16
- package/dist/rollup.js +2 -3
- package/dist/shared/index.js +2 -3
- package/dist/shared/loadConfigFile.js +2 -3
- package/dist/shared/mergeOptions.js +2 -3
- package/dist/shared/rollup.js +124 -87
- package/dist/shared/watch-cli.js +5 -6
- package/dist/shared/watch.js +22 -11
- package/package.json +5 -7
package/dist/rollup.d.ts
CHANGED
|
@@ -344,7 +344,7 @@ export type WatchChangeHook = (
|
|
|
344
344
|
this: PluginContext,
|
|
345
345
|
id: string,
|
|
346
346
|
change: { event: ChangeEvent }
|
|
347
|
-
) => void;
|
|
347
|
+
) => Promise<void> | void;
|
|
348
348
|
|
|
349
349
|
/**
|
|
350
350
|
* use this type for plugin annotation
|
|
@@ -375,7 +375,7 @@ export interface PluginHooks extends OutputPluginHooks {
|
|
|
375
375
|
buildEnd: (this: PluginContext, err?: Error) => Promise<void> | void;
|
|
376
376
|
buildStart: (this: PluginContext, options: NormalizedInputOptions) => Promise<void> | void;
|
|
377
377
|
closeBundle: (this: PluginContext) => Promise<void> | void;
|
|
378
|
-
closeWatcher: (this: PluginContext) => void;
|
|
378
|
+
closeWatcher: (this: PluginContext) => Promise<void> | void;
|
|
379
379
|
load: LoadHook;
|
|
380
380
|
moduleParsed: ModuleParsedHook;
|
|
381
381
|
options: (
|
|
@@ -440,7 +440,9 @@ export type AsyncPluginHooks =
|
|
|
440
440
|
| 'shouldTransformCachedModule'
|
|
441
441
|
| 'transform'
|
|
442
442
|
| 'writeBundle'
|
|
443
|
-
| 'closeBundle'
|
|
443
|
+
| 'closeBundle'
|
|
444
|
+
| 'closeWatcher'
|
|
445
|
+
| 'watchChange';
|
|
444
446
|
|
|
445
447
|
export type PluginValueHooks = 'banner' | 'footer' | 'intro' | 'outro';
|
|
446
448
|
|
|
@@ -458,13 +460,11 @@ export type FirstPluginHooks =
|
|
|
458
460
|
|
|
459
461
|
export type SequentialPluginHooks =
|
|
460
462
|
| 'augmentChunkHash'
|
|
461
|
-
| 'closeWatcher'
|
|
462
463
|
| 'generateBundle'
|
|
463
464
|
| 'options'
|
|
464
465
|
| 'outputOptions'
|
|
465
466
|
| 'renderChunk'
|
|
466
|
-
| 'transform'
|
|
467
|
-
| 'watchChange';
|
|
467
|
+
| 'transform';
|
|
468
468
|
|
|
469
469
|
export type ParallelPluginHooks =
|
|
470
470
|
| 'banner'
|
|
@@ -477,7 +477,9 @@ export type ParallelPluginHooks =
|
|
|
477
477
|
| 'renderError'
|
|
478
478
|
| 'renderStart'
|
|
479
479
|
| 'writeBundle'
|
|
480
|
-
| 'closeBundle'
|
|
480
|
+
| 'closeBundle'
|
|
481
|
+
| 'closeWatcher'
|
|
482
|
+
| 'watchChange';
|
|
481
483
|
|
|
482
484
|
interface OutputPluginValueHooks {
|
|
483
485
|
banner: AddonHook;
|
|
@@ -898,6 +900,24 @@ interface TypedEventEmitter<T extends { [event: string]: (...args: any) => any }
|
|
|
898
900
|
setMaxListeners(n: number): this;
|
|
899
901
|
}
|
|
900
902
|
|
|
903
|
+
export interface RollupAwaitingEmitter<T extends { [event: string]: (...args: any) => any }>
|
|
904
|
+
extends TypedEventEmitter<T> {
|
|
905
|
+
close(): Promise<void>;
|
|
906
|
+
emitAndAwait<K extends keyof T>(event: K, ...args: Parameters<T[K]>): Promise<ReturnType<T[K]>[]>;
|
|
907
|
+
/**
|
|
908
|
+
* Registers an event listener that will be awaited before Rollup continues
|
|
909
|
+
* for events emitted via emitAndAwait. All listeners will be awaited in
|
|
910
|
+
* parallel while rejections are tracked via Promise.all.
|
|
911
|
+
* Listeners are removed automatically when removeAwaited is called, which
|
|
912
|
+
* happens automatically after each run.
|
|
913
|
+
*/
|
|
914
|
+
onCurrentAwaited<K extends keyof T>(
|
|
915
|
+
event: K,
|
|
916
|
+
listener: (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>>
|
|
917
|
+
): this;
|
|
918
|
+
removeAwaited(): this;
|
|
919
|
+
}
|
|
920
|
+
|
|
901
921
|
export type RollupWatcherEvent =
|
|
902
922
|
| { code: 'START' }
|
|
903
923
|
| { code: 'BUNDLE_START'; input?: InputOption; output: readonly string[] }
|
|
@@ -911,15 +931,12 @@ export type RollupWatcherEvent =
|
|
|
911
931
|
| { code: 'END' }
|
|
912
932
|
| { code: 'ERROR'; error: RollupError; result: RollupBuild | null };
|
|
913
933
|
|
|
914
|
-
export
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
}> {
|
|
921
|
-
close(): void;
|
|
922
|
-
}
|
|
934
|
+
export type RollupWatcher = RollupAwaitingEmitter<{
|
|
935
|
+
change: (id: string, change: { event: ChangeEvent }) => void;
|
|
936
|
+
close: () => void;
|
|
937
|
+
event: (event: RollupWatcherEvent) => void;
|
|
938
|
+
restart: () => void;
|
|
939
|
+
}>;
|
|
923
940
|
|
|
924
941
|
export function watch(config: RollupWatchOptions | RollupWatchOptions[]): RollupWatcher;
|
|
925
942
|
|
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED
package/dist/shared/rollup.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Rollup.js v2.70.1
|
|
4
|
+
Mon, 14 Mar 2022 05:50:08 GMT - commit b8315e03f9790d610a413316fbf6d565f9340cab
|
|
6
5
|
|
|
7
6
|
https://github.com/rollup/rollup
|
|
8
7
|
|
|
@@ -28,7 +27,7 @@ function _interopNamespaceDefault(e) {
|
|
|
28
27
|
return n;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
var version$1 = "2.
|
|
30
|
+
var version$1 = "2.70.1";
|
|
32
31
|
|
|
33
32
|
function ensureArray$1(items) {
|
|
34
33
|
if (Array.isArray(items)) {
|
|
@@ -5904,6 +5903,30 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5904
5903
|
}
|
|
5905
5904
|
}
|
|
5906
5905
|
|
|
5906
|
+
const isInteger = (prop) => typeof prop === 'string' && /^\d+$/.test(prop);
|
|
5907
|
+
// This makes sure unknown properties are not handled as "undefined" but as
|
|
5908
|
+
// "unknown" but without access side effects. An exception is done for numeric
|
|
5909
|
+
// properties as we do not expect new builtin properties to be numbers, this
|
|
5910
|
+
// will improve tree-shaking for out-of-bounds array properties
|
|
5911
|
+
const OBJECT_PROTOTYPE_FALLBACK = new (class ObjectPrototypeFallbackExpression extends ExpressionEntity {
|
|
5912
|
+
deoptimizeThisOnEventAtPath(event, path, thisParameter) {
|
|
5913
|
+
if (event === EVENT_CALLED && path.length === 1 && !isInteger(path[0])) {
|
|
5914
|
+
thisParameter.deoptimizePath(UNKNOWN_PATH);
|
|
5915
|
+
}
|
|
5916
|
+
}
|
|
5917
|
+
getLiteralValueAtPath(path) {
|
|
5918
|
+
// We ignore number properties as we do not expect new properties to be
|
|
5919
|
+
// numbers and also want to keep handling out-of-bound array elements as
|
|
5920
|
+
// "undefined"
|
|
5921
|
+
return path.length === 1 && isInteger(path[0]) ? undefined : UnknownValue;
|
|
5922
|
+
}
|
|
5923
|
+
hasEffectsWhenAccessedAtPath(path) {
|
|
5924
|
+
return path.length > 1;
|
|
5925
|
+
}
|
|
5926
|
+
hasEffectsWhenAssignedAtPath(path) {
|
|
5927
|
+
return path.length > 1;
|
|
5928
|
+
}
|
|
5929
|
+
})();
|
|
5907
5930
|
const OBJECT_PROTOTYPE = new ObjectEntity({
|
|
5908
5931
|
__proto__: null,
|
|
5909
5932
|
hasOwnProperty: METHOD_RETURNS_BOOLEAN,
|
|
@@ -5912,7 +5935,7 @@ const OBJECT_PROTOTYPE = new ObjectEntity({
|
|
|
5912
5935
|
toLocaleString: METHOD_RETURNS_STRING,
|
|
5913
5936
|
toString: METHOD_RETURNS_STRING,
|
|
5914
5937
|
valueOf: METHOD_RETURNS_UNKNOWN
|
|
5915
|
-
},
|
|
5938
|
+
}, OBJECT_PROTOTYPE_FALLBACK, true);
|
|
5916
5939
|
|
|
5917
5940
|
const NEW_ARRAY_PROPERTIES = [
|
|
5918
5941
|
{ key: UnknownInteger, kind: 'init', property: UNKNOWN_EXPRESSION },
|
|
@@ -6980,6 +7003,8 @@ const knownGlobals = {
|
|
|
6980
7003
|
isFrozen: PF,
|
|
6981
7004
|
isSealed: PF,
|
|
6982
7005
|
keys: PF,
|
|
7006
|
+
fromEntries: PF,
|
|
7007
|
+
entries: PF,
|
|
6983
7008
|
prototype: O
|
|
6984
7009
|
},
|
|
6985
7010
|
parseFloat: PF,
|
|
@@ -22591,41 +22616,6 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
22591
22616
|
return context;
|
|
22592
22617
|
}
|
|
22593
22618
|
|
|
22594
|
-
const unfulfilledActions = new Set();
|
|
22595
|
-
function addUnresolvedAction(actionTuple) {
|
|
22596
|
-
unfulfilledActions.add(actionTuple);
|
|
22597
|
-
}
|
|
22598
|
-
function resolveAction(actionTuple) {
|
|
22599
|
-
unfulfilledActions.delete(actionTuple);
|
|
22600
|
-
}
|
|
22601
|
-
function formatAction([pluginName, hookName, args]) {
|
|
22602
|
-
const action = `(${pluginName}) ${hookName}`;
|
|
22603
|
-
const s = JSON.stringify;
|
|
22604
|
-
switch (hookName) {
|
|
22605
|
-
case 'resolveId':
|
|
22606
|
-
return `${action} ${s(args[0])} ${s(args[1])}`;
|
|
22607
|
-
case 'load':
|
|
22608
|
-
return `${action} ${s(args[0])}`;
|
|
22609
|
-
case 'transform':
|
|
22610
|
-
return `${action} ${s(args[1])}`;
|
|
22611
|
-
case 'shouldTransformCachedModule':
|
|
22612
|
-
return `${action} ${s(args[0].id)}`;
|
|
22613
|
-
case 'moduleParsed':
|
|
22614
|
-
return `${action} ${s(args[0].id)}`;
|
|
22615
|
-
}
|
|
22616
|
-
return action;
|
|
22617
|
-
}
|
|
22618
|
-
process$1.on('exit', () => {
|
|
22619
|
-
if (unfulfilledActions.size) {
|
|
22620
|
-
let err = '[!] Error: unfinished hook action(s) on exit:\n';
|
|
22621
|
-
for (const action of unfulfilledActions) {
|
|
22622
|
-
err += formatAction(action) + '\n';
|
|
22623
|
-
}
|
|
22624
|
-
console.error('%s', err);
|
|
22625
|
-
process$1.exitCode = 1;
|
|
22626
|
-
}
|
|
22627
|
-
});
|
|
22628
|
-
|
|
22629
22619
|
const inputHookNames = {
|
|
22630
22620
|
buildEnd: 1,
|
|
22631
22621
|
buildStart: 1,
|
|
@@ -22651,6 +22641,7 @@ class PluginDriver {
|
|
|
22651
22641
|
constructor(graph, options, userPlugins, pluginCache, basePluginDriver) {
|
|
22652
22642
|
this.graph = graph;
|
|
22653
22643
|
this.options = options;
|
|
22644
|
+
this.unfulfilledActions = new Set();
|
|
22654
22645
|
warnDeprecatedHooks(userPlugins, options);
|
|
22655
22646
|
this.pluginCache = pluginCache;
|
|
22656
22647
|
this.fileEmitter = new FileEmitter(graph, options, basePluginDriver && basePluginDriver.fileEmitter);
|
|
@@ -22677,6 +22668,9 @@ class PluginDriver {
|
|
|
22677
22668
|
createOutputPluginDriver(plugins) {
|
|
22678
22669
|
return new PluginDriver(this.graph, this.options, plugins, this.pluginCache, this);
|
|
22679
22670
|
}
|
|
22671
|
+
getUnfulfilledHookActions() {
|
|
22672
|
+
return this.unfulfilledActions;
|
|
22673
|
+
}
|
|
22680
22674
|
// chains, first non-null result stops and returns
|
|
22681
22675
|
hookFirst(hookName, args, replaceContext, skipped) {
|
|
22682
22676
|
let promise = Promise.resolve(undefined);
|
|
@@ -22764,12 +22758,6 @@ class PluginDriver {
|
|
|
22764
22758
|
}
|
|
22765
22759
|
return promise;
|
|
22766
22760
|
}
|
|
22767
|
-
// chains synchronously, ignores returns
|
|
22768
|
-
hookSeqSync(hookName, args, replaceContext) {
|
|
22769
|
-
for (const plugin of this.plugins) {
|
|
22770
|
-
this.runHookSync(hookName, args, plugin, replaceContext);
|
|
22771
|
-
}
|
|
22772
|
-
}
|
|
22773
22761
|
runHook(hookName, args, plugin, permitValues, hookContext) {
|
|
22774
22762
|
const hook = plugin[hookName];
|
|
22775
22763
|
if (!hook)
|
|
@@ -22798,22 +22786,21 @@ class PluginDriver {
|
|
|
22798
22786
|
// exit with a successful 0 return code but without producing any
|
|
22799
22787
|
// output, errors or warnings.
|
|
22800
22788
|
action = [plugin.name, hookName, args];
|
|
22801
|
-
|
|
22789
|
+
this.unfulfilledActions.add(action);
|
|
22802
22790
|
// Although it would be more elegant to just return hookResult here
|
|
22803
22791
|
// and put the .then() handler just above the .catch() handler below,
|
|
22804
22792
|
// doing so would subtly change the defacto async event dispatch order
|
|
22805
22793
|
// which at least one test and some plugins in the wild may depend on.
|
|
22806
|
-
|
|
22807
|
-
return promise.then(() => {
|
|
22794
|
+
return Promise.resolve(hookResult).then(result => {
|
|
22808
22795
|
// action was fulfilled
|
|
22809
|
-
|
|
22810
|
-
return
|
|
22796
|
+
this.unfulfilledActions.delete(action);
|
|
22797
|
+
return result;
|
|
22811
22798
|
});
|
|
22812
22799
|
})
|
|
22813
22800
|
.catch(err => {
|
|
22814
22801
|
if (action !== null) {
|
|
22815
22802
|
// action considered to be fulfilled since error being handled
|
|
22816
|
-
|
|
22803
|
+
this.unfulfilledActions.delete(action);
|
|
22817
22804
|
}
|
|
22818
22805
|
return throwPluginError(err, plugin.name, { hook: hookName });
|
|
22819
22806
|
});
|
|
@@ -22902,14 +22889,10 @@ class Graph {
|
|
|
22902
22889
|
}
|
|
22903
22890
|
if (watcher) {
|
|
22904
22891
|
this.watchMode = true;
|
|
22905
|
-
const handleChange = (...args) => this.pluginDriver.
|
|
22906
|
-
const handleClose = () => this.pluginDriver.
|
|
22907
|
-
watcher.
|
|
22908
|
-
watcher.
|
|
22909
|
-
watcher.once('restart', () => {
|
|
22910
|
-
watcher.removeListener('change', handleChange);
|
|
22911
|
-
watcher.removeListener('close', handleClose);
|
|
22912
|
-
});
|
|
22892
|
+
const handleChange = (...args) => this.pluginDriver.hookParallel('watchChange', args);
|
|
22893
|
+
const handleClose = () => this.pluginDriver.hookParallel('closeWatcher', []);
|
|
22894
|
+
watcher.onCurrentAwaited('change', handleChange);
|
|
22895
|
+
watcher.onCurrentAwaited('close', handleClose);
|
|
22913
22896
|
}
|
|
22914
22897
|
this.pluginDriver = new PluginDriver(this, options, options.plugins, this.pluginCache);
|
|
22915
22898
|
this.acornParser = Parser.extend(...options.acornInjectPlugins);
|
|
@@ -23064,6 +23047,38 @@ class Graph {
|
|
|
23064
23047
|
}
|
|
23065
23048
|
}
|
|
23066
23049
|
|
|
23050
|
+
function formatAction([pluginName, hookName, args]) {
|
|
23051
|
+
const action = `(${pluginName}) ${hookName}`;
|
|
23052
|
+
const s = JSON.stringify;
|
|
23053
|
+
switch (hookName) {
|
|
23054
|
+
case 'resolveId':
|
|
23055
|
+
return `${action} ${s(args[0])} ${s(args[1])}`;
|
|
23056
|
+
case 'load':
|
|
23057
|
+
return `${action} ${s(args[0])}`;
|
|
23058
|
+
case 'transform':
|
|
23059
|
+
return `${action} ${s(args[1])}`;
|
|
23060
|
+
case 'shouldTransformCachedModule':
|
|
23061
|
+
return `${action} ${s(args[0].id)}`;
|
|
23062
|
+
case 'moduleParsed':
|
|
23063
|
+
return `${action} ${s(args[0].id)}`;
|
|
23064
|
+
}
|
|
23065
|
+
return action;
|
|
23066
|
+
}
|
|
23067
|
+
async function catchUnfinishedHookActions(pluginDriver, callback) {
|
|
23068
|
+
let handleEmptyEventLoop;
|
|
23069
|
+
const emptyEventLoopPromise = new Promise((_, reject) => {
|
|
23070
|
+
handleEmptyEventLoop = () => {
|
|
23071
|
+
const unfulfilledActions = pluginDriver.getUnfulfilledHookActions();
|
|
23072
|
+
reject(new Error(`Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:\n` +
|
|
23073
|
+
[...unfulfilledActions].map(formatAction).join('\n')));
|
|
23074
|
+
};
|
|
23075
|
+
process$1.once('beforeExit', handleEmptyEventLoop);
|
|
23076
|
+
});
|
|
23077
|
+
const result = await Promise.race([callback(), emptyEventLoopPromise]);
|
|
23078
|
+
process$1.off('beforeExit', handleEmptyEventLoop);
|
|
23079
|
+
return result;
|
|
23080
|
+
}
|
|
23081
|
+
|
|
23067
23082
|
function normalizeInputOptions(config) {
|
|
23068
23083
|
var _a, _b, _c;
|
|
23069
23084
|
// These are options that may trigger special warnings or behaviour later
|
|
@@ -23547,20 +23562,22 @@ async function rollupInternal(rawInputOptions, watcher) {
|
|
|
23547
23562
|
delete inputOptions.cache;
|
|
23548
23563
|
delete rawInputOptions.cache;
|
|
23549
23564
|
timeStart('BUILD', 1);
|
|
23550
|
-
|
|
23551
|
-
|
|
23552
|
-
|
|
23553
|
-
|
|
23554
|
-
catch (err) {
|
|
23555
|
-
const watchFiles = Object.keys(graph.watchFiles);
|
|
23556
|
-
if (watchFiles.length > 0) {
|
|
23557
|
-
err.watchFiles = watchFiles;
|
|
23565
|
+
await catchUnfinishedHookActions(graph.pluginDriver, async () => {
|
|
23566
|
+
try {
|
|
23567
|
+
await graph.pluginDriver.hookParallel('buildStart', [inputOptions]);
|
|
23568
|
+
await graph.build();
|
|
23558
23569
|
}
|
|
23559
|
-
|
|
23560
|
-
|
|
23561
|
-
|
|
23562
|
-
|
|
23563
|
-
|
|
23570
|
+
catch (err) {
|
|
23571
|
+
const watchFiles = Object.keys(graph.watchFiles);
|
|
23572
|
+
if (watchFiles.length > 0) {
|
|
23573
|
+
err.watchFiles = watchFiles;
|
|
23574
|
+
}
|
|
23575
|
+
await graph.pluginDriver.hookParallel('buildEnd', [err]);
|
|
23576
|
+
await graph.pluginDriver.hookParallel('closeBundle', []);
|
|
23577
|
+
throw err;
|
|
23578
|
+
}
|
|
23579
|
+
await graph.pluginDriver.hookParallel('buildEnd', []);
|
|
23580
|
+
});
|
|
23564
23581
|
timeEnd('BUILD', 1);
|
|
23565
23582
|
const result = {
|
|
23566
23583
|
cache: useCache ? graph.getCache() : undefined,
|
|
@@ -23611,21 +23628,23 @@ function normalizePlugins(plugins, anonymousPrefix) {
|
|
|
23611
23628
|
}
|
|
23612
23629
|
});
|
|
23613
23630
|
}
|
|
23614
|
-
|
|
23631
|
+
function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, rawOutputOptions, graph) {
|
|
23615
23632
|
const { options: outputOptions, outputPluginDriver, unsetOptions } = getOutputOptionsAndPluginDriver(rawOutputOptions, graph.pluginDriver, inputOptions, unsetInputOptions);
|
|
23616
|
-
|
|
23617
|
-
|
|
23618
|
-
|
|
23619
|
-
if (
|
|
23620
|
-
|
|
23621
|
-
|
|
23622
|
-
|
|
23623
|
-
|
|
23633
|
+
return catchUnfinishedHookActions(outputPluginDriver, async () => {
|
|
23634
|
+
const bundle = new Bundle(outputOptions, unsetOptions, inputOptions, outputPluginDriver, graph);
|
|
23635
|
+
const generated = await bundle.generate(isWrite);
|
|
23636
|
+
if (isWrite) {
|
|
23637
|
+
if (!outputOptions.dir && !outputOptions.file) {
|
|
23638
|
+
return error({
|
|
23639
|
+
code: 'MISSING_OPTION',
|
|
23640
|
+
message: 'You must specify "output.file" or "output.dir" for the build.'
|
|
23641
|
+
});
|
|
23642
|
+
}
|
|
23643
|
+
await Promise.all(Object.values(generated).map(chunk => writeOutputFile(chunk, outputOptions)));
|
|
23644
|
+
await outputPluginDriver.hookParallel('writeBundle', [outputOptions, generated]);
|
|
23624
23645
|
}
|
|
23625
|
-
|
|
23626
|
-
|
|
23627
|
-
}
|
|
23628
|
-
return createOutput(generated);
|
|
23646
|
+
return createOutput(generated);
|
|
23647
|
+
});
|
|
23629
23648
|
}
|
|
23630
23649
|
function getOutputOptionsAndPluginDriver(rawOutputOptions, inputPluginDriver, inputOptions, unsetInputOptions) {
|
|
23631
23650
|
if (!rawOutputOptions) {
|
|
@@ -23714,12 +23733,30 @@ function defineConfig(options) {
|
|
|
23714
23733
|
class WatchEmitter extends require$$0$2.EventEmitter {
|
|
23715
23734
|
constructor() {
|
|
23716
23735
|
super();
|
|
23736
|
+
this.awaitedHandlers = Object.create(null);
|
|
23717
23737
|
// Allows more than 10 bundles to be watched without
|
|
23718
23738
|
// showing the `MaxListenersExceededWarning` to the user.
|
|
23719
23739
|
this.setMaxListeners(Infinity);
|
|
23720
23740
|
}
|
|
23721
|
-
|
|
23741
|
+
// Will be overwritten by Rollup
|
|
23742
|
+
async close() { }
|
|
23743
|
+
emitAndAwait(event, ...args) {
|
|
23744
|
+
this.emit(event, ...args);
|
|
23745
|
+
return Promise.all(this.getHandlers(event).map(handler => handler(...args)));
|
|
23746
|
+
}
|
|
23747
|
+
onCurrentAwaited(event, listener) {
|
|
23748
|
+
this.getHandlers(event).push(listener);
|
|
23749
|
+
return this;
|
|
23750
|
+
}
|
|
23751
|
+
removeAwaited() {
|
|
23752
|
+
this.awaitedHandlers = {};
|
|
23753
|
+
return this;
|
|
23754
|
+
}
|
|
23755
|
+
getHandlers(event) {
|
|
23756
|
+
return this.awaitedHandlers[event] || (this.awaitedHandlers[event] = []);
|
|
23757
|
+
}
|
|
23722
23758
|
}
|
|
23759
|
+
|
|
23723
23760
|
function watch(configs) {
|
|
23724
23761
|
const emitter = new WatchEmitter();
|
|
23725
23762
|
const configArray = ensureArray$1(configs);
|
package/dist/shared/watch-cli.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Rollup.js v2.70.1
|
|
4
|
+
Mon, 14 Mar 2022 05:50:08 GMT - commit b8315e03f9790d610a413316fbf6d565f9340cab
|
|
6
5
|
|
|
7
6
|
https://github.com/rollup/rollup
|
|
8
7
|
|
|
@@ -389,7 +388,7 @@ async function watch(command) {
|
|
|
389
388
|
return;
|
|
390
389
|
}
|
|
391
390
|
if (watcher) {
|
|
392
|
-
watcher.close();
|
|
391
|
+
await watcher.close();
|
|
393
392
|
}
|
|
394
393
|
start(options, warnings);
|
|
395
394
|
}
|
|
@@ -455,12 +454,12 @@ async function watch(command) {
|
|
|
455
454
|
}
|
|
456
455
|
});
|
|
457
456
|
}
|
|
458
|
-
function close(code) {
|
|
457
|
+
async function close(code) {
|
|
459
458
|
process$2.removeListener('uncaughtException', close);
|
|
460
459
|
// removing a non-existent listener is a no-op
|
|
461
460
|
process$2.stdin.removeListener('end', close);
|
|
462
461
|
if (watcher)
|
|
463
|
-
watcher.close();
|
|
462
|
+
await watcher.close();
|
|
464
463
|
if (configWatcher)
|
|
465
464
|
configWatcher.close();
|
|
466
465
|
if (code) {
|
package/dist/shared/watch.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Rollup.js v2.70.1
|
|
4
|
+
Mon, 14 Mar 2022 05:50:08 GMT - commit b8315e03f9790d610a413316fbf6d565f9340cab
|
|
6
5
|
|
|
7
6
|
https://github.com/rollup/rollup
|
|
8
7
|
|
|
@@ -113,13 +112,13 @@ class Watcher {
|
|
|
113
112
|
: buildDelay, this.buildDelay);
|
|
114
113
|
process.nextTick(() => this.run());
|
|
115
114
|
}
|
|
116
|
-
close() {
|
|
115
|
+
async close() {
|
|
117
116
|
if (this.buildTimeout)
|
|
118
117
|
clearTimeout(this.buildTimeout);
|
|
119
118
|
for (const task of this.tasks) {
|
|
120
119
|
task.close();
|
|
121
120
|
}
|
|
122
|
-
this.emitter.
|
|
121
|
+
await this.emitter.emitAndAwait('close');
|
|
123
122
|
this.emitter.removeAllListeners();
|
|
124
123
|
}
|
|
125
124
|
invalidate(file) {
|
|
@@ -143,14 +142,26 @@ class Watcher {
|
|
|
143
142
|
}
|
|
144
143
|
if (this.buildTimeout)
|
|
145
144
|
clearTimeout(this.buildTimeout);
|
|
146
|
-
this.buildTimeout = setTimeout(() => {
|
|
145
|
+
this.buildTimeout = setTimeout(async () => {
|
|
147
146
|
this.buildTimeout = null;
|
|
148
|
-
|
|
149
|
-
this.emitter.
|
|
147
|
+
try {
|
|
148
|
+
await Promise.all([...this.invalidatedIds].map(([id, event]) => this.emitter.emitAndAwait('change', id, { event })));
|
|
149
|
+
this.invalidatedIds.clear();
|
|
150
|
+
this.emitter.emit('restart');
|
|
151
|
+
this.emitter.removeAwaited();
|
|
152
|
+
this.run();
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
this.invalidatedIds.clear();
|
|
156
|
+
this.emitter.emit('event', {
|
|
157
|
+
code: 'ERROR',
|
|
158
|
+
error,
|
|
159
|
+
result: null
|
|
160
|
+
});
|
|
161
|
+
this.emitter.emit('event', {
|
|
162
|
+
code: 'END'
|
|
163
|
+
});
|
|
150
164
|
}
|
|
151
|
-
this.invalidatedIds.clear();
|
|
152
|
-
this.emitter.emit('restart');
|
|
153
|
-
this.run();
|
|
154
165
|
}, this.buildDelay);
|
|
155
166
|
}
|
|
156
167
|
async run() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollup",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.70.1",
|
|
4
4
|
"description": "Next-generation ES module bundler",
|
|
5
5
|
"main": "dist/rollup.js",
|
|
6
6
|
"module": "dist/es/rollup.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"rollup": "dist/bin/rollup"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "shx rm -rf dist &&
|
|
12
|
+
"build": "shx rm -rf dist && node scripts/update-git-commit.js && rollup --config rollup.config.ts --configPlugin typescript && shx cp src/rollup/types.d.ts dist/rollup.d.ts && shx chmod a+x dist/bin/rollup",
|
|
13
13
|
"build:cjs": "shx rm -rf dist && rollup --config rollup.config.ts --configPlugin typescript --configTest && shx cp src/rollup/types.d.ts dist/rollup.d.ts && shx chmod a+x dist/bin/rollup",
|
|
14
14
|
"build:bootstrap": "node dist/bin/rollup --config rollup.config.ts --configPlugin typescript && shx cp src/rollup/types.d.ts dist/rollup.d.ts && shx chmod a+x dist/bin/rollup",
|
|
15
15
|
"ci:lint": "npm run lint:nofix",
|
|
@@ -22,10 +22,9 @@
|
|
|
22
22
|
"perf": "npm run build:cjs && node --expose-gc scripts/perf.js",
|
|
23
23
|
"perf:debug": "node --inspect-brk scripts/perf-debug.js",
|
|
24
24
|
"perf:init": "node scripts/perf-init.js",
|
|
25
|
-
"
|
|
26
|
-
"postpublish": "pinst --enable && git push && git push --tags",
|
|
25
|
+
"postpublish": "git push && git push --tags",
|
|
27
26
|
"prepare": "husky install && npm run build",
|
|
28
|
-
"prepublishOnly": "
|
|
27
|
+
"prepublishOnly": "npm ci && npm run lint:nofix && npm run security && npm run build:bootstrap && npm run test:all",
|
|
29
28
|
"security": "npm audit",
|
|
30
29
|
"test": "npm run build && npm run test:all",
|
|
31
30
|
"test:cjs": "npm run build:cjs && npm run test:only",
|
|
@@ -97,7 +96,6 @@
|
|
|
97
96
|
"magic-string": "^0.25.7",
|
|
98
97
|
"mocha": "^9.2.1",
|
|
99
98
|
"nyc": "^15.1.0",
|
|
100
|
-
"pinst": "^3.0.0",
|
|
101
99
|
"prettier": "^2.5.1",
|
|
102
100
|
"pretty-bytes": "^5.6.0",
|
|
103
101
|
"pretty-ms": "^7.0.1",
|
|
@@ -138,6 +136,6 @@
|
|
|
138
136
|
},
|
|
139
137
|
"default": "./dist/es/rollup.browser.js"
|
|
140
138
|
},
|
|
141
|
-
"./dist
|
|
139
|
+
"./dist/*": "./dist/*"
|
|
142
140
|
}
|
|
143
141
|
}
|