rollup 3.21.0 → 3.21.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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.21.0
4
- Sun, 23 Apr 2023 19:43:51 GMT - commit b79b73cd8bb98c10ab7eedae154bb5c1e03ced7d
3
+ Rollup.js v3.21.2
4
+ Sun, 30 Apr 2023 05:31:29 GMT - commit f138dcee19367f17f2e66f940fb8d612471f7ddf
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -16,8 +16,6 @@ const process$2 = require('node:process');
16
16
  const index = require('./index.js');
17
17
  const cli = require('../bin/rollup');
18
18
  const rollup = require('./rollup.js');
19
- const require$$0 = require('assert');
20
- const require$$0$1 = require('events');
21
19
  const loadConfigFile_js = require('./loadConfigFile.js');
22
20
  const node_child_process = require('node:child_process');
23
21
  const watchProxy = require('./watch-proxy.js');
@@ -27,6 +25,7 @@ require('stream');
27
25
  require('path');
28
26
  require('os');
29
27
  require('./fsevents-importer.js');
28
+ require('events');
30
29
  require('node:path');
31
30
  require('tty');
32
31
  require('node:perf_hooks');
@@ -72,89 +71,47 @@ function dateTime(options = {}) {
72
71
  .replace(/\..+/, end);
73
72
  }
74
73
 
