rollup 4.0.0-1 → 4.0.0-12

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.
@@ -0,0 +1,317 @@
1
+ /*
2
+ @license
3
+ Rollup.js v4.0.0-12
4
+ Wed, 23 Aug 2023 14:39:48 GMT - commit b6eec18d711348e3b177ef58dc2836cdf75e0432
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.js');
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
+
87
+ const eventsRewrites = {
88
+ create: {
89
+ create: 'buggy',
90
+ delete: null,
91
+ update: 'create'
92
+ },
93
+ delete: {
94
+ create: 'update',
95
+ delete: 'buggy',
96
+ update: 'buggy'
97
+ },
98
+ update: {
99
+ create: 'buggy',
100
+ delete: 'delete',
101
+ update: 'update'
102
+ }
103
+ };
104
+ class Watcher {
105
+ constructor(optionsList, emitter) {
106
+ this.buildDelay = 0;
107
+ this.buildTimeout = null;
108
+ this.closed = false;
109
+ this.invalidatedIds = new Map();
110
+ this.rerun = false;
111
+ this.running = true;
112
+ this.emitter = emitter;
113
+ emitter.close = this.close.bind(this);
114
+ this.tasks = optionsList.map(options => new Task(this, options));
115
+ for (const { watch } of optionsList) {
116
+ if (watch && typeof watch.buildDelay === 'number') {
117
+ this.buildDelay = Math.max(this.buildDelay, watch.buildDelay);
118
+ }
119
+ }
120
+ process.nextTick(() => this.run());
121
+ }
122
+ async close() {
123
+ if (this.closed)
124
+ return;
125
+ this.closed = true;
126
+ if (this.buildTimeout)
127
+ clearTimeout(this.buildTimeout);
128
+ for (const task of this.tasks) {
129
+ task.close();
130
+ }
131
+ await this.emitter.emit('close');
132
+ this.emitter.removeAllListeners();
133
+ }
134
+ invalidate(file) {
135
+ if (file) {
136
+ const previousEvent = this.invalidatedIds.get(file.id);
137
+ const event = previousEvent ? eventsRewrites[previousEvent][file.event] : file.event;
138
+ if (event === 'buggy') {
139
+ //TODO: throws or warn? Currently just ignore, uses new event
140
+ this.invalidatedIds.set(file.id, file.event);
141
+ }
142
+ else if (event === null) {
143
+ this.invalidatedIds.delete(file.id);
144
+ }
145
+ else {
146
+ this.invalidatedIds.set(file.id, event);
147
+ }
148
+ }
149
+ if (this.running) {
150
+ this.rerun = true;
151
+ return;
152
+ }
153
+ if (this.buildTimeout)
154
+ clearTimeout(this.buildTimeout);
155
+ this.buildTimeout = setTimeout(async () => {
156
+ this.buildTimeout = null;
157
+ try {
158
+ await Promise.all([...this.invalidatedIds].map(([id, event]) => this.emitter.emit('change', id, { event })));
159
+ this.invalidatedIds.clear();
160
+ await this.emitter.emit('restart');
161
+ this.emitter.removeListenersForCurrentRun();
162
+ this.run();
163
+ }
164
+ catch (error) {
165
+ this.invalidatedIds.clear();
166
+ await this.emitter.emit('event', {
167
+ code: 'ERROR',
168
+ error,
169
+ result: null
170
+ });
171
+ await this.emitter.emit('event', {
172
+ code: 'END'
173
+ });
174
+ }
175
+ }, this.buildDelay);
176
+ }
177
+ async run() {
178
+ this.running = true;
179
+ await this.emitter.emit('event', {
180
+ code: 'START'
181
+ });
182
+ for (const task of this.tasks) {
183
+ await task.run();
184
+ }
185
+ this.running = false;
186
+ await this.emitter.emit('event', {
187
+ code: 'END'
188
+ });
189
+ if (this.rerun) {
190
+ this.rerun = false;
191
+ this.invalidate();
192
+ }
193
+ }
194
+ }
195
+ class Task {
196
+ constructor(watcher, options) {
197
+ this.cache = { modules: [] };
198
+ this.watchFiles = [];
199
+ this.closed = false;
200
+ this.invalidated = true;
201
+ this.watched = new Set();
202
+ this.watcher = watcher;
203
+ this.options = options;
204
+ this.skipWrite = Boolean(options.watch && options.watch.skipWrite);
205
+ this.outputs = this.options.output;
206
+ this.outputFiles = this.outputs.map(output => {
207
+ if (output.file || output.dir)
208
+ return node_path.resolve(output.file || output.dir);
209
+ return undefined;
210
+ });
211
+ const watchOptions = this.options.watch || {};
212
+ this.filter = rollup.createFilter(watchOptions.include, watchOptions.exclude);
213
+ this.fileWatcher = new FileWatcher(this, {
214
+ ...watchOptions.chokidar,
215
+ disableGlobbing: true,
216
+ ignoreInitial: true
217
+ });
218
+ }
219
+ close() {
220
+ this.closed = true;
221
+ this.fileWatcher.close();
222
+ }
223
+ invalidate(id, details) {
224
+ this.invalidated = true;
225
+ if (details.isTransformDependency) {
226
+ for (const module of this.cache.modules) {
227
+ if (!module.transformDependencies.includes(id))
228
+ continue;
229
+ // effective invalidation
230
+ module.originalCode = null;
231
+ }
232
+ }
233
+ this.watcher.invalidate({ event: details.event, id });
234
+ }
235
+ async run() {
236
+ if (!this.invalidated)
237
+ return;
238
+ this.invalidated = false;
239
+ const options = {
240
+ ...this.options,
241
+ cache: this.cache
242
+ };
243
+ const start = Date.now();
244
+ await this.watcher.emitter.emit('event', {
245
+ code: 'BUNDLE_START',
246
+ input: this.options.input,
247
+ output: this.outputFiles
248
+ });
249
+ let result = null;
250
+ try {
251
+ result = await rollup.rollupInternal(options, this.watcher.emitter);
252
+ if (this.closed) {
253
+ return;
254
+ }
255
+ this.updateWatchedFiles(result);
256
+ this.skipWrite || (await Promise.all(this.outputs.map(output => result.write(output))));
257
+ await this.watcher.emitter.emit('event', {
258
+ code: 'BUNDLE_END',
259
+ duration: Date.now() - start,
260
+ input: this.options.input,
261
+ output: this.outputFiles,
262
+ result
263
+ });
264
+ }
265
+ catch (error) {
266
+ if (!this.closed) {
267
+ if (Array.isArray(error.watchFiles)) {
268
+ for (const id of error.watchFiles) {
269
+ this.watchFile(id);
270
+ }
271
+ }
272
+ if (error.id) {
273
+ this.cache.modules = this.cache.modules.filter(module => module.id !== error.id);
274
+ }
275
+ }
276
+ await this.watcher.emitter.emit('event', {
277
+ code: 'ERROR',
278
+ error,
279
+ result
280
+ });
281
+ }
282
+ }
283
+ updateWatchedFiles(result) {
284
+ const previouslyWatched = this.watched;
285
+ this.watched = new Set();
286
+ this.watchFiles = result.watchFiles;
287
+ this.cache = result.cache;
288
+ for (const id of this.watchFiles) {
289
+ this.watchFile(id);
290
+ }
291
+ for (const module of this.cache.modules) {
292
+ for (const depId of module.transformDependencies) {
293
+ this.watchFile(depId, true);
294
+ }
295
+ }
296
+ for (const id of previouslyWatched) {
297
+ if (!this.watched.has(id)) {
298
+ this.fileWatcher.unwatch(id);
299
+ }
300
+ }
301
+ }
302
+ watchFile(id, isTransformDependency = false) {
303
+ if (!this.filter(id))
304
+ return;
305
+ this.watched.add(id);
306
+ if (this.outputFiles.includes(id)) {
307
+ throw new Error('Cannot import the generated bundle');
308
+ }
309
+ // this is necessary to ensure that any 'renamed' files
310
+ // continue to be watched following an error
311
+ this.fileWatcher.watch(id, isTransformDependency);
312
+ }
313
+ }
314
+
315
+ exports.Task = Task;
316
+ exports.Watcher = Watcher;
317
+ //# sourceMappingURL=watch.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "4.0.0-1",
3
+ "version": "4.0.0-12",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -31,23 +31,25 @@
31
31
  }
32
32
  },
33
33
  "scripts": {
34
- "build": "concurrently -c green,blue 'npm run build:napi -- --release' 'npm:build:js' && npm run build:copy-native",
34
+ "build": "npm run build:wasm && concurrently -c green,blue 'npm run build:napi -- --release' 'npm:build:js' && npm run build:copy-native",
35
35
  "build:quick": "concurrently -c green,blue 'npm:build:napi' 'npm:build:cjs' && npm run build:copy-native",
36
36
  "build:napi": "napi build --platform --dts native.d.ts --js native.js --cargo-cwd rust -p bindings_napi --cargo-name bindings_napi",
37
+ "build:wasm": "wasm-pack build rust/bindings_wasm --out-dir ../../wasm --target web --no-pack && shx rm wasm/.gitignore",
38
+ "build:wasm:node": "wasm-pack build rust/bindings_wasm --out-dir ../../wasm-node --target nodejs --no-pack && shx rm wasm-node/.gitignore",
37
39
  "update:napi": "npm run build:napi && npm run build:copy-native",
38
40
  "build:js": "rollup --config rollup.config.ts --configPlugin typescript",
39
41
  "update:js": "npm run build:js && npm run build:copy-native",
40
42
  "build:copy-native": "shx mkdir -p dist && shx cp rollup.*.node dist/",
41
43
  "dev": "vitepress dev docs",
42
44
  "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 && npm run build:copy-native && shx rm -rf dist-build",
45
+ "build:bootstrap": "shx mv dist dist-build && node dist-build/bin/rollup --config rollup.config.ts --configPlugin typescript && shx rm -rf dist-build",
44
46
  "build:docs": "vitepress build docs",
45
47
  "preview:docs": "vitepress preview docs",
46
48
  "ci:artifacts": "napi artifacts",
47
49
  "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:all",
49
- "ci:test:only": "npm run build:cjs && npm run build:copy-native && npm run build:bootstrap && npm run test:only",
50
- "ci:coverage": "npm run build:cjs && npm run build:copy-native && npm run build:bootstrap && nyc --reporter lcovonly mocha",
50
+ "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",
51
+ "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,cyan 'npm:test:only' 'npm:test:typescript' 'npm:test:leak' 'npm:test:browser'",
52
+ "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
53
  "lint": "concurrently -c red,green,blue 'npm:lint:js' 'npm:lint:markdown' 'npm:lint:rust'",
52
54
  "lint:js": "eslint . --fix --cache",
53
55
  "lint:js:nofix": "eslint . --cache",
@@ -92,44 +94,44 @@
92
94
  },
93
95
  "homepage": "https://rollupjs.org/",
94
96
  "optionalDependencies": {
95
- "fsevents": "~2.3.2",
96
- "@rollup/rollup-darwin-arm64": "4.0.0-1",
97
- "@rollup/rollup-android-arm64": "4.0.0-1",
98
- "@rollup/rollup-win32-arm64-msvc": "4.0.0-1",
99
- "@rollup/rollup-linux-arm64-gnu": "4.0.0-1",
100
- "@rollup/rollup-android-arm-eabi": "4.0.0-1",
101
- "@rollup/rollup-linux-arm-gnueabihf": "4.0.0-1",
102
- "@rollup/rollup-win32-ia32-msvc": "4.0.0-1",
103
- "@rollup/rollup-darwin-x64": "4.0.0-1",
104
- "@rollup/rollup-win32-x64-msvc": "4.0.0-1",
105
- "@rollup/rollup-linux-x64-gnu": "4.0.0-1",
106
- "@rollup/rollup-linux-x64-musl": "4.0.0-1"
97
+ "@rollup/rollup-darwin-arm64": "4.0.0-12",
98
+ "@rollup/rollup-android-arm64": "4.0.0-12",
99
+ "@rollup/rollup-win32-arm64-msvc": "4.0.0-12",
100
+ "@rollup/rollup-linux-arm64-gnu": "4.0.0-12",
101
+ "@rollup/rollup-android-arm-eabi": "4.0.0-12",
102
+ "@rollup/rollup-linux-arm-gnueabihf": "4.0.0-12",
103
+ "@rollup/rollup-win32-ia32-msvc": "4.0.0-12",
104
+ "@rollup/rollup-darwin-x64": "4.0.0-12",
105
+ "@rollup/rollup-win32-x64-msvc": "4.0.0-12",
106
+ "@rollup/rollup-linux-x64-gnu": "4.0.0-12",
107
+ "@rollup/rollup-linux-x64-musl": "4.0.0-12"
107
108
  },
108
109
  "devDependencies": {
109
110
  "@codemirror/commands": "^6.2.4",
110
111
  "@codemirror/lang-javascript": "^6.1.9",
111
- "@codemirror/language": "^6.8.0",
112
- "@codemirror/search": "^6.5.0",
112
+ "@codemirror/language": "^6.9.0",
113
+ "@codemirror/search": "^6.5.1",
113
114
  "@codemirror/state": "^6.2.1",
114
- "@codemirror/view": "^6.14.1",
115
+ "@codemirror/view": "^6.16.0",
115
116
  "@jridgewell/sourcemap-codec": "^1.4.15",
116
- "@mermaid-js/mermaid-cli": "^10.2.4",
117
+ "@mermaid-js/mermaid-cli": "^10.3.1",
117
118
  "@napi-rs/cli": "^2.16.2",
118
119
  "@rollup/plugin-alias": "^5.0.0",
119
120
  "@rollup/plugin-buble": "^1.0.2",
120
- "@rollup/plugin-commonjs": "^25.0.3",
121
+ "@rollup/plugin-commonjs": "^25.0.4",
121
122
  "@rollup/plugin-json": "^6.0.0",
122
- "@rollup/plugin-node-resolve": "^15.1.0",
123
+ "@rollup/plugin-node-resolve": "^15.2.0",
123
124
  "@rollup/plugin-replace": "^5.0.2",
124
125
  "@rollup/plugin-terser": "^0.4.3",
125
126
  "@rollup/plugin-typescript": "^11.1.2",
126
- "@rollup/pluginutils": "^5.0.2",
127
+ "@rollup/plugin-wasm": "^6.1.3",
128
+ "@rollup/pluginutils": "^5.0.3",
127
129
  "@types/estree": "1.0.1",
128
130
  "@types/mocha": "^10.0.1",
129
- "@types/node": "~14.18.54",
131
+ "@types/node": "~18.17.5",
130
132
  "@types/yargs-parser": "^21.0.0",
131
- "@typescript-eslint/eslint-plugin": "^6.2.0",
132
- "@typescript-eslint/parser": "^6.2.0",
133
+ "@typescript-eslint/eslint-plugin": "^6.4.0",
134
+ "@typescript-eslint/parser": "^6.4.0",
133
135
  "@vue/eslint-config-prettier": "^8.0.0",
134
136
  "@vue/eslint-config-typescript": "^11.0.3",
135
137
  "acorn": "^8.10.0",
@@ -141,50 +143,51 @@
141
143
  "chokidar": "^3.5.3",
142
144
  "colorette": "^2.0.20",
143
145
  "concurrently": "^8.2.0",
144
- "core-js": "^3.31.1",
146
+ "core-js": "^3.32.1",
145
147
  "date-time": "^4.0.0",
146
148
  "es5-shim": "^4.6.7",
147
149
  "es6-shim": "^0.35.8",
148
- "eslint": "^8.45.0",
149
- "eslint-config-prettier": "^8.8.0",
150
- "eslint-plugin-import": "^2.27.5",
150
+ "eslint": "^8.47.0",
151
+ "eslint-config-prettier": "^9.0.0",
152
+ "eslint-plugin-import": "^2.28.1",
151
153
  "eslint-plugin-prettier": "^5.0.0",
152
- "eslint-plugin-unicorn": "^48.0.0",
153
- "eslint-plugin-vue": "^9.15.1",
154
+ "eslint-plugin-unicorn": "^48.0.1",
155
+ "eslint-plugin-vue": "^9.17.0",
154
156
  "fixturify": "^3.0.0",
155
157
  "flru": "^1.0.2",
156
158
  "fs-extra": "^11.1.1",
157
159
  "github-api": "^3.4.0",
158
160
  "hash.js": "^1.1.7",
159
161
  "husky": "^8.0.3",
160
- "inquirer": "^9.2.8",
162
+ "inquirer": "^9.2.10",
161
163
  "is-reference": "^3.0.1",
162
- "lint-staged": "^13.2.3",
164
+ "lint-staged": "^14.0.0",
163
165
  "locate-character": "^3.0.0",
164
- "magic-string": "^0.30.1",
166
+ "magic-string": "^0.30.2",
165
167
  "mocha": "^10.2.0",
166
168
  "nyc": "^15.1.0",
167
- "pinia": "^2.1.4",
168
- "prettier": "^3.0.0",
169
+ "pinia": "^2.1.6",
170
+ "prettier": "^3.0.2",
169
171
  "pretty-bytes": "^6.1.1",
170
172
  "pretty-ms": "^8.0.0",
171
173
  "requirejs": "^2.3.6",
172
- "rollup": "^3.26.3",
174
+ "rollup": "^3.28.1",
173
175
  "rollup-plugin-license": "^3.0.1",
174
176
  "rollup-plugin-string": "^3.0.0",
175
177
  "rollup-plugin-thatworks": "^1.0.4",
176
178
  "semver": "^7.5.4",
177
179
  "shx": "^0.3.4",
178
- "signal-exit": "^4.0.2",
180
+ "signal-exit": "^4.1.0",
179
181
  "source-map": "^0.7.4",
180
182
  "source-map-support": "^0.5.21",
181
- "systemjs": "^6.14.1",
183
+ "systemjs": "^6.14.2",
182
184
  "terser": "^5.19.2",
183
- "tslib": "^2.6.1",
185
+ "tslib": "^2.6.2",
184
186
  "typescript": "^5.1.6",
185
- "vite": "^4.4.7",
186
- "vitepress": "^1.0.0-beta.6",
187
+ "vite": "^4.4.9",
188
+ "vitepress": "^1.0.0-rc.4",
187
189
  "vue": "^3.3.4",
190
+ "wasm-pack": "^0.12.1",
188
191
  "weak-napi": "^2.0.2",
189
192
  "yargs-parser": "^21.1.1"
190
193
  },