rollup 2.57.0
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/CHANGELOG.md +5982 -0
- package/LICENSE.md +710 -0
- package/README.md +127 -0
- package/dist/bin/rollup +1783 -0
- package/dist/es/package.json +1 -0
- package/dist/es/rollup.browser.js +11 -0
- package/dist/es/rollup.js +15 -0
- package/dist/es/shared/rollup.js +23502 -0
- package/dist/es/shared/watch.js +4876 -0
- package/dist/loadConfigFile.js +26 -0
- package/dist/rollup.browser.js +12 -0
- package/dist/rollup.browser.js.map +1 -0
- package/dist/rollup.d.ts +909 -0
- package/dist/rollup.js +27 -0
- package/dist/shared/index.js +4457 -0
- package/dist/shared/loadConfigFile.js +596 -0
- package/dist/shared/mergeOptions.js +172 -0
- package/dist/shared/rollup.js +23539 -0
- package/dist/shared/watch-cli.js +455 -0
- package/dist/shared/watch.js +304 -0
- package/package.json +142 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
/*
|
|
2
|
+
@license
|
|
3
|
+
Rollup.js v2.57.0
|
|
4
|
+
Wed, 22 Sep 2021 04:43:07 GMT - commit b67ef301e8e44f9e0d9b144c0cce441e2a41c3da
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
https://github.com/rollup/rollup
|
|
8
|
+
|
|
9
|
+
Released under the MIT License.
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var fs = require('fs');
|
|
14
|
+
var index = require('./index.js');
|
|
15
|
+
var loadConfigFile_js = require('./loadConfigFile.js');
|
|
16
|
+
var cli = require('../bin/rollup');
|
|
17
|
+
var rollup = require('./rollup.js');
|
|
18
|
+
var require$$0 = require('assert');
|
|
19
|
+
var require$$0$1 = require('events');
|
|
20
|
+
require('path');
|
|
21
|
+
require('util');
|
|
22
|
+
require('stream');
|
|
23
|
+
require('os');
|
|
24
|
+
require('url');
|
|
25
|
+
require('tty');
|
|
26
|
+
require('./mergeOptions.js');
|
|
27
|
+
require('module');
|
|
28
|
+
require('crypto');
|
|
29
|
+
|
|
30
|
+
function timeZone(date = new Date()) {
|
|
31
|
+
const offset = date.getTimezoneOffset();
|
|
32
|
+
const absOffset = Math.abs(offset);
|
|
33
|
+
const hours = Math.floor(absOffset / 60);
|
|
34
|
+
const minutes = absOffset % 60;
|
|
35
|
+
const minutesOut = minutes > 0 ? ':' + ('0' + minutes).slice(-2) : '';
|
|
36
|
+
return (offset < 0 ? '+' : '-') + hours + minutesOut;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function dateTime(options = {}) {
|
|
40
|
+
let {
|
|
41
|
+
date = new Date(),
|
|
42
|
+
local = true,
|
|
43
|
+
showTimeZone = false,
|
|
44
|
+
showMilliseconds = false
|
|
45
|
+
} = options;
|
|
46
|
+
|
|
47
|
+
if (local) {
|
|
48
|
+
// Offset the date so it will return the correct value when getting the ISO string.
|
|
49
|
+
date = new Date(date.getTime() - (date.getTimezoneOffset() * 60000));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let end = '';
|
|
53
|
+
|
|
54
|
+
if (showTimeZone) {
|
|
55
|
+
end = ' UTC' + (local ? timeZone(date) : '');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (showMilliseconds && date.getUTCMilliseconds() > 0) {
|
|
59
|
+
end = ` ${date.getUTCMilliseconds()}ms${end}`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return date
|
|
63
|
+
.toISOString()
|
|
64
|
+
.replace(/T/, ' ')
|
|
65
|
+
.replace(/\..+/, end);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var signalExit = {exports: {}};
|
|
69
|
+
|
|
70
|
+
var signals$1 = {exports: {}};
|
|
71
|
+
|
|
72
|
+
(function (module) {
|
|
73
|
+
// This is not the set of all possible signals.
|
|
74
|
+
//
|
|
75
|
+
// It IS, however, the set of all signals that trigger
|
|
76
|
+
// an exit on either Linux or BSD systems. Linux is a
|
|
77
|
+
// superset of the signal names supported on BSD, and
|
|
78
|
+
// the unknown signals just fail to register, so we can
|
|
79
|
+
// catch that easily enough.
|
|
80
|
+
//
|
|
81
|
+
// Don't bother with SIGKILL. It's uncatchable, which
|
|
82
|
+
// means that we can't fire any callbacks anyway.
|
|
83
|
+
//
|
|
84
|
+
// If a user does happen to register a handler on a non-
|
|
85
|
+
// fatal signal like SIGWINCH or something, and then
|
|
86
|
+
// exit, it'll end up firing `process.emit('exit')`, so
|
|
87
|
+
// the handler will be fired anyway.
|
|
88
|
+
//
|
|
89
|
+
// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
|
|
90
|
+
// artificially, inherently leave the process in a
|
|
91
|
+
// state from which it is not safe to try and enter JS
|
|
92
|
+
// listeners.
|
|
93
|
+
module.exports = [
|
|
94
|
+
'SIGABRT',
|
|
95
|
+
'SIGALRM',
|
|
96
|
+
'SIGHUP',
|
|
97
|
+
'SIGINT',
|
|
98
|
+
'SIGTERM'
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
if (process.platform !== 'win32') {
|
|
102
|
+
module.exports.push(
|
|
103
|
+
'SIGVTALRM',
|
|
104
|
+
'SIGXCPU',
|
|
105
|
+
'SIGXFSZ',
|
|
106
|
+
'SIGUSR2',
|
|
107
|
+
'SIGTRAP',
|
|
108
|
+
'SIGSYS',
|
|
109
|
+
'SIGQUIT',
|
|
110
|
+
'SIGIOT'
|
|
111
|
+
// should detect profiler and enable/disable accordingly.
|
|
112
|
+
// see #21
|
|
113
|
+
// 'SIGPROF'
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (process.platform === 'linux') {
|
|
118
|
+
module.exports.push(
|
|
119
|
+
'SIGIO',
|
|
120
|
+
'SIGPOLL',
|
|
121
|
+
'SIGPWR',
|
|
122
|
+
'SIGSTKFLT',
|
|
123
|
+
'SIGUNUSED'
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}(signals$1));
|
|
127
|
+
|
|
128
|
+
// Note: since nyc uses this module to output coverage, any lines
|
|
129
|
+
// that are in the direct sync flow of nyc's outputCoverage are
|
|
130
|
+
// ignored, since we can never get coverage for them.
|
|
131
|
+
// grab a reference to node's real process object right away
|
|
132
|
+
var process$1 = rollup.commonjsGlobal.process;
|
|
133
|
+
// some kind of non-node environment, just no-op
|
|
134
|
+
if (typeof process$1 !== 'object' || !process$1) {
|
|
135
|
+
signalExit.exports = () => {};
|
|
136
|
+
} else {
|
|
137
|
+
var assert = require$$0;
|
|
138
|
+
var signals = signals$1.exports;
|
|
139
|
+
var isWin = /^win/i.test(process$1.platform);
|
|
140
|
+
|
|
141
|
+
var EE = require$$0$1;
|
|
142
|
+
/* istanbul ignore if */
|
|
143
|
+
if (typeof EE !== 'function') {
|
|
144
|
+
EE = EE.EventEmitter;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
var emitter;
|
|
148
|
+
if (process$1.__signal_exit_emitter__) {
|
|
149
|
+
emitter = process$1.__signal_exit_emitter__;
|
|
150
|
+
} else {
|
|
151
|
+
emitter = process$1.__signal_exit_emitter__ = new EE();
|
|
152
|
+
emitter.count = 0;
|
|
153
|
+
emitter.emitted = {};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Because this emitter is a global, we have to check to see if a
|
|
157
|
+
// previous version of this library failed to enable infinite listeners.
|
|
158
|
+
// I know what you're about to say. But literally everything about
|
|
159
|
+
// signal-exit is a compromise with evil. Get used to it.
|
|
160
|
+
if (!emitter.infinite) {
|
|
161
|
+
emitter.setMaxListeners(Infinity);
|
|
162
|
+
emitter.infinite = true;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
signalExit.exports = function (cb, opts) {
|
|
166
|
+
if (rollup.commonjsGlobal.process !== process$1) {
|
|
167
|
+
return
|
|
168
|
+
}
|
|
169
|
+
assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
|
|
170
|
+
|
|
171
|
+
if (loaded === false) {
|
|
172
|
+
load();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
var ev = 'exit';
|
|
176
|
+
if (opts && opts.alwaysLast) {
|
|
177
|
+
ev = 'afterexit';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
var remove = function () {
|
|
181
|
+
emitter.removeListener(ev, cb);
|
|
182
|
+
if (emitter.listeners('exit').length === 0 &&
|
|
183
|
+
emitter.listeners('afterexit').length === 0) {
|
|
184
|
+
unload();
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
emitter.on(ev, cb);
|
|
188
|
+
|
|
189
|
+
return remove
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
var unload = function unload () {
|
|
193
|
+
if (!loaded || rollup.commonjsGlobal.process !== process$1) {
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
loaded = false;
|
|
197
|
+
|
|
198
|
+
signals.forEach(function (sig) {
|
|
199
|
+
try {
|
|
200
|
+
process$1.removeListener(sig, sigListeners[sig]);
|
|
201
|
+
} catch (er) {}
|
|
202
|
+
});
|
|
203
|
+
process$1.emit = originalProcessEmit;
|
|
204
|
+
process$1.reallyExit = originalProcessReallyExit;
|
|
205
|
+
emitter.count -= 1;
|
|
206
|
+
};
|
|
207
|
+
signalExit.exports.unload = unload;
|
|
208
|
+
|
|
209
|
+
var emit = function emit (event, code, signal) {
|
|
210
|
+
if (emitter.emitted[event]) {
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
emitter.emitted[event] = true;
|
|
214
|
+
emitter.emit(event, code, signal);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// { <signal>: <listener fn>, ... }
|
|
218
|
+
var sigListeners = {};
|
|
219
|
+
signals.forEach(function (sig) {
|
|
220
|
+
sigListeners[sig] = function listener () {
|
|
221
|
+
if (process$1 !== rollup.commonjsGlobal.process) {
|
|
222
|
+
return
|
|
223
|
+
}
|
|
224
|
+
// If there are no other listeners, an exit is coming!
|
|
225
|
+
// Simplest way: remove us and then re-send the signal.
|
|
226
|
+
// We know that this will kill the process, so we can
|
|
227
|
+
// safely emit now.
|
|
228
|
+
var listeners = process$1.listeners(sig);
|
|
229
|
+
if (listeners.length === emitter.count) {
|
|
230
|
+
unload();
|
|
231
|
+
emit('exit', null, sig);
|
|
232
|
+
/* istanbul ignore next */
|
|
233
|
+
emit('afterexit', null, sig);
|
|
234
|
+
/* istanbul ignore next */
|
|
235
|
+
if (isWin && sig === 'SIGHUP') {
|
|
236
|
+
// "SIGHUP" throws an `ENOSYS` error on Windows,
|
|
237
|
+
// so use a supported signal instead
|
|
238
|
+
sig = 'SIGINT';
|
|
239
|
+
}
|
|
240
|
+
process$1.kill(process$1.pid, sig);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
signalExit.exports.signals = function () {
|
|
246
|
+
return signals
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
var loaded = false;
|
|
250
|
+
|
|
251
|
+
var load = function load () {
|
|
252
|
+
if (loaded || process$1 !== rollup.commonjsGlobal.process) {
|
|
253
|
+
return
|
|
254
|
+
}
|
|
255
|
+
loaded = true;
|
|
256
|
+
|
|
257
|
+
// This is the number of onSignalExit's that are in play.
|
|
258
|
+
// It's important so that we can count the correct number of
|
|
259
|
+
// listeners on signals, and don't wait for the other one to
|
|
260
|
+
// handle it instead of us.
|
|
261
|
+
emitter.count += 1;
|
|
262
|
+
|
|
263
|
+
signals = signals.filter(function (sig) {
|
|
264
|
+
try {
|
|
265
|
+
process$1.on(sig, sigListeners[sig]);
|
|
266
|
+
return true
|
|
267
|
+
} catch (er) {
|
|
268
|
+
return false
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
process$1.emit = processEmit;
|
|
273
|
+
process$1.reallyExit = processReallyExit;
|
|
274
|
+
};
|
|
275
|
+
signalExit.exports.load = load;
|
|
276
|
+
|
|
277
|
+
var originalProcessReallyExit = process$1.reallyExit;
|
|
278
|
+
var processReallyExit = function processReallyExit (code) {
|
|
279
|
+
if (process$1 !== rollup.commonjsGlobal.process) {
|
|
280
|
+
return
|
|
281
|
+
}
|
|
282
|
+
process$1.exitCode = code || 0;
|
|
283
|
+
emit('exit', process$1.exitCode, null);
|
|
284
|
+
/* istanbul ignore next */
|
|
285
|
+
emit('afterexit', process$1.exitCode, null);
|
|
286
|
+
/* istanbul ignore next */
|
|
287
|
+
originalProcessReallyExit.call(process$1, process$1.exitCode);
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
var originalProcessEmit = process$1.emit;
|
|
291
|
+
var processEmit = function processEmit (ev, arg) {
|
|
292
|
+
if (ev === 'exit' && process$1 === rollup.commonjsGlobal.process) {
|
|
293
|
+
if (arg !== undefined) {
|
|
294
|
+
process$1.exitCode = arg;
|
|
295
|
+
}
|
|
296
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
297
|
+
emit('exit', process$1.exitCode, null);
|
|
298
|
+
/* istanbul ignore next */
|
|
299
|
+
emit('afterexit', process$1.exitCode, null);
|
|
300
|
+
return ret
|
|
301
|
+
} else {
|
|
302
|
+
return originalProcessEmit.apply(this, arguments)
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
var onExit = signalExit.exports;
|
|
308
|
+
|
|
309
|
+
const CLEAR_SCREEN = '\u001Bc';
|
|
310
|
+
function getResetScreen(configs, allowClearScreen) {
|
|
311
|
+
let clearScreen = allowClearScreen;
|
|
312
|
+
for (const config of configs) {
|
|
313
|
+
if (config.watch && config.watch.clearScreen === false) {
|
|
314
|
+
clearScreen = false;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (clearScreen) {
|
|
318
|
+
return (heading) => loadConfigFile_js.stderr(CLEAR_SCREEN + heading);
|
|
319
|
+
}
|
|
320
|
+
let firstRun = true;
|
|
321
|
+
return (heading) => {
|
|
322
|
+
if (firstRun) {
|
|
323
|
+
loadConfigFile_js.stderr(heading);
|
|
324
|
+
firstRun = false;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
async function watch(command) {
|
|
330
|
+
process.env.ROLLUP_WATCH = 'true';
|
|
331
|
+
const isTTY = process.stderr.isTTY;
|
|
332
|
+
const silent = command.silent;
|
|
333
|
+
let configs;
|
|
334
|
+
let warnings;
|
|
335
|
+
let watcher;
|
|
336
|
+
let configWatcher;
|
|
337
|
+
const configFile = command.config ? cli.getConfigPath(command.config) : null;
|
|
338
|
+
onExit(close);
|
|
339
|
+
process.on('uncaughtException', close);
|
|
340
|
+
if (!process.stdin.isTTY) {
|
|
341
|
+
process.stdin.on('end', close);
|
|
342
|
+
process.stdin.resume();
|
|
343
|
+
}
|
|
344
|
+
async function loadConfigFromFileAndTrack(configFile) {
|
|
345
|
+
let reloadingConfig = false;
|
|
346
|
+
let aborted = false;
|
|
347
|
+
let configFileData = null;
|
|
348
|
+
configWatcher = index.chokidar.watch(configFile).on('change', () => reloadConfigFile());
|
|
349
|
+
await reloadConfigFile();
|
|
350
|
+
async function reloadConfigFile() {
|
|
351
|
+
try {
|
|
352
|
+
const newConfigFileData = fs.readFileSync(configFile, 'utf-8');
|
|
353
|
+
if (newConfigFileData === configFileData) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (reloadingConfig) {
|
|
357
|
+
aborted = true;
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (configFileData) {
|
|
361
|
+
loadConfigFile_js.stderr(`\nReloading updated config...`);
|
|
362
|
+
}
|
|
363
|
+
configFileData = newConfigFileData;
|
|
364
|
+
reloadingConfig = true;
|
|
365
|
+
({ options: configs, warnings } = await loadConfigFile_js.loadAndParseConfigFile(configFile, command));
|
|
366
|
+
reloadingConfig = false;
|
|
367
|
+
if (aborted) {
|
|
368
|
+
aborted = false;
|
|
369
|
+
reloadConfigFile();
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
if (watcher) {
|
|
373
|
+
watcher.close();
|
|
374
|
+
}
|
|
375
|
+
start(configs);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
catch (err) {
|
|
379
|
+
configs = [];
|
|
380
|
+
reloadingConfig = false;
|
|
381
|
+
loadConfigFile_js.handleError(err, true);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (configFile) {
|
|
386
|
+
await loadConfigFromFileAndTrack(configFile);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
({ options: configs, warnings } = await cli.loadConfigFromCommand(command));
|
|
390
|
+
start(configs);
|
|
391
|
+
}
|
|
392
|
+
const resetScreen = getResetScreen(configs, isTTY);
|
|
393
|
+
function start(configs) {
|
|
394
|
+
try {
|
|
395
|
+
watcher = rollup.watch(configs);
|
|
396
|
+
}
|
|
397
|
+
catch (err) {
|
|
398
|
+
return loadConfigFile_js.handleError(err);
|
|
399
|
+
}
|
|
400
|
+
watcher.on('event', event => {
|
|
401
|
+
switch (event.code) {
|
|
402
|
+
case 'ERROR':
|
|
403
|
+
warnings.flush();
|
|
404
|
+
loadConfigFile_js.handleError(event.error, true);
|
|
405
|
+
break;
|
|
406
|
+
case 'START':
|
|
407
|
+
if (!silent) {
|
|
408
|
+
resetScreen(loadConfigFile_js.underline(`rollup v${rollup.version}`));
|
|
409
|
+
}
|
|
410
|
+
break;
|
|
411
|
+
case 'BUNDLE_START':
|
|
412
|
+
if (!silent) {
|
|
413
|
+
let input = event.input;
|
|
414
|
+
if (typeof input !== 'string') {
|
|
415
|
+
input = Array.isArray(input)
|
|
416
|
+
? input.join(', ')
|
|
417
|
+
: Object.values(input).join(', ');
|
|
418
|
+
}
|
|
419
|
+
loadConfigFile_js.stderr(loadConfigFile_js.cyan(`bundles ${loadConfigFile_js.bold(input)} → ${loadConfigFile_js.bold(event.output.map(rollup.relativeId).join(', '))}...`));
|
|
420
|
+
}
|
|
421
|
+
break;
|
|
422
|
+
case 'BUNDLE_END':
|
|
423
|
+
warnings.flush();
|
|
424
|
+
if (!silent)
|
|
425
|
+
loadConfigFile_js.stderr(loadConfigFile_js.green(`created ${loadConfigFile_js.bold(event.output.map(rollup.relativeId).join(', '))} in ${loadConfigFile_js.bold(cli.ms(event.duration))}`));
|
|
426
|
+
if (event.result && event.result.getTimings) {
|
|
427
|
+
cli.printTimings(event.result.getTimings());
|
|
428
|
+
}
|
|
429
|
+
break;
|
|
430
|
+
case 'END':
|
|
431
|
+
if (!silent && isTTY) {
|
|
432
|
+
loadConfigFile_js.stderr(`\n[${dateTime()}] waiting for changes...`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
if ('result' in event && event.result) {
|
|
436
|
+
event.result.close().catch(error => loadConfigFile_js.handleError(error, true));
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
function close(code) {
|
|
441
|
+
process.removeListener('uncaughtException', close);
|
|
442
|
+
// removing a non-existent listener is a no-op
|
|
443
|
+
process.stdin.removeListener('end', close);
|
|
444
|
+
if (watcher)
|
|
445
|
+
watcher.close();
|
|
446
|
+
if (configWatcher)
|
|
447
|
+
configWatcher.close();
|
|
448
|
+
if (code) {
|
|
449
|
+
process.exit(code);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
exports.watch = watch;
|
|
455
|
+
//# sourceMappingURL=watch-cli.js.map
|