75
- var signalExitExports = {};
76
- var signalExit = {
77
- get exports(){ return signalExitExports; },
78
- set exports(v){ signalExitExports = v; },
79
- };
80
-
81
- var signalsExports = {};
82
- var signals$1 = {
83
- get exports(){ return signalsExports; },
84
- set exports(v){ signalsExports = v; },
85
- };
86
-
87
- var hasRequiredSignals;
88
-
89
- function requireSignals () {
90
- if (hasRequiredSignals) return signalsExports;
91
- hasRequiredSignals = 1;
92
- (function (module) {
93
- // This is not the set of all possible signals.
94
- //
95
- // It IS, however, the set of all signals that trigger
96
- // an exit on either Linux or BSD systems. Linux is a
97
- // superset of the signal names supported on BSD, and
98
- // the unknown signals just fail to register, so we can
99
- // catch that easily enough.
100
- //
101
- // Don't bother with SIGKILL. It's uncatchable, which
102
- // means that we can't fire any callbacks anyway.
103
- //
104
- // If a user does happen to register a handler on a non-
105
- // fatal signal like SIGWINCH or something, and then
106
- // exit, it'll end up firing `process.emit('exit')`, so
107
- // the handler will be fired anyway.
108
- //
109
- // SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
110
- // artificially, inherently leave the process in a
111
- // state from which it is not safe to try and enter JS
112
- // listeners.
113
- module.exports = [
114
- 'SIGABRT',
115
- 'SIGALRM',
116
- 'SIGHUP',
117
- 'SIGINT',
118
- 'SIGTERM'
119
- ];
120
-
121
- if (process.platform !== 'win32') {
122
- module.exports.push(
123
- 'SIGVTALRM',
124
- 'SIGXCPU',
125
- 'SIGXFSZ',
126
- 'SIGUSR2',
127
- 'SIGTRAP',
128
- 'SIGSYS',
129
- 'SIGQUIT',
130
- 'SIGIOT'
131
- // should detect profiler and enable/disable accordingly.
132
- // see #21
133
- // 'SIGPROF'
134
- );
135
- }
136
-
137
- if (process.platform === 'linux') {
138
- module.exports.push(
139
- 'SIGIO',
140
- 'SIGPOLL',
141
- 'SIGPWR',
142
- 'SIGSTKFLT',
143
- 'SIGUNUSED'
144
- );
145
- }
146
- } (signals$1));
147
- return signalsExports;
74
+ /**
75
+ * This is not the set of all possible signals.
76
+ *
77
+ * It IS, however, the set of all signals that trigger
78
+ * an exit on either Linux or BSD systems. Linux is a
79
+ * superset of the signal names supported on BSD, and
80
+ * the unknown signals just fail to register, so we can
81
+ * catch that easily enough.
82
+ *
83
+ * Windows signals are a different set, since there are
84
+ * signals that terminate Windows processes, but don't
85
+ * terminate (or don't even exist) on Posix systems.
86
+ *
87
+ * Don't bother with SIGKILL. It's uncatchable, which
88
+ * means that we can't fire any callbacks anyway.
89
+ *
90
+ * If a user does happen to register a handler on a non-
91
+ * fatal signal like SIGWINCH or something, and then
92
+ * exit, it'll end up firing `process.emit('exit')`, so
93
+ * the handler will be fired anyway.
94
+ *
95
+ * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
96
+ * artificially, inherently leave the process in a
97
+ * state from which it is not safe to try and enter JS
98
+ * listeners.
99
+ */
100
+ const signals = [];
101
+ signals.push('SIGHUP', 'SIGINT', 'SIGTERM');
102
+ if (process.platform !== 'win32') {
103
+ signals.push('SIGALRM', 'SIGABRT', 'SIGVTALRM', 'SIGXCPU', 'SIGXFSZ', 'SIGUSR2', 'SIGTRAP', 'SIGSYS', 'SIGQUIT', 'SIGIOT'
104
+ // should detect profiler and enable/disable accordingly.
105
+ // see #21
106
+ // 'SIGPROF'
107
+ );
108
+ }
109
+ if (process.platform === 'linux') {
110
+ signals.push('SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT');
148
111
  }
149
112
 
150
113
  // Note: since nyc uses this module to output coverage, any lines
151
- // that are in the direct sync flow of nyc's outputCoverage are
152
- // ignored, since we can never get coverage for them.
153
- // grab a reference to node's real process object right away
154
- var process$1 = rollup.commonjsGlobal.process;
155
-
156
- const processOk = function (process) {
157
- return process &&
114
+ const processOk = (process) => !!process &&
158
115
  typeof process === 'object' &&
159
116
  typeof process.removeListener === 'function' &&
160
117
  typeof process.emit === 'function' &&
@@ -162,193 +119,260 @@ const processOk = function (process) {
162
119
  typeof process.listeners === 'function' &&
163
120
  typeof process.kill === 'function' &&
164
121
  typeof process.pid === 'number' &&
165
- typeof process.on === 'function'
166
- };
167
-
168
- // some kind of non-node environment, just no-op
169
- /* istanbul ignore if */
170
- if (!processOk(process$1)) {
171
- signalExit.exports = function () {
172
- return function () {}
173
- };
174
- } else {
175
- var assert = require$$0;
176
- var signals = requireSignals();
177
- var isWin = /^win/i.test(process$1.platform);
178
-
179
- var EE = require$$0$1;
180
- /* istanbul ignore if */
181
- if (typeof EE !== 'function') {
182
- EE = EE.EventEmitter;
183
- }
184
-
185
- var emitter;
186
- if (process$1.__signal_exit_emitter__) {
187
- emitter = process$1.__signal_exit_emitter__;
188
- } else {
189
- emitter = process$1.__signal_exit_emitter__ = new EE();
190
- emitter.count = 0;
191
- emitter.emitted = {};
192
- }
193
-
194
- // Because this emitter is a global, we have to check to see if a
195
- // previous version of this library failed to enable infinite listeners.
196
- // I know what you're about to say. But literally everything about
197
- // signal-exit is a compromise with evil. Get used to it.
198
- if (!emitter.infinite) {
199
- emitter.setMaxListeners(Infinity);
200
- emitter.infinite = true;
201
- }
202
-
203
- signalExit.exports = function (cb, opts) {
204
- /* istanbul ignore if */
205
- if (!processOk(rollup.commonjsGlobal.process)) {
206
- return function () {}
122
+ typeof process.on === 'function';
123
+ const kExitEmitter = Symbol.for('signal-exit emitter');
124
+ const global = globalThis;
125
+ const ObjectDefineProperty = Object.defineProperty.bind(Object);
126
+ // teeny tiny ee
127
+ class Emitter {
128
+ emitted = {
129
+ afterExit: false,
130
+ exit: false,
131
+ };
132
+ listeners = {
133
+ afterExit: [],
134
+ exit: [],
135
+ };
136
+ count = 0;
137
+ id = Math.random();
138
+ constructor() {
139
+ if (global[kExitEmitter]) {
140
+ console.error('reusing global emitter');
141
+ return global[kExitEmitter];
142
+ }
143
+ ObjectDefineProperty(global, kExitEmitter, {
144
+ value: this,
145
+ writable: false,
146
+ enumerable: false,
147
+ configurable: false,
148
+ });
207
149
  }
208
- assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
209
-
210
- if (loaded === false) {
211
- load();
150
+ on(ev, fn) {
151
+ this.listeners[ev].push(fn);
212
152
  }
213
-
214
- var ev = 'exit';
215
- if (opts && opts.alwaysLast) {
216
- ev = 'afterexit';
153
+ removeListener(ev, fn) {
154
+ const list = this.listeners[ev];
155
+ const i = list.indexOf(fn);
156
+ /* c8 ignore start */
157
+ if (i === -1) {
158
+ return;
159
+ }
160
+ /* c8 ignore stop */
161
+ if (i === 0 && list.length === 1) {
162
+ list.length = 0;
163
+ }
164
+ else {
165
+ list.splice(i, 1);
166
+ }
217
167
  }
218
-
219
- var remove = function () {
220
- emitter.removeListener(ev, cb);
221
- if (emitter.listeners('exit').length === 0 &&
222
- emitter.listeners('afterexit').length === 0) {
223
- unload();
224
- }
168
+ emit(ev, code, signal) {
169
+ if (this.emitted[ev]) {
170
+ return;
171
+ }
172
+ this.emitted[ev] = true;
173
+ for (const fn of this.listeners[ev]) {
174
+ fn(code, signal);
175
+ }
176
+ }
177
+ }
178
+ class SignalExitBase {
179
+ }
180
+ const signalExitWrap = (handler) => {
181
+ return {
182
+ onExit(cb, opts) {
183
+ return handler.onExit(cb, opts);
184
+ },
185
+ load() {
186
+ return handler.load();
187
+ },
188
+ unload() {
189
+ return handler.unload();
190
+ },
225
191
  };
226
- emitter.on(ev, cb);
227
-
228
- return remove
229
- };
230
-
231
- var unload = function unload () {
232
- if (!loaded || !processOk(rollup.commonjsGlobal.process)) {
233
- return
192
+ };
193
+ class SignalExitFallback extends SignalExitBase {
194
+ onExit() {
195
+ return () => { };
234
196
  }
235
- loaded = false;
236
-
237
- signals.forEach(function (sig) {
238
- try {
239
- process$1.removeListener(sig, sigListeners[sig]);
240
- } catch (er) {}
241
- });
242
- process$1.emit = originalProcessEmit;
243
- process$1.reallyExit = originalProcessReallyExit;
244
- emitter.count -= 1;
245
- };
246
- signalExitExports.unload = unload;
247
-
248
- var emit = function emit (event, code, signal) {
249
- /* istanbul ignore if */
250
- if (emitter.emitted[event]) {
251
- return
197
+ load() { }
198
+ unload() { }
199
+ }
200
+ class SignalExit extends SignalExitBase {
201
+ // "SIGHUP" throws an `ENOSYS` error on Windows,
202
+ // so use a supported signal instead
203
+ /* c8 ignore start */
204
+ #hupSig = process$1.platform === 'win32' ? 'SIGINT' : 'SIGHUP';
205
+ /* c8 ignore stop */
206
+ #emitter = new Emitter();
207
+ #process;
208
+ #originalProcessEmit;
209
+ #originalProcessReallyExit;
210
+ #sigListeners = {};
211
+ #loaded = false;
212
+ constructor(process) {
213
+ super();
214
+ this.#process = process;
215
+ // { <signal>: <listener fn>, ... }
216
+ this.#sigListeners = {};
217
+ for (const sig of signals) {
218
+ this.#sigListeners[sig] = () => {
219
+ // If there are no other listeners, an exit is coming!
220
+ // Simplest way: remove us and then re-send the signal.
221
+ // We know that this will kill the process, so we can
222
+ // safely emit now.
223
+ const listeners = this.#process.listeners(sig);
224
+ let { count } = this.#emitter;
225
+ // This is a workaround for the fact that signal-exit v3 and signal
226
+ // exit v4 are not aware of each other, and each will attempt to let
227
+ // the other handle it, so neither of them do. To correct this, we
228
+ // detect if we're the only handler *except* for previous versions
229
+ // of signal-exit.
230
+ /* c8 ignore start */
231
+ //@ts-ignore
232
+ if (typeof process.__signal_exit_emitter__ === 'object')
233
+ count++;
234
+ /* c8 ignore stop */
235
+ if (listeners.length === count) {
236
+ this.unload();
237
+ this.#emitter.emit('exit', null, sig);
238
+ this.#emitter.emit('afterExit', null, sig);
239
+ /* c8 ignore start */
240
+ process.kill(process.pid, sig === 'SIGHUP' ? this.#hupSig : sig);
241
+ /* c8 ignore stop */
242
+ }
243
+ };
244
+ }
245
+ this.#originalProcessReallyExit = process.reallyExit;
246
+ this.#originalProcessEmit = process.emit;
252
247
  }
253
- emitter.emitted[event] = true;
254
- emitter.emit(event, code, signal);
255
- };
256
-
257
- // { <signal>: <listener fn>, ... }
258
- var sigListeners = {};
259
- signals.forEach(function (sig) {
260
- sigListeners[sig] = function listener () {
261
- /* istanbul ignore if */
262
- if (!processOk(rollup.commonjsGlobal.process)) {
263
- return
264
- }
265
- // If there are no other listeners, an exit is coming!
266
- // Simplest way: remove us and then re-send the signal.
267
- // We know that this will kill the process, so we can
268
- // safely emit now.
269
- var listeners = process$1.listeners(sig);
270
- if (listeners.length === emitter.count) {
271
- unload();
272
- emit('exit', null, sig);
273
- /* istanbul ignore next */
274
- emit('afterexit', null, sig);
275
- /* istanbul ignore next */
276
- if (isWin && sig === 'SIGHUP') {
277
- // "SIGHUP" throws an `ENOSYS` error on Windows,
278
- // so use a supported signal instead
279
- sig = 'SIGINT';
248
+ onExit(cb, opts) {
249
+ /* c8 ignore start */
250
+ if (!processOk(this.#process)) {
251
+ return () => { };
280
252
  }
281
- /* istanbul ignore next */
282
- process$1.kill(process$1.pid, sig);
283
- }
284
- };
285
- });
286
-
287
- signalExitExports.signals = function () {
288
- return signals
289
- };
290
-
291
- var loaded = false;
292
-
293
- var load = function load () {
294
- if (loaded || !processOk(rollup.commonjsGlobal.process)) {
295
- return
253
+ /* c8 ignore stop */
254
+ if (this.#loaded === false) {
255
+ this.load();
256
+ }
257
+ const ev = opts?.alwaysLast ? 'afterExit' : 'exit';
258
+ this.#emitter.on(ev, cb);
259
+ return () => {
260
+ this.#emitter.removeListener(ev, cb);
261
+ if (this.#emitter.listeners['exit'].length === 0 &&
262
+ this.#emitter.listeners['afterExit'].length === 0) {
263
+ this.unload();
264
+ }
265
+ };
296
266
  }
297
- loaded = true;
298
-
299
- // This is the number of onSignalExit's that are in play.
300
- // It's important so that we can count the correct number of
301
- // listeners on signals, and don't wait for the other one to
302
- // handle it instead of us.
303
- emitter.count += 1;
304
-
305
- signals = signals.filter(function (sig) {
306
- try {
307
- process$1.on(sig, sigListeners[sig]);
308
- return true
309
- } catch (er) {
310
- return false
311
- }
312
- });
313
-
314
- process$1.emit = processEmit;
315
- process$1.reallyExit = processReallyExit;
316
- };
317
- signalExitExports.load = load;
318
-
319
- var originalProcessReallyExit = process$1.reallyExit;
320
- var processReallyExit = function processReallyExit (code) {
321
- /* istanbul ignore if */
322
- if (!processOk(rollup.commonjsGlobal.process)) {
323
- return
267
+ load() {
268
+ if (this.#loaded) {
269
+ return;
270
+ }
271
+ this.#loaded = true;
272
+ // This is the number of onSignalExit's that are in play.
273
+ // It's important so that we can count the correct number of
274
+ // listeners on signals, and don't wait for the other one to
275
+ // handle it instead of us.
276
+ this.#emitter.count += 1;
277
+ for (const sig of signals) {
278
+ try {
279
+ const fn = this.#sigListeners[sig];
280
+ if (fn)
281
+ this.#process.on(sig, fn);
282
+ }
283
+ catch (_) { }
284
+ }
285
+ this.#process.emit = (ev, ...a) => {
286
+ return this.#processEmit(ev, ...a);
287
+ };
288
+ this.#process.reallyExit = (code) => {
289
+ return this.#processReallyExit(code);
290
+ };
324
291
  }
325
- process$1.exitCode = code || /* istanbul ignore next */ 0;
326
- emit('exit', process$1.exitCode, null);
327
- /* istanbul ignore next */
328
- emit('afterexit', process$1.exitCode, null);
329
- /* istanbul ignore next */
330
- originalProcessReallyExit.call(process$1, process$1.exitCode);
331
- };
332
-
333
- var originalProcessEmit = process$1.emit;
334
- var processEmit = function processEmit (ev, arg) {
335
- if (ev === 'exit' && processOk(rollup.commonjsGlobal.process)) {
336
- /* istanbul ignore else */
337
- if (arg !== undefined) {
338
- process$1.exitCode = arg;
339
- }
340
- var ret = originalProcessEmit.apply(this, arguments);
341
- /* istanbul ignore next */
342
- emit('exit', process$1.exitCode, null);
343
- /* istanbul ignore next */
344
- emit('afterexit', process$1.exitCode, null);
345
- /* istanbul ignore next */
346
- return ret
347
- } else {
348
- return originalProcessEmit.apply(this, arguments)
292
+ unload() {
293
+ if (!this.#loaded) {
294
+ return;
295
+ }
296
+ this.#loaded = false;
297
+ signals.forEach(sig => {
298
+ const listener = this.#sigListeners[sig];
299
+ /* c8 ignore start */
300
+ if (!listener) {
301
+ throw new Error('Listener not defined for signal: ' + sig);
302
+ }
303
+ /* c8 ignore stop */
304
+ try {
305
+ this.#process.removeListener(sig, listener);
306
+ /* c8 ignore start */
307
+ }
308
+ catch (_) { }
309
+ /* c8 ignore stop */
310
+ });
311
+ this.#process.emit = this.#originalProcessEmit;
312
+ this.#process.reallyExit = this.#originalProcessReallyExit;
313
+ this.#emitter.count -= 1;
314
+ }
315
+ #processReallyExit(code) {
316
+ /* c8 ignore start */
317
+ if (!processOk(this.#process)) {
318
+ return 0;
319
+ }
320
+ this.#process.exitCode = code || 0;
321
+ /* c8 ignore stop */
322
+ this.#emitter.emit('exit', this.#process.exitCode, null);
323
+ this.#emitter.emit('afterExit', this.#process.exitCode, null);
324
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
325
+ }
326
+ #processEmit(ev, ...args) {
327
+ const og = this.#originalProcessEmit;
328
+ if (ev === 'exit' && processOk(this.#process)) {
329
+ if (typeof args[0] === 'number') {
330
+ this.#process.exitCode = args[0];
331
+ /* c8 ignore start */
332
+ }
333
+ /* c8 ignore start */
334
+ const ret = og.call(this.#process, ev, ...args);
335
+ /* c8 ignore start */
336
+ this.#emitter.emit('exit', this.#process.exitCode, null);
337
+ this.#emitter.emit('afterExit', this.#process.exitCode, null);
338
+ /* c8 ignore stop */
339
+ return ret;
340
+ }
341
+ else {
342
+ return og.call(this.#process, ev, ...args);
343
+ }
349
344
  }
350
- };
351
345
  }
346
+ const process$1 = globalThis.process;
347
+ // wrap so that we call the method on the actual handler, without
348
+ // exporting it directly.
349
+ const {
350
+ /**
351
+ * Called when the process is exiting, whether via signal, explicit
352
+ * exit, or running out of stuff to do.
353
+ *
354
+ * If the global process object is not suitable for instrumentation,
355
+ * then this will be a no-op.
356
+ *
357
+ * Returns a function that may be used to unload signal-exit.
358
+ */
359
+ onExit,
360
+ /**
361
+ * Load the listeners. Likely you never need to call this, unless
362
+ * doing a rather deep integration with signal-exit functionality.
363
+ * Mostly exposed for the benefit of testing.
364
+ *
365
+ * @internal
366
+ */
367
+ load,
368
+ /**
369
+ * Unload the listeners. Likely you never need to call this, unless
370
+ * doing a rather deep integration with signal-exit functionality.
371
+ * Mostly exposed for the benefit of testing.
372
+ *
373
+ * @internal
374
+ */
375
+ unload, } = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
352
376
 
353
377
  const CLEAR_SCREEN = '\u001Bc';
354
378
  function getResetScreen(configs, allowClearScreen) {
@@ -406,7 +430,7 @@ async function watch(command) {
406
430
  let resetScreen;
407
431
  const configFile = command.config ? await cli.getConfigPath(command.config) : null;
408
432
  const runWatchHook = createWatchHooks(command);
409
- signalExitExports(close);
433
+ onExit(close);
410
434
  process$2.on('uncaughtException', close);
411
435
  if (!process$2.stdin.isTTY) {
412
436
  process$2.stdin.on('end', close);
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.21.0
4
- Sun, 23 Apr 2023 19:43:51 GMT - commit b79b73cd8bb98c10ab7eedae154bb5c1e03ced7d
3
+ Rollup.js v3.21.2
4
+ Sun, 30 Apr 2023 05:31:29 GMT - commit f138dcee19367f17f2e66f940fb8d612471f7ddf
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.21.0
4
- Sun, 23 Apr 2023 19:43:51 GMT - commit b79b73cd8bb98c10ab7eedae154bb5c1e03ced7d
3
+ Rollup.js v3.21.2
4
+ Sun, 30 Apr 2023 05:31:29 GMT - commit f138dcee19367f17f2e66f940fb8d612471f7ddf
5
5
 
6
6
  https://github.com/rollup/rollup
7
7