rollup 4.63.4 → 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.4
4
- Sat, 19 Sep 2026 06:35:38 GMT - commit ba78d5752a1e1ff4ff4af3a8bffab7691d822f7d
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",
3
- "version": "4.63.4",
3
+ "version": "4.63.5",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -117,31 +117,31 @@
117
117
  "optionalDependencies": {
118
118
  "@napi-rs/lzma-linux-x64-gnu": "1.5.1",
119
119
  "fsevents": "~2.3.2",
120
- "@rollup/rollup-darwin-arm64": "4.63.4",
121
- "@rollup/rollup-android-arm64": "4.63.4",
122
- "@rollup/rollup-win32-arm64-msvc": "4.63.4",
123
- "@rollup/rollup-freebsd-arm64": "4.63.4",
124
- "@rollup/rollup-linux-arm64-gnu": "4.63.4",
125
- "@rollup/rollup-linux-arm64-musl": "4.63.4",
126
- "@rollup/rollup-android-arm-eabi": "4.63.4",
127
- "@rollup/rollup-linux-arm-gnueabihf": "4.63.4",
128
- "@rollup/rollup-linux-arm-musleabihf": "4.63.4",
129
- "@rollup/rollup-win32-ia32-msvc": "4.63.4",
130
- "@rollup/rollup-linux-loong64-gnu": "4.63.4",
131
- "@rollup/rollup-linux-loong64-musl": "4.63.4",
132
- "@rollup/rollup-linux-riscv64-gnu": "4.63.4",
133
- "@rollup/rollup-linux-riscv64-musl": "4.63.4",
134
- "@rollup/rollup-linux-ppc64-gnu": "4.63.4",
135
- "@rollup/rollup-linux-ppc64-musl": "4.63.4",
136
- "@rollup/rollup-linux-s390x-gnu": "4.63.4",
137
- "@rollup/rollup-darwin-x64": "4.63.4",
138
- "@rollup/rollup-win32-x64-gnu": "4.63.4",
139
- "@rollup/rollup-win32-x64-msvc": "4.63.4",
140
- "@rollup/rollup-freebsd-x64": "4.63.4",
141
- "@rollup/rollup-linux-x64-gnu": "4.63.4",
142
- "@rollup/rollup-linux-x64-musl": "4.63.4",
143
- "@rollup/rollup-openbsd-x64": "4.63.4",
144
- "@rollup/rollup-openharmony-arm64": "4.63.4"
120
+ "@rollup/rollup-darwin-arm64": "4.63.5",
121
+ "@rollup/rollup-android-arm64": "4.63.5",
122
+ "@rollup/rollup-win32-arm64-msvc": "4.63.5",
123
+ "@rollup/rollup-freebsd-arm64": "4.63.5",
124
+ "@rollup/rollup-linux-arm64-gnu": "4.63.5",
125
+ "@rollup/rollup-linux-arm64-musl": "4.63.5",
126
+ "@rollup/rollup-android-arm-eabi": "4.63.5",
127
+ "@rollup/rollup-linux-arm-gnueabihf": "4.63.5",
128
+ "@rollup/rollup-linux-arm-musleabihf": "4.63.5",
129
+ "@rollup/rollup-win32-ia32-msvc": "4.63.5",
130
+ "@rollup/rollup-linux-loong64-gnu": "4.63.5",
131
+ "@rollup/rollup-linux-loong64-musl": "4.63.5",
132
+ "@rollup/rollup-linux-riscv64-gnu": "4.63.5",
133
+ "@rollup/rollup-linux-riscv64-musl": "4.63.5",
134
+ "@rollup/rollup-linux-ppc64-gnu": "4.63.5",
135
+ "@rollup/rollup-linux-ppc64-musl": "4.63.5",
136
+ "@rollup/rollup-linux-s390x-gnu": "4.63.5",
137
+ "@rollup/rollup-darwin-x64": "4.63.5",
138
+ "@rollup/rollup-win32-x64-gnu": "4.63.5",
139
+ "@rollup/rollup-win32-x64-msvc": "4.63.5",
140
+ "@rollup/rollup-freebsd-x64": "4.63.5",
141
+ "@rollup/rollup-linux-x64-gnu": "4.63.5",
142
+ "@rollup/rollup-linux-x64-musl": "4.63.5",
143
+ "@rollup/rollup-openbsd-x64": "4.63.5",
144
+ "@rollup/rollup-openharmony-arm64": "4.63.5"
145
145
  },
146
146
  "dependencies": {
147
147
  "@types/estree": "1.0.9"