@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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.63.3
4
- Mon, 14 Sep 2026 12:44:36 GMT - commit 250deca2945f8817350564f7d52bab0f79175d1b
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
 
@@ -15,7 +15,7 @@ const index = require('./index.js');
15
15
  const promises = require('node:fs/promises');
16
16
  const process$2 = require('node:process');
17
17
  const cli = require('../bin/rollup');
18
- const rollup_js = require('../rollup.js');
18
+ const rollup_js = require('./node-entry.js');
19
19
  const rollup = require('./rollup.js');
20
20
  const parseAst_js = require('./parseAst.js');
21
21
  const loadConfigFile_js = require('./loadConfigFile.js');
@@ -520,13 +520,22 @@ async function watch(command) {
520
520
  }
521
521
  function close(code) {
522
522
  process$2.removeListener('uncaughtException', closeWithError);
523
- // removing a non-existent listener is a no-op
524
- process$2.stdin.removeListener('end', close);
525
523
  if (configWatcher)
526
524
  configWatcher.close();
527
- Promise.resolve(watcher?.close()).finally(() => {
528
- process$2.exit(typeof code === 'number' ? code : 0);
529
- });
525
+ Promise.resolve(watcher?.close())
526
+ .finally(() => {
527
+ // The numeric branch is only evaluated while the process is already exiting,
528
+ // after coverage tools have written their counters.
529
+ /* istanbul ignore next */
530
+ const exitCode = typeof code === 'number' ? code : 0;
531
+ process$2.exitCode = exitCode;
532
+ // Calling process.exit directly can deadlock while V8 background tasks are
533
+ // still running, see https://github.com/nodejs/node/issues/54918. Letting the
534
+ // process exit naturally avoids this, but plugins may keep handles open.
535
+ // The ".unref()" ensures this handler does not block exit
536
+ setTimeout(() => process$2.exit(exitCode), 200).unref();
537
+ })
538
+ .catch(error => rollup.handleError(error, true));
530
539
  // Tell signal-exit that we are handling this gracefully
531
540
  return true;
532
541
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.63.3
4
- Mon, 14 Sep 2026 12:44:36 GMT - commit 250deca2945f8817350564f7d52bab0f79175d1b
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
 
@@ -16,6 +16,7 @@ const path = require('node:path');
16
16
  const process = require('node:process');
17
17
  const index = require('./index.js');
18
18
  const node_os = require('node:os');
19
+ const rollup_js = require('./node-entry.js');
19
20
  require('./parseAst.js');
20
21
  require('../native.js');
21
22
  require('path');
@@ -103,11 +104,12 @@ const eventsRewrites = {
103
104
  };
104
105
  class Watcher {
105
106
  constructor(optionsList, emitter) {
107
+ this.closed = false;
106
108
  this.buildDelay = 0;
107
109
  this.buildTimeout = null;
108
- this.closed = false;
109
110
  this.invalidatedIds = new Map();
110
111
  this.rerun = false;
112
+ // Starts held so that invalidations before the initial run only request a rerun.
111
113
  this.running = true;
112
114
  this.emitter = emitter;
113
115
  emitter.close = this.close.bind(this);
@@ -117,7 +119,7 @@ class Watcher {
117
119
  this.buildDelay = Math.max(this.buildDelay, watch.buildDelay);
118
120
  }
119
121
  }
120
- process.nextTick(() => this.run().catch(error => this.reportError(error)));
122
+ process.nextTick(() => this.runExclusively(() => this.run()));
121
123
  }
122
124
  async close() {
123
125
  if (this.closed)
@@ -125,13 +127,19 @@ class Watcher {
125
127
  this.closed = true;
126
128
  if (this.buildTimeout)
127
129
  clearTimeout(this.buildTimeout);
128
- for (const task of this.tasks) {
129
- task.close();
130
+ try {
131
+ await rollup_js.waitForAllAndRethrowFirstFailure([
132
+ ...this.tasks.map(task => task.close()),
133
+ this.emitter.emit('close')
134
+ ]);
135
+ }
136
+ finally {
137
+ this.emitter.removeAllListeners();
130
138
  }
131
- await this.emitter.emit('close');
132
- this.emitter.removeAllListeners();
133
139
  }
134
140
  invalidate(file) {
141
+ if (this.closed)
142
+ return;
135
143
  if (file) {
136
144
  const previousEvent = this.invalidatedIds.get(file.id);
137
145
  const event = previousEvent ? eventsRewrites[previousEvent][file.event] : file.event;
@@ -152,22 +160,64 @@ class Watcher {
152
160
  }
153
161
  if (this.buildTimeout)
154
162
  clearTimeout(this.buildTimeout);
155
- this.buildTimeout = setTimeout(async () => {
163
+ this.buildTimeout = setTimeout(() => {
156
164
  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
- await this.run();
163
- }
164
- catch (error) {
165
- await this.reportError(error);
166
- }
165
+ this.runExclusively(() => this.announceChangesAndRebuild());
167
166
  }, this.buildDelay);
168
167
  }
169
- async reportError(error) {
168
+ // The running flag spans the whole cycle, including async listeners, so
169
+ // that invalidations meanwhile only request a rerun.
170
+ async runExclusively(cycle) {
171
+ this.running = true;
172
+ try {
173
+ await cycle();
174
+ }
175
+ catch (error) {
176
+ await this.reportError(error);
177
+ }
178
+ finally {
179
+ this.running = false;
180
+ }
181
+ if (this.rerun) {
182
+ this.rerun = false;
183
+ this.invalidate();
184
+ }
185
+ }
186
+ async announceChangesAndRebuild() {
187
+ await this.announcePendingChanges();
188
+ if (this.closed || !this.hasInvalidatedTask())
189
+ return;
190
+ await this.emitter.emit('restart');
191
+ await this.announcePendingChanges();
192
+ if (this.closed)
193
+ return;
194
+ this.emitter.removeListenersForCurrentRun();
195
+ await this.run();
196
+ }
197
+ // The upcoming run consumes announced changes via the task flags, making
198
+ // their rerun requests obsolete. The reset must directly follow the last
199
+ // emptiness check so that no change slips through unannounced.
200
+ async announcePendingChanges() {
201
+ while (this.invalidatedIds.size > 0 && !this.closed) {
202
+ await this.announceChangeBatch();
203
+ }
204
+ this.rerun = false;
205
+ }
206
+ // Cleared before emitting so that changes arriving during slow hooks,
207
+ // including follow-ups of the same file, form the next batch instead of
208
+ // being dropped with this one.
209
+ async announceChangeBatch() {
210
+ const changes = [...this.invalidatedIds];
170
211
  this.invalidatedIds.clear();
212
+ await rollup_js.waitForAllAndRethrowFirstFailure(changes.flatMap(([id, event]) => [
213
+ ...this.tasks.map(task => task.announceChange(id, event)),
214
+ this.emitter.emit('change', id, { event })
215
+ ]));
216
+ }
217
+ hasInvalidatedTask() {
218
+ return this.tasks.some(task => task.isInvalidated());
219
+ }
220
+ async reportError(error) {
171
221
  await this.emitter.emit('event', {
172
222
  code: 'ERROR',
173
223
  error,
@@ -178,37 +228,26 @@ class Watcher {
178
228
  });
179
229
  }
180
230
  async run() {
181
- this.running = true;
182
- // Drop a rerun request left over from a failed run: honoring it after this run
183
- // would start an empty run that removes the plugin event listeners of this run.
184
- this.rerun = false;
185
- try {
186
- await this.emitter.emit('event', {
187
- code: 'START'
188
- });
189
- for (const task of this.tasks) {
190
- await task.run();
191
- }
192
- }
193
- finally {
194
- this.running = false;
231
+ await this.emitter.emit('event', {
232
+ code: 'START'
233
+ });
234
+ for (const task of this.tasks) {
235
+ await task.run();
195
236
  }
237
+ if (this.closed)
238
+ return;
196
239
  await this.emitter.emit('event', {
197
240
  code: 'END'
198
241
  });
199
- if (this.rerun) {
200
- this.rerun = false;
201
- this.invalidate();
202
- }
203
242
  }
204
243
  }
205
244
  class Task {
206
245
  constructor(watcher, options) {
207
246
  this.cache = { modules: [] };
208
247
  this.watchFiles = [];
209
- this.closed = false;
210
248
  this.invalidated = true;
211
249
  this.watched = new Set();
250
+ this.watchHooks = null;
212
251
  this.watcher = watcher;
213
252
  this.options = options;
214
253
  this.skipWrite = Boolean(options.watch && options.watch.skipWrite);
@@ -226,9 +265,14 @@ class Task {
226
265
  ignoreInitial: true
227
266
  });
228
267
  }
229
- close() {
230
- this.closed = true;
268
+ async announceChange(id, event) {
269
+ await this.watchHooks?.watchChange(id, { event });
270
+ }
271
+ async close() {
231
272
  this.fileWatcher.close();
273
+ const watchHooks = this.watchHooks;
274
+ this.watchHooks = null;
275
+ await watchHooks?.closeWatcher();
232
276
  }
233
277
  invalidate(id, details) {
234
278
  this.invalidated = true;
@@ -243,8 +287,11 @@ class Task {
243
287
  this.watcher.invalidate({ event: details.event, id });
244
288
  this.watchOptions.onInvalidate?.(id);
245
289
  }
290
+ isInvalidated() {
291
+ return this.invalidated;
292
+ }
246
293
  async run() {
247
- if (!this.invalidated)
294
+ if (!this.invalidated || this.watcher.closed)
248
295
  return;
249
296
  this.invalidated = false;
250
297
  const options = {
@@ -257,16 +304,22 @@ class Task {
257
304
  input: this.options.input,
258
305
  output: this.outputFiles
259
306
  });
307
+ if (this.watcher.closed) {
308
+ return;
309
+ }
260
310
  let result = null;
261
311
  try {
262
- result = await rollup.rollupInternal(options, this.watcher.emitter);
263
- if (this.closed) {
312
+ result = await rollup.rollupInternal(options, watchHooks => {
313
+ if (!this.watcher.closed)
314
+ this.watchHooks = watchHooks;
315
+ });
316
+ if (this.watcher.closed) {
264
317
  return;
265
318
  }
266
319
  this.updateWatchedFiles(result);
267
320
  if (!this.skipWrite) {
268
321
  await Promise.all(this.outputs.map(output => result.write(output)));
269
- if (this.closed) {
322
+ if (this.watcher.closed) {
270
323
  return;
271
324
  }
272
325
  this.updateWatchedFiles(result);
@@ -280,7 +333,7 @@ class Task {
280
333
  });
281
334
  }
282
335
  catch (error) {
283
- if (!this.closed) {
336
+ if (!this.watcher.closed) {
284
337
  if (Array.isArray(error.watchFiles)) {
285
338
  for (const id of error.watchFiles) {
286
339
  this.watchFile(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/wasm-node",
3
- "version": "4.63.3",
3
+ "version": "4.63.5",
4
4
  "description": "Next-generation ES module bundler with Node wasm",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -89,10 +89,10 @@
89
89
  "globals": "^17.12.0",
90
90
  "husky": "^9.1.7",
91
91
  "is-reference": "^3.0.3",
92
- "lint-staged": "^17.5.0",
92
+ "lint-staged": "^17.5.1",
93
93
  "locate-character": "^3.0.0",
94
- "magic-string": "^1.2.3",
95
- "memfs": "^4.71.0",
94
+ "magic-string": "^1.4.1",
95
+ "memfs": "^4.78.0",
96
96
  "mocha": "^11.8.0",
97
97
  "nodemon": "^3.1.14",
98
98
  "npm-audit-resolver": "^3.0.0-RC.0",
@@ -106,7 +106,7 @@
106
106
  "pretty-bytes": "^7.1.3",
107
107
  "pretty-ms": "^9.3.1",
108
108
  "requirejs": "^2.3.8",
109
- "rollup": "^4.63.1",
109
+ "rollup": "^4.63.3",
110
110
  "rollup-plugin-license": "^3.7.1",
111
111
  "semver": "^7.8.5",
112
112
  "shx": "^0.4.0",