rollup 2.69.2 → 2.70.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 +2 -3
- package/dist/es/rollup.browser.js +3 -4
- package/dist/es/rollup.js +2 -3
- package/dist/es/shared/rollup.js +34 -27
- 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 +26 -19
- package/dist/shared/watch-cli.js +5 -6
- package/dist/shared/watch.js +22 -11
- package/package.json +4 -6
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.0
|
|
4
|
+
Mon, 07 Mar 2022 06:21:56 GMT - commit 6d8924c8acd7fd124da5fa8026537e1c629f1515
|
|
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.0";
|
|
32
31
|
|
|
33
32
|
function ensureArray$1(items) {
|
|
34
33
|
if (Array.isArray(items)) {
|
|
@@ -22790,12 +22789,6 @@ class PluginDriver {
|
|
|
22790
22789
|
}
|
|
22791
22790
|
return promise;
|
|
22792
22791
|
}
|
|
22793
|
-
// chains synchronously, ignores returns
|
|
22794
|
-
hookSeqSync(hookName, args, replaceContext) {
|
|
22795
|
-
for (const plugin of this.plugins) {
|
|
22796
|
-
this.runHookSync(hookName, args, plugin, replaceContext);
|
|
22797
|
-
}
|
|
22798
|
-
}
|
|
22799
22792
|
runHook(hookName, args, plugin, permitValues, hookContext) {
|
|
22800
22793
|
const hook = plugin[hookName];
|
|
22801
22794
|
if (!hook)
|
|
@@ -22928,14 +22921,10 @@ class Graph {
|
|
|
22928
22921
|
}
|
|
22929
22922
|
if (watcher) {
|
|
22930
22923
|
this.watchMode = true;
|
|
22931
|
-
const handleChange = (...args) => this.pluginDriver.
|
|
22932
|
-
const handleClose = () => this.pluginDriver.
|
|
22933
|
-
watcher.
|
|
22934
|
-
watcher.
|
|
22935
|
-
watcher.once('restart', () => {
|
|
22936
|
-
watcher.removeListener('change', handleChange);
|
|
22937
|
-
watcher.removeListener('close', handleClose);
|
|
22938
|
-
});
|
|
22924
|
+
const handleChange = (...args) => this.pluginDriver.hookParallel('watchChange', args);
|
|
22925
|
+
const handleClose = () => this.pluginDriver.hookParallel('closeWatcher', []);
|
|
22926
|
+
watcher.onCurrentAwaited('change', handleChange);
|
|
22927
|
+
watcher.onCurrentAwaited('close', handleClose);
|
|
22939
22928
|
}
|
|
22940
22929
|
this.pluginDriver = new PluginDriver(this, options, options.plugins, this.pluginCache);
|
|
22941
22930
|
this.acornParser = Parser.extend(...options.acornInjectPlugins);
|
|
@@ -23740,12 +23729,30 @@ function defineConfig(options) {
|
|
|
23740
23729
|
class WatchEmitter extends require$$0$2.EventEmitter {
|
|
23741
23730
|
constructor() {
|
|
23742
23731
|
super();
|
|
23732
|
+
this.awaitedHandlers = Object.create(null);
|
|
23743
23733
|
// Allows more than 10 bundles to be watched without
|
|
23744
23734
|
// showing the `MaxListenersExceededWarning` to the user.
|
|
23745
23735
|
this.setMaxListeners(Infinity);
|
|
23746
23736
|
}
|
|
23747
|
-
|
|
23737
|
+
// Will be overwritten by Rollup
|
|
23738
|
+
async close() { }
|
|
23739
|
+
emitAndAwait(event, ...args) {
|
|
23740
|
+
this.emit(event, ...args);
|
|
23741
|
+
return Promise.all(this.getHandlers(event).map(handler => handler(...args)));
|
|
23742
|
+
}
|
|
23743
|
+
onCurrentAwaited(event, listener) {
|
|
23744
|
+
this.getHandlers(event).push(listener);
|
|
23745
|
+
return this;
|
|
23746
|
+
}
|
|
23747
|
+
removeAwaited() {
|
|
23748
|
+
this.awaitedHandlers = {};
|
|
23749
|
+
return this;
|
|
23750
|
+
}
|
|
23751
|
+
getHandlers(event) {
|
|
23752
|
+
return this.awaitedHandlers[event] || (this.awaitedHandlers[event] = []);
|
|
23753
|
+
}
|
|
23748
23754
|
}
|
|
23755
|
+
|
|
23749
23756
|
function watch(configs) {
|
|
23750
23757
|
const emitter = new WatchEmitter();
|
|
23751
23758
|
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.0
|
|
4
|
+
Mon, 07 Mar 2022 06:21:56 GMT - commit 6d8924c8acd7fd124da5fa8026537e1c629f1515
|
|
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.0
|
|
4
|
+
Mon, 07 Mar 2022 06:21:56 GMT - commit 6d8924c8acd7fd124da5fa8026537e1c629f1515
|
|
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.0",
|
|
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",
|