@rollup/wasm-node 4.63.3 → 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 +394 -95
- 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/native.js +3 -0
- 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 +363 -91
- package/dist/shared/watch-cli.js +17 -8
- package/dist/shared/watch.js +99 -46
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +5 -5
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/native.js
CHANGED
|
@@ -11,3 +11,6 @@ exports.parseAsync = async (code, allowReturnOutsideFunction, jsx, _signal) =>
|
|
|
11
11
|
exports.xxhashBase64Url = xxhashBase64Url;
|
|
12
12
|
exports.xxhashBase36 = xxhashBase36;
|
|
13
13
|
exports.xxhashBase16 = xxhashBase16;
|
|
14
|
+
// WASM builds don't collect LLVM coverage. This no-op keeps exports in sync
|
|
15
|
+
// with native.js, where flushLlvmCoverage only exists in coverage builds.
|
|
16
|
+
exports.flushLlvmCoverage = () => {};
|
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,
|
package/dist/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
|
|
|
@@ -12,118 +12,20 @@
|
|
|
12
12
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
13
13
|
|
|
14
14
|
const rollup = require('./shared/rollup.js');
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
require('
|
|
15
|
+
const rollup_js = require('./shared/node-entry.js');
|
|
16
|
+
require('./shared/parseAst.js');
|
|
17
|
+
require('./native.js');
|
|
18
18
|
require('node:path');
|
|
19
|
+
require('node:process');
|
|
19
20
|
require('path');
|
|
20
|
-
require('./native.js');
|
|
21
21
|
require('node:perf_hooks');
|
|
22
22
|
require('node:fs/promises');
|
|
23
|
+
require('./shared/fsevents-importer.js');
|
|
23
24
|
|
|
24
|
-
class WatchEmitter {
|
|
25
|
-
constructor() {
|
|
26
|
-
this.currentHandlers = Object.create(null);
|
|
27
|
-
this.persistentHandlers = Object.create(null);
|
|
28
|
-
}
|
|
29
|
-
// Will be overwritten by Rollup
|
|
30
|
-
async close() { }
|
|
31
|
-
emit(event, ...parameters) {
|
|
32
|
-
return Promise.all([...this.getCurrentHandlers(event), ...this.getPersistentHandlers(event)].map(handler => handler(...parameters)));
|
|
33
|
-
}
|
|
34
|
-
off(event, listener) {
|
|
35
|
-
const listeners = this.persistentHandlers[event];
|
|
36
|
-
if (listeners) {
|
|
37
|
-
// A hack stolen from "mitt": ">>> 0" does not change numbers >= 0, but -1
|
|
38
|
-
// (which would remove the last array element if used unchanged) is turned
|
|
39
|
-
// into max_int, which is outside the array and does not change anything.
|
|
40
|
-
listeners.splice(listeners.indexOf(listener) >>> 0, 1);
|
|
41
|
-
}
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
on(event, listener) {
|
|
45
|
-
this.getPersistentHandlers(event).push(listener);
|
|
46
|
-
return this;
|
|
47
|
-
}
|
|
48
|
-
onCurrentRun(event, listener) {
|
|
49
|
-
this.getCurrentHandlers(event).push(listener);
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
once(event, listener) {
|
|
53
|
-
const selfRemovingListener = (...parameters) => {
|
|
54
|
-
this.off(event, selfRemovingListener);
|
|
55
|
-
return listener(...parameters);
|
|
56
|
-
};
|
|
57
|
-
this.on(event, selfRemovingListener);
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
removeAllListeners() {
|
|
61
|
-
this.removeListenersForCurrentRun();
|
|
62
|
-
this.persistentHandlers = Object.create(null);
|
|
63
|
-
return this;
|
|
64
|
-
}
|
|
65
|
-
removeListenersForCurrentRun() {
|
|
66
|
-
this.currentHandlers = Object.create(null);
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
|
-
getCurrentHandlers(event) {
|
|
70
|
-
return this.currentHandlers[event] || (this.currentHandlers[event] = []);
|
|
71
|
-
}
|
|
72
|
-
getPersistentHandlers(event) {
|
|
73
|
-
return this.persistentHandlers[event] || (this.persistentHandlers[event] = []);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function watch(configs) {
|
|
78
|
-
const emitter = new WatchEmitter();
|
|
79
|
-
watchInternal(configs, emitter).catch(error => {
|
|
80
|
-
rollup.handleError(error);
|
|
81
|
-
});
|
|
82
|
-
return emitter;
|
|
83
|
-
}
|
|
84
|
-
function ensureTrailingSlash(path) {
|
|
85
|
-
if (path[path.length - 1] !== '/') {
|
|
86
|
-
return `${path}/`;
|
|
87
|
-
}
|
|
88
|
-
return path;
|
|
89
|
-
}
|
|
90
|
-
function checkWatchConfig(config) {
|
|
91
|
-
for (const item of config) {
|
|
92
|
-
if (typeof item.watch !== 'boolean' && item.watch?.allowInputInsideOutputPath) {
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
if (item.input && item.output) {
|
|
96
|
-
const input = typeof item.input === 'string' ? rollup.ensureArray(item.input) : item.input;
|
|
97
|
-
const outputs = rollup.ensureArray(item.output);
|
|
98
|
-
for (const index in input) {
|
|
99
|
-
const inputPath = input[index];
|
|
100
|
-
if (typeof inputPath !== 'string') {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const outputWithInputAsSubPath = outputs.find(({ dir }) => dir && ensureTrailingSlash(inputPath).startsWith(ensureTrailingSlash(dir)));
|
|
104
|
-
if (outputWithInputAsSubPath) {
|
|
105
|
-
parseAst_js.error(parseAst_js.logInvalidOption('watch', parseAst_js.URL_WATCH, `the input "${inputPath}" is a subpath of the output "${outputWithInputAsSubPath.dir}"`));
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
async function watchInternal(configs, emitter) {
|
|
112
|
-
const optionsList = await Promise.all(rollup.ensureArray(configs).map(config => rollup.mergeOptions(config, true)));
|
|
113
|
-
const watchOptionsList = optionsList.filter(config => config.watch !== false);
|
|
114
|
-
if (watchOptionsList.length === 0) {
|
|
115
|
-
return parseAst_js.error(parseAst_js.logInvalidOption('watch', parseAst_js.URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
|
|
116
|
-
}
|
|
117
|
-
checkWatchConfig(watchOptionsList);
|
|
118
|
-
await fseventsImporter.loadFsEvents();
|
|
119
|
-
const { Watcher } = await Promise.resolve().then(() => require('./shared/watch.js'));
|
|
120
|
-
new Watcher(watchOptionsList, emitter);
|
|
121
|
-
}
|
|
122
25
|
|
|
123
|
-
const VERSION = rollup.package_.version;
|
|
124
26
|
|
|
125
27
|
exports.defineConfig = rollup.defineConfig;
|
|
126
28
|
exports.rollup = rollup.rollup;
|
|
127
|
-
exports.VERSION = VERSION;
|
|
128
|
-
exports.watch = watch;
|
|
29
|
+
exports.VERSION = rollup_js.VERSION;
|
|
30
|
+
exports.watch = rollup_js.watch;
|
|
129
31
|
//# sourceMappingURL=rollup.js.map
|
package/dist/shared/index.js
CHANGED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/*
|
|
2
|
+
@license
|
|
3
|
+
Rollup.js v4.63.5
|
|
4
|
+
Thu, 24 Sep 2026 10:07:23 GMT - commit 3722484c33c58b3ab0cbbfcca09b8f267d420329
|
|
5
|
+
|
|
6
|
+
https://github.com/rollup/rollup
|
|
7
|
+
|
|
8
|
+
Released under the MIT License.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const rollup = require('./rollup.js');
|
|
13
|
+
const parseAst_js = require('./parseAst.js');
|
|
14
|
+
const fseventsImporter = require('./fsevents-importer.js');
|
|
15
|
+
|
|
16
|
+
function waitForAllAndRethrowFirstFailure(promises) {
|
|
17
|
+
return Promise.allSettled(promises).then(results => {
|
|
18
|
+
for (const result of results) {
|
|
19
|
+
if (result.status === 'rejected') {
|
|
20
|
+
throw result.reason;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
class WatchEmitter {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.currentHandlers = Object.create(null);
|
|
28
|
+
this.persistentHandlers = Object.create(null);
|
|
29
|
+
}
|
|
30
|
+
// Will be overwritten by Rollup
|
|
31
|
+
async close() { }
|
|
32
|
+
emit(event, ...parameters) {
|
|
33
|
+
// The async wrapper turns a synchronous throw into a rejection so that no sibling listener is skipped.
|
|
34
|
+
return waitForAllAndRethrowFirstFailure([...this.getCurrentHandlers(event), ...this.getPersistentHandlers(event)].map(async (handler) => handler(...parameters)));
|
|
35
|
+
}
|
|
36
|
+
off(event, listener) {
|
|
37
|
+
const listeners = this.persistentHandlers[event];
|
|
38
|
+
if (listeners) {
|
|
39
|
+
// A hack stolen from "mitt": ">>> 0" does not change numbers >= 0, but -1
|
|
40
|
+
// (which would remove the last array element if used unchanged) is turned
|
|
41
|
+
// into max_int, which is outside the array and does not change anything.
|
|
42
|
+
listeners.splice(listeners.indexOf(listener) >>> 0, 1);
|
|
43
|
+
}
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
on(event, listener) {
|
|
47
|
+
this.getPersistentHandlers(event).push(listener);
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
onCurrentRun(event, listener) {
|
|
51
|
+
this.getCurrentHandlers(event).push(listener);
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
once(event, listener) {
|
|
55
|
+
const selfRemovingListener = (...parameters) => {
|
|
56
|
+
this.off(event, selfRemovingListener);
|
|
57
|
+
return listener(...parameters);
|
|
58
|
+
};
|
|
59
|
+
this.on(event, selfRemovingListener);
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
removeAllListeners() {
|
|
63
|
+
this.removeListenersForCurrentRun();
|
|
64
|
+
this.persistentHandlers = Object.create(null);
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
removeListenersForCurrentRun() {
|
|
68
|
+
this.currentHandlers = Object.create(null);
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
getCurrentHandlers(event) {
|
|
72
|
+
return this.currentHandlers[event] || (this.currentHandlers[event] = []);
|
|
73
|
+
}
|
|
74
|
+
getPersistentHandlers(event) {
|
|
75
|
+
return this.persistentHandlers[event] || (this.persistentHandlers[event] = []);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function watch(configs) {
|
|
80
|
+
const emitter = new WatchEmitter();
|
|
81
|
+
let isClosed = false;
|
|
82
|
+
// Until the watcher takes over closing, a close prevents its construction
|
|
83
|
+
// and emits close itself, as no watcher will.
|
|
84
|
+
emitter.close = async () => {
|
|
85
|
+
if (isClosed)
|
|
86
|
+
return;
|
|
87
|
+
isClosed = true;
|
|
88
|
+
try {
|
|
89
|
+
await emitter.emit('close');
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
emitter.removeAllListeners();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
watchInternal(configs, emitter, () => isClosed).catch(error => {
|
|
96
|
+
rollup.handleError(error);
|
|
97
|
+
});
|
|
98
|
+
return emitter;
|
|
99
|
+
}
|
|
100
|
+
function ensureTrailingSlash(path) {
|
|
101
|
+
if (path[path.length - 1] !== '/') {
|
|
102
|
+
return `${path}/`;
|
|
103
|
+
}
|
|
104
|
+
return path;
|
|
105
|
+
}
|
|
106
|
+
function checkWatchConfig(config) {
|
|
107
|
+
for (const item of config) {
|
|
108
|
+
if (typeof item.watch !== 'boolean' && item.watch?.allowInputInsideOutputPath) {
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
if (item.input && item.output) {
|
|
112
|
+
const input = typeof item.input === 'string' ? rollup.ensureArray(item.input) : item.input;
|
|
113
|
+
const outputs = rollup.ensureArray(item.output);
|
|
114
|
+
for (const index in input) {
|
|
115
|
+
const inputPath = input[index];
|
|
116
|
+
if (typeof inputPath !== 'string') {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const outputWithInputAsSubPath = outputs.find(({ dir }) => dir && ensureTrailingSlash(inputPath).startsWith(ensureTrailingSlash(dir)));
|
|
120
|
+
if (outputWithInputAsSubPath) {
|
|
121
|
+
parseAst_js.error(parseAst_js.logInvalidOption('watch', parseAst_js.URL_WATCH, `the input "${inputPath}" is a subpath of the output "${outputWithInputAsSubPath.dir}"`));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async function watchInternal(configs, emitter, wasClosed) {
|
|
128
|
+
const optionsList = await Promise.all(rollup.ensureArray(configs).map(config => rollup.mergeOptions(config, true)));
|
|
129
|
+
const watchOptionsList = optionsList.filter(config => config.watch !== false);
|
|
130
|
+
if (watchOptionsList.length === 0) {
|
|
131
|
+
return parseAst_js.error(parseAst_js.logInvalidOption('watch', parseAst_js.URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
|
|
132
|
+
}
|
|
133
|
+
checkWatchConfig(watchOptionsList);
|
|
134
|
+
await fseventsImporter.loadFsEvents();
|
|
135
|
+
const { Watcher } = await Promise.resolve().then(() => require('./watch.js'));
|
|
136
|
+
if (wasClosed()) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
new Watcher(watchOptionsList, emitter);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const VERSION = rollup.package_.version;
|
|
143
|
+
|
|
144
|
+
exports.VERSION = VERSION;
|
|
145
|
+
exports.waitForAllAndRethrowFirstFailure = waitForAllAndRethrowFirstFailure;
|
|
146
|
+
exports.watch = watch;
|
|
147
|
+
//# sourceMappingURL=node-entry.js.map
|
package/dist/shared/parseAst.js
CHANGED