rollup 4.0.0-1 → 4.0.0-2
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 +1722 -0
- package/dist/es/getLogFilter.js +65 -0
- package/dist/es/native.js +257 -0
- package/dist/es/package.json +1 -0
- package/dist/es/rollup.js +18 -0
- package/dist/es/shared/node-entry.js +28052 -0
- package/dist/es/shared/watch.js +4900 -0
- package/dist/getLogFilter.d.ts +5 -0
- package/dist/getLogFilter.js +70 -0
- package/dist/loadConfigFile.d.ts +20 -0
- package/dist/loadConfigFile.js +30 -0
- package/dist/native.js +257 -0
- package/dist/rollup.d.ts +1008 -0
- package/dist/rollup.js +32 -0
- package/dist/shared/fsevents-importer.js +38 -0
- package/dist/shared/index.js +4611 -0
- package/dist/shared/loadConfigFile.js +551 -0
- package/dist/shared/rollup.js +28128 -0
- package/dist/shared/watch-cli.js +560 -0
- package/dist/shared/watch-proxy.js +89 -0
- package/dist/shared/watch.js +319 -0
- package/package.json +17 -17
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/*
|
|
2
|
+
@license
|
|
3
|
+
Rollup.js v4.0.0-2
|
|
4
|
+
Tue, 01 Aug 2023 11:16:13 GMT - commit d62558dbc45912c9c4478dc761bb290738c3b968
|
|
5
|
+
|
|
6
|
+
https://github.com/rollup/rollup
|
|
7
|
+
|
|
8
|
+
Released under the MIT License.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
13
|
+
|
|
14
|
+
const node_path = require('node:path');
|
|
15
|
+
const process = require('node:process');
|
|
16
|
+
const rollup = require('./rollup.js');
|
|
17
|
+
const node_os = require('node:os');
|
|
18
|
+
const index = require('./index.js');
|
|
19
|
+
require('tty');
|
|
20
|
+
require('path');
|
|
21
|
+
require('node:perf_hooks');
|
|
22
|
+
require('node:crypto');
|
|
23
|
+
require('../native');
|
|
24
|
+
require('node:fs/promises');
|
|
25
|
+
require('fs');
|
|
26
|
+
require('util');
|
|
27
|
+
require('stream');
|
|
28
|
+
require('os');
|
|
29
|
+
require('./fsevents-importer.js');
|
|
30
|
+
require('events');
|
|
31
|
+
|
|
32
|
+
class FileWatcher {
|
|
33
|
+
constructor(task, chokidarOptions) {
|
|
34
|
+
this.transformWatchers = new Map();
|
|
35
|
+
this.chokidarOptions = chokidarOptions;
|
|
36
|
+
this.task = task;
|
|
37
|
+
this.watcher = this.createWatcher(null);
|
|
38
|
+
}
|
|
39
|
+
close() {
|
|
40
|
+
this.watcher.close();
|
|
41
|
+
for (const watcher of this.transformWatchers.values()) {
|
|
42
|
+
watcher.close();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
unwatch(id) {
|
|
46
|
+
this.watcher.unwatch(id);
|
|
47
|
+
const transformWatcher = this.transformWatchers.get(id);
|
|
48
|
+
if (transformWatcher) {
|
|
49
|
+
this.transformWatchers.delete(id);
|
|
50
|
+
transformWatcher.close();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
watch(id, isTransformDependency) {
|
|
54
|
+
if (isTransformDependency) {
|
|
55
|
+
const watcher = this.transformWatchers.get(id) ?? this.createWatcher(id);
|
|
56
|
+
watcher.add(id);
|
|
57
|
+
this.transformWatchers.set(id, watcher);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.watcher.add(id);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
createWatcher(transformWatcherId) {
|
|
64
|
+
const task = this.task;
|
|
65
|
+
const isLinux = node_os.platform() === 'linux';
|
|
66
|
+
const isTransformDependency = transformWatcherId !== null;
|
|
67
|
+
const handleChange = (id, event) => {
|
|
68
|
+
const changedId = transformWatcherId || id;
|
|
69
|
+
if (isLinux) {
|
|
70
|
+
// unwatching and watching fixes an issue with chokidar where on certain systems,
|
|
71
|
+
// a file that was unlinked and immediately recreated would create a change event
|
|
72
|
+
// but then no longer any further events
|
|
73
|
+
watcher.unwatch(changedId);
|
|
74
|
+
watcher.add(changedId);
|
|
75
|
+
}
|
|
76
|
+
task.invalidate(changedId, { event, isTransformDependency });
|
|
77
|
+
};
|
|
78
|
+
const watcher = index.chokidar
|
|
79
|
+
.watch([], this.chokidarOptions)
|
|
80
|
+
.on('add', id => handleChange(id, 'create'))
|
|
81
|
+
.on('change', id => handleChange(id, 'update'))
|
|
82
|
+
.on('unlink', id => handleChange(id, 'delete'));
|
|
83
|
+
return watcher;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=fileWatcher.js.map
|
|
87
|
+
|
|
88
|
+
const eventsRewrites = {
|
|
89
|
+
create: {
|
|
90
|
+
create: 'buggy',
|
|
91
|
+
delete: null,
|
|
92
|
+
update: 'create'
|
|
93
|
+
},
|
|
94
|
+
delete: {
|
|
95
|
+
create: 'update',
|
|
96
|
+
delete: 'buggy',
|
|
97
|
+
update: 'buggy'
|
|
98
|
+
},
|
|
99
|
+
update: {
|
|
100
|
+
create: 'buggy',
|
|
101
|
+
delete: 'delete',
|
|
102
|
+
update: 'update'
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
class Watcher {
|
|
106
|
+
constructor(optionsList, emitter) {
|
|
107
|
+
this.buildDelay = 0;
|
|
108
|
+
this.buildTimeout = null;
|
|
109
|
+
this.closed = false;
|
|
110
|
+
this.invalidatedIds = new Map();
|
|
111
|
+
this.rerun = false;
|
|
112
|
+
this.running = true;
|
|
113
|
+
this.emitter = emitter;
|
|
114
|
+
emitter.close = this.close.bind(this);
|
|
115
|
+
this.tasks = optionsList.map(options => new Task(this, options));
|
|
116
|
+
for (const { watch } of optionsList) {
|
|
117
|
+
if (watch && typeof watch.buildDelay === 'number') {
|
|
118
|
+
this.buildDelay = Math.max(this.buildDelay, watch.buildDelay);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
process.nextTick(() => this.run());
|
|
122
|
+
}
|
|
123
|
+
async close() {
|
|
124
|
+
if (this.closed)
|
|
125
|
+
return;
|
|
126
|
+
this.closed = true;
|
|
127
|
+
if (this.buildTimeout)
|
|
128
|
+
clearTimeout(this.buildTimeout);
|
|
129
|
+
for (const task of this.tasks) {
|
|
130
|
+
task.close();
|
|
131
|
+
}
|
|
132
|
+
await this.emitter.emit('close');
|
|
133
|
+
this.emitter.removeAllListeners();
|
|
134
|
+
}
|
|
135
|
+
invalidate(file) {
|
|
136
|
+
if (file) {
|
|
137
|
+
const previousEvent = this.invalidatedIds.get(file.id);
|
|
138
|
+
const event = previousEvent ? eventsRewrites[previousEvent][file.event] : file.event;
|
|
139
|
+
if (event === 'buggy') {
|
|
140
|
+
//TODO: throws or warn? Currently just ignore, uses new event
|
|
141
|
+
this.invalidatedIds.set(file.id, file.event);
|
|
142
|
+
}
|
|
143
|
+
else if (event === null) {
|
|
144
|
+
this.invalidatedIds.delete(file.id);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
this.invalidatedIds.set(file.id, event);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (this.running) {
|
|
151
|
+
this.rerun = true;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (this.buildTimeout)
|
|
155
|
+
clearTimeout(this.buildTimeout);
|
|
156
|
+
this.buildTimeout = setTimeout(async () => {
|
|
157
|
+
this.buildTimeout = null;
|
|
158
|
+
try {
|
|
159
|
+
await Promise.all([...this.invalidatedIds].map(([id, event]) => this.emitter.emit('change', id, { event })));
|
|
160
|
+
this.invalidatedIds.clear();
|
|
161
|
+
await this.emitter.emit('restart');
|
|
162
|
+
this.emitter.removeListenersForCurrentRun();
|
|
163
|
+
this.run();
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
this.invalidatedIds.clear();
|
|
167
|
+
await this.emitter.emit('event', {
|
|
168
|
+
code: 'ERROR',
|
|
169
|
+
error,
|
|
170
|
+
result: null
|
|
171
|
+
});
|
|
172
|
+
await this.emitter.emit('event', {
|
|
173
|
+
code: 'END'
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}, this.buildDelay);
|
|
177
|
+
}
|
|
178
|
+
async run() {
|
|
179
|
+
this.running = true;
|
|
180
|
+
await this.emitter.emit('event', {
|
|
181
|
+
code: 'START'
|
|
182
|
+
});
|
|
183
|
+
for (const task of this.tasks) {
|
|
184
|
+
await task.run();
|
|
185
|
+
}
|
|
186
|
+
this.running = false;
|
|
187
|
+
await this.emitter.emit('event', {
|
|
188
|
+
code: 'END'
|
|
189
|
+
});
|
|
190
|
+
if (this.rerun) {
|
|
191
|
+
this.rerun = false;
|
|
192
|
+
this.invalidate();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
class Task {
|
|
197
|
+
constructor(watcher, options) {
|
|
198
|
+
this.cache = { modules: [] };
|
|
199
|
+
this.watchFiles = [];
|
|
200
|
+
this.closed = false;
|
|
201
|
+
this.invalidated = true;
|
|
202
|
+
this.watched = new Set();
|
|
203
|
+
this.watcher = watcher;
|
|
204
|
+
this.options = options;
|
|
205
|
+
this.skipWrite = Boolean(options.watch && options.watch.skipWrite);
|
|
206
|
+
this.outputs = this.options.output;
|
|
207
|
+
this.outputFiles = this.outputs.map(output => {
|
|
208
|
+
if (output.file || output.dir)
|
|
209
|
+
return node_path.resolve(output.file || output.dir);
|
|
210
|
+
return undefined;
|
|
211
|
+
});
|
|
212
|
+
const watchOptions = this.options.watch || {};
|
|
213
|
+
this.filter = rollup.createFilter(watchOptions.include, watchOptions.exclude);
|
|
214
|
+
this.fileWatcher = new FileWatcher(this, {
|
|
215
|
+
...watchOptions.chokidar,
|
|
216
|
+
disableGlobbing: true,
|
|
217
|
+
ignoreInitial: true
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
close() {
|
|
221
|
+
this.closed = true;
|
|
222
|
+
this.fileWatcher.close();
|
|
223
|
+
}
|
|
224
|
+
invalidate(id, details) {
|
|
225
|
+
this.invalidated = true;
|
|
226
|
+
if (details.isTransformDependency) {
|
|
227
|
+
for (const module of this.cache.modules) {
|
|
228
|
+
if (!module.transformDependencies.includes(id))
|
|
229
|
+
continue;
|
|
230
|
+
// effective invalidation
|
|
231
|
+
module.originalCode = null;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
this.watcher.invalidate({ event: details.event, id });
|
|
235
|
+
}
|
|
236
|
+
async run() {
|
|
237
|
+
if (!this.invalidated)
|
|
238
|
+
return;
|
|
239
|
+
this.invalidated = false;
|
|
240
|
+
const options = {
|
|
241
|
+
...this.options,
|
|
242
|
+
cache: this.cache
|
|
243
|
+
};
|
|
244
|
+
const start = Date.now();
|
|
245
|
+
await this.watcher.emitter.emit('event', {
|
|
246
|
+
code: 'BUNDLE_START',
|
|
247
|
+
input: this.options.input,
|
|
248
|
+
output: this.outputFiles
|
|
249
|
+
});
|
|
250
|
+
let result = null;
|
|
251
|
+
try {
|
|
252
|
+
result = await rollup.rollupInternal(options, this.watcher.emitter);
|
|
253
|
+
if (this.closed) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
this.updateWatchedFiles(result);
|
|
257
|
+
this.skipWrite || (await Promise.all(this.outputs.map(output => result.write(output))));
|
|
258
|
+
await this.watcher.emitter.emit('event', {
|
|
259
|
+
code: 'BUNDLE_END',
|
|
260
|
+
duration: Date.now() - start,
|
|
261
|
+
input: this.options.input,
|
|
262
|
+
output: this.outputFiles,
|
|
263
|
+
result
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
if (!this.closed) {
|
|
268
|
+
if (Array.isArray(error.watchFiles)) {
|
|
269
|
+
for (const id of error.watchFiles) {
|
|
270
|
+
this.watchFile(id);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (error.id) {
|
|
274
|
+
this.cache.modules = this.cache.modules.filter(module => module.id !== error.id);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
await this.watcher.emitter.emit('event', {
|
|
278
|
+
code: 'ERROR',
|
|
279
|
+
error,
|
|
280
|
+
result
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
updateWatchedFiles(result) {
|
|
285
|
+
const previouslyWatched = this.watched;
|
|
286
|
+
this.watched = new Set();
|
|
287
|
+
this.watchFiles = result.watchFiles;
|
|
288
|
+
this.cache = result.cache;
|
|
289
|
+
for (const id of this.watchFiles) {
|
|
290
|
+
this.watchFile(id);
|
|
291
|
+
}
|
|
292
|
+
for (const module of this.cache.modules) {
|
|
293
|
+
for (const depId of module.transformDependencies) {
|
|
294
|
+
this.watchFile(depId, true);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
for (const id of previouslyWatched) {
|
|
298
|
+
if (!this.watched.has(id)) {
|
|
299
|
+
this.fileWatcher.unwatch(id);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
watchFile(id, isTransformDependency = false) {
|
|
304
|
+
if (!this.filter(id))
|
|
305
|
+
return;
|
|
306
|
+
this.watched.add(id);
|
|
307
|
+
if (this.outputFiles.includes(id)) {
|
|
308
|
+
throw new Error('Cannot import the generated bundle');
|
|
309
|
+
}
|
|
310
|
+
// this is necessary to ensure that any 'renamed' files
|
|
311
|
+
// continue to be watched following an error
|
|
312
|
+
this.fileWatcher.watch(id, isTransformDependency);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=watch.js.map
|
|
316
|
+
|
|
317
|
+
exports.Task = Task;
|
|
318
|
+
exports.Watcher = Watcher;
|
|
319
|
+
//# sourceMappingURL=watch.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollup",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-2",
|
|
4
4
|
"description": "Next-generation ES module bundler",
|
|
5
5
|
"main": "dist/rollup.js",
|
|
6
6
|
"module": "dist/es/rollup.js",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"build:copy-native": "shx mkdir -p dist && shx cp rollup.*.node dist/",
|
|
41
41
|
"dev": "vitepress dev docs",
|
|
42
42
|
"build:cjs": "rollup --config rollup.config.ts --configPlugin typescript --configTest",
|
|
43
|
-
"build:bootstrap": "shx mv dist dist-build && node dist-build/bin/rollup --config rollup.config.ts --configPlugin typescript &&
|
|
43
|
+
"build:bootstrap": "shx mv dist dist-build && node dist-build/bin/rollup --config rollup.config.ts --configPlugin typescript && shx rm -rf dist-build",
|
|
44
44
|
"build:docs": "vitepress build docs",
|
|
45
45
|
"preview:docs": "vitepress preview docs",
|
|
46
46
|
"ci:artifacts": "napi artifacts",
|
|
47
47
|
"ci:lint": "concurrently -c red,green,blue 'npm:lint:js:nofix' 'npm:lint:markdown:nofix' 'npm:lint:rust:nofix'",
|
|
48
|
-
"ci:test": "npm run build:cjs && npm run build:copy-native && npm run build:bootstrap && npm run test:
|
|
49
|
-
"ci:test:
|
|
50
|
-
"ci:coverage": "npm run build:cjs && npm run build:copy-native && npm run build:bootstrap && nyc --reporter lcovonly mocha",
|
|
48
|
+
"ci:test:only": "npm run build:cjs && npm run build:copy-native && npm run build:bootstrap && npm run build:copy-native && npm run test:only",
|
|
49
|
+
"ci:test:all": "npm run build:cjs && npm run build:copy-native && npm run build:bootstrap && npm run build:copy-native && concurrently --kill-others-on-fail -c green,blue,magenta 'npm:test:only' 'npm:test:typescript' 'npm:test:leak'",
|
|
50
|
+
"ci:coverage": "npm run build:cjs && npm run build:copy-native && npm run build:bootstrap && npm run build:copy-native && nyc --reporter lcovonly mocha",
|
|
51
51
|
"lint": "concurrently -c red,green,blue 'npm:lint:js' 'npm:lint:markdown' 'npm:lint:rust'",
|
|
52
52
|
"lint:js": "eslint . --fix --cache",
|
|
53
53
|
"lint:js:nofix": "eslint . --cache",
|
|
@@ -93,17 +93,17 @@
|
|
|
93
93
|
"homepage": "https://rollupjs.org/",
|
|
94
94
|
"optionalDependencies": {
|
|
95
95
|
"fsevents": "~2.3.2",
|
|
96
|
-
"@rollup/rollup-darwin-arm64": "4.0.0-
|
|
97
|
-
"@rollup/rollup-android-arm64": "4.0.0-
|
|
98
|
-
"@rollup/rollup-win32-arm64-msvc": "4.0.0-
|
|
99
|
-
"@rollup/rollup-linux-arm64-gnu": "4.0.0-
|
|
100
|
-
"@rollup/rollup-android-arm-eabi": "4.0.0-
|
|
101
|
-
"@rollup/rollup-linux-arm-gnueabihf": "4.0.0-
|
|
102
|
-
"@rollup/rollup-win32-ia32-msvc": "4.0.0-
|
|
103
|
-
"@rollup/rollup-darwin-x64": "4.0.0-
|
|
104
|
-
"@rollup/rollup-win32-x64-msvc": "4.0.0-
|
|
105
|
-
"@rollup/rollup-linux-x64-gnu": "4.0.0-
|
|
106
|
-
"@rollup/rollup-linux-x64-musl": "4.0.0-
|
|
96
|
+
"@rollup/rollup-darwin-arm64": "4.0.0-2",
|
|
97
|
+
"@rollup/rollup-android-arm64": "4.0.0-2",
|
|
98
|
+
"@rollup/rollup-win32-arm64-msvc": "4.0.0-2",
|
|
99
|
+
"@rollup/rollup-linux-arm64-gnu": "4.0.0-2",
|
|
100
|
+
"@rollup/rollup-android-arm-eabi": "4.0.0-2",
|
|
101
|
+
"@rollup/rollup-linux-arm-gnueabihf": "4.0.0-2",
|
|
102
|
+
"@rollup/rollup-win32-ia32-msvc": "4.0.0-2",
|
|
103
|
+
"@rollup/rollup-darwin-x64": "4.0.0-2",
|
|
104
|
+
"@rollup/rollup-win32-x64-msvc": "4.0.0-2",
|
|
105
|
+
"@rollup/rollup-linux-x64-gnu": "4.0.0-2",
|
|
106
|
+
"@rollup/rollup-linux-x64-musl": "4.0.0-2"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@codemirror/commands": "^6.2.4",
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
"dist/es/package.json"
|
|
199
199
|
],
|
|
200
200
|
"engines": {
|
|
201
|
-
"node": ">=
|
|
201
|
+
"node": ">=18.0.0",
|
|
202
202
|
"npm": ">=8.0.0"
|
|
203
203
|
},
|
|
204
204
|
"exports": {
|