rollup 3.1.0 → 3.2.1

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.1.0
4
- Wed, 12 Oct 2022 08:54:50 GMT - commit f7b768992209a970c240799cdff12a4fa437c0d4
3
+ Rollup.js v3.2.1
4
+ Sun, 16 Oct 2022 04:44:52 GMT - commit 46e1eaaaf05e0c2efa0ed395d7a3cfa99ef25fb5
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -25,13 +25,12 @@ require('util');
25
25
  require('stream');
26
26
  require('path');
27
27
  require('os');
28
- require('./mergeOptions.js');
29
28
  require('node:path');
30
29
  require('node:perf_hooks');
31
30
  require('node:crypto');
32
31
  require('node:events');
33
- require('node:url');
34
32
  require('tty');
33
+ require('node:url');
35
34
 
36
35
  function timeZone(date = new Date()) {
37
36
  const offset = date.getTimezoneOffset();
@@ -350,12 +349,12 @@ function getResetScreen(configs, allowClearScreen) {
350
349
  }
351
350
  }
352
351
  if (clearScreen) {
353
- return (heading) => loadConfigFile_js.stderr(CLEAR_SCREEN + heading);
352
+ return (heading) => rollup.stderr(CLEAR_SCREEN + heading);
354
353
  }
355
354
  let firstRun = true;
356
355
  return (heading) => {
357
356
  if (firstRun) {
358
- loadConfigFile_js.stderr(heading);
357
+ rollup.stderr(heading);
359
358
  firstRun = false;
360
359
  }
361
360
  };
@@ -366,7 +365,7 @@ function extractWatchHooks(command) {
366
365
  return {};
367
366
  return command.watch
368
367
  .filter(value => typeof value === 'object')
369
- .reduce((acc, keyValueOption) => ({ ...acc, ...keyValueOption }), {});
368
+ .reduce((accumulator, keyValueOption) => ({ ...accumulator, ...keyValueOption }), {});
370
369
  }
371
370
  function createWatchHooks(command) {
372
371
  const watchHooks = extractWatchHooks(command);
@@ -374,15 +373,15 @@ function createWatchHooks(command) {
374
373
  if (watchHooks[hook]) {
375
374
  const cmd = watchHooks[hook];
376
375
  if (!command.silent) {
377
- loadConfigFile_js.stderr(loadConfigFile_js.cyan(`watch.${hook} ${loadConfigFile_js.bold(`$ ${cmd}`)}`));
376
+ rollup.stderr(rollup.cyan(`watch.${hook} ${rollup.bold(`$ ${cmd}`)}`));
378
377
  }
379
378
  try {
380
379
  // !! important - use stderr for all writes from execSync
381
380
  const stdio = [process.stdin, process.stderr, process.stderr];
382
381
  node_child_process.execSync(cmd, { stdio: command.silent ? 'ignore' : stdio });
383
382
  }
384
- catch (e) {
385
- loadConfigFile_js.stderr(e.message);
383
+ catch (error) {
384
+ rollup.stderr(error.message);
386
385
  }
387
386
  }
388
387
  };
@@ -417,7 +416,7 @@ async function watch(command) {
417
416
  configFileRevision++;
418
417
  const currentConfigFileRevision = configFileRevision;
419
418
  if (configFileData) {
420
- loadConfigFile_js.stderr(`\nReloading updated config...`);
419
+ rollup.stderr(`\nReloading updated config...`);
421
420
  }
422
421
  configFileData = newConfigFileData;
423
422
  const { options, warnings } = await loadConfigFile_js.loadConfigFile(configFile, command);
@@ -429,8 +428,8 @@ async function watch(command) {
429
428
  }
430
429
  start(options, warnings);
431
430
  }
432
- catch (err) {
433
- loadConfigFile_js.handleError(err, true);
431
+ catch (error) {
432
+ rollup.handleError(error, true);
434
433
  }
435
434
  }
436
435
  }
@@ -439,32 +438,29 @@ async function watch(command) {
439
438
  }
440
439
  else {
441
440
  const { options, warnings } = await cli.loadConfigFromCommand(command);
442
- start(options, warnings);
441
+ await start(options, warnings);
443
442
  }
444
- function start(configs, warnings) {
445
- try {
446
- watcher = rollup.watch(configs);
447
- }
448
- catch (err) {
449
- return loadConfigFile_js.handleError(err);
450
- }
443
+ async function start(configs, warnings) {
444
+ watcher = rollup.watch(configs);
451
445
  watcher.on('event', event => {
452
446
  switch (event.code) {
453
- case 'ERROR':
447
+ case 'ERROR': {
454
448
  warnings.flush();
455
- loadConfigFile_js.handleError(event.error, true);
449
+ rollup.handleError(event.error, true);
456
450
  runWatchHook('onError');
457
451
  break;
458
- case 'START':
452
+ }
453
+ case 'START': {
459
454
  if (!silent) {
460
455
  if (!resetScreen) {
461
456
  resetScreen = getResetScreen(configs, isTTY);
462
457
  }
463
- resetScreen(loadConfigFile_js.underline(`rollup v${rollup.version}`));
458
+ resetScreen(rollup.underline(`rollup v${rollup.version}`));
464
459
  }
465
460
  runWatchHook('onStart');
466
461
  break;
467
- case 'BUNDLE_START':
462
+ }
463
+ case 'BUNDLE_START': {
468
464
  if (!silent) {
469
465
  let input = event.input;
470
466
  if (typeof input !== 'string') {
@@ -472,27 +468,30 @@ async function watch(command) {
472
468
  ? input.join(', ')
473
469
  : Object.values(input).join(', ');
474
470
  }
475
- loadConfigFile_js.stderr(loadConfigFile_js.cyan(`bundles ${loadConfigFile_js.bold(input)} → ${loadConfigFile_js.bold(event.output.map(rollup.relativeId).join(', '))}...`));
471
+ rollup.stderr(rollup.cyan(`bundles ${rollup.bold(input)} → ${rollup.bold(event.output.map(rollup.relativeId).join(', '))}...`));
476
472
  }
477
473
  runWatchHook('onBundleStart');
478
474
  break;
479
- case 'BUNDLE_END':
475
+ }
476
+ case 'BUNDLE_END': {
480
477
  warnings.flush();
481
478
  if (!silent)
482
- loadConfigFile_js.stderr(loadConfigFile_js.green(`created ${loadConfigFile_js.bold(event.output.map(rollup.relativeId).join(', '))} in ${loadConfigFile_js.bold(cli.prettyMilliseconds(event.duration))}`));
479
+ rollup.stderr(rollup.green(`created ${rollup.bold(event.output.map(rollup.relativeId).join(', '))} in ${rollup.bold(cli.prettyMilliseconds(event.duration))}`));
483
480
  runWatchHook('onBundleEnd');
484
481
  if (event.result && event.result.getTimings) {
485
482
  cli.printTimings(event.result.getTimings());
486
483
  }
487
484
  break;
488
- case 'END':
485
+ }
486
+ case 'END': {
489
487
  runWatchHook('onEnd');
490
488
  if (!silent && isTTY) {
491
- loadConfigFile_js.stderr(`\n[${dateTime()}] waiting for changes...`);
489
+ rollup.stderr(`\n[${dateTime()}] waiting for changes...`);
492
490
  }
491
+ }
493
492
  }
494
493
  if ('result' in event && event.result) {
495
- event.result.close().catch(error => loadConfigFile_js.handleError(error, true));
494
+ event.result.close().catch(error => rollup.handleError(error, true));
496
495
  }
497
496
  });
498
497
  }
@@ -505,6 +504,7 @@ async function watch(command) {
505
504
  if (configWatcher)
506
505
  configWatcher.close();
507
506
  if (code) {
507
+ // eslint-disable-next-line unicorn/no-process-exit
508
508
  process$2.exit(code);
509
509
  }
510
510
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.1.0
4
- Wed, 12 Oct 2022 08:54:50 GMT - commit f7b768992209a970c240799cdff12a4fa437c0d4
3
+ Rollup.js v3.2.1
4
+ Sun, 16 Oct 2022 04:44:52 GMT - commit 46e1eaaaf05e0c2efa0ed395d7a3cfa99ef25fb5
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -14,7 +14,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
14
14
  const node_path = require('node:path');
15
15
  const process = require('node:process');
16
16
  const rollup = require('./rollup.js');
17
- const mergeOptions = require('./mergeOptions.js');
18
17
  const node_os = require('node:os');
19
18
  const index = require('./index.js');
20
19
  require('path');
@@ -22,6 +21,7 @@ require('node:perf_hooks');
22
21
  require('node:crypto');
23
22
  require('node:fs');
24
23
  require('node:events');
24
+ require('tty');
25
25
  require('fs');
26
26
  require('util');
27
27
  require('stream');
@@ -101,7 +101,7 @@ const eventsRewrites = {
101
101
  }
102
102
  };
103
103
  class Watcher {
104
- constructor(configs, emitter) {
104
+ constructor(optionsList, emitter) {
105
105
  this.buildDelay = 0;
106
106
  this.buildTimeout = null;
107
107
  this.closed = false;
@@ -110,10 +110,12 @@ class Watcher {
110
110
  this.running = true;
111
111
  this.emitter = emitter;
112
112
  emitter.close = this.close.bind(this);
113
- this.tasks = configs.map(config => new Task(this, config));
114
- this.buildDelay = configs.reduce((buildDelay, { watch }) => watch && typeof watch.buildDelay === 'number'
115
- ? Math.max(buildDelay, watch.buildDelay)
116
- : buildDelay, this.buildDelay);
113
+ this.tasks = optionsList.map(options => new Task(this, options));
114
+ for (const { watch } of optionsList) {
115
+ if (watch && typeof watch.buildDelay === 'number') {
116
+ this.buildDelay = Math.max(this.buildDelay, watch.buildDelay);
117
+ }
118
+ }
117
119
  process.nextTick(() => this.run());
118
120
  }
119
121
  async close() {
@@ -130,8 +132,8 @@ class Watcher {
130
132
  }
131
133
  invalidate(file) {
132
134
  if (file) {
133
- const prevEvent = this.invalidatedIds.get(file.id);
134
- const event = prevEvent ? eventsRewrites[prevEvent][file.event] : file.event;
135
+ const previousEvent = this.invalidatedIds.get(file.id);
136
+ const event = previousEvent ? eventsRewrites[previousEvent][file.event] : file.event;
135
137
  if (event === 'buggy') {
136
138
  //TODO: throws or warn? Currently just ignore, uses new event
137
139
  this.invalidatedIds.set(file.id, file.event);
@@ -190,15 +192,15 @@ class Watcher {
190
192
  }
191
193
  }
192
194
  class Task {
193
- constructor(watcher, config) {
195
+ constructor(watcher, options) {
194
196
  this.cache = { modules: [] };
195
197
  this.watchFiles = [];
196
198
  this.closed = false;
197
199
  this.invalidated = true;
198
200
  this.watched = new Set();
199
201
  this.watcher = watcher;
200
- this.skipWrite = Boolean(config.watch && config.watch.skipWrite);
201
- this.options = mergeOptions.mergeOptions(config);
202
+ this.options = options;
203
+ this.skipWrite = Boolean(options.watch && options.watch.skipWrite);
202
204
  this.outputs = this.options.output;
203
205
  this.outputFiles = this.outputs.map(output => {
204
206
  if (output.file || output.dir)
@@ -300,7 +302,7 @@ class Task {
300
302
  if (!this.filter(id))
301
303
  return;
302
304
  this.watched.add(id);
303
- if (this.outputFiles.some(file => file === id)) {
305
+ if (this.outputFiles.includes(id)) {
304
306
  throw new Error('Cannot import the generated bundle');
305
307
  }
306
308
  // this is necessary to ensure that any 'renamed' files
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -87,6 +87,7 @@
87
87
  "eslint-config-prettier": "^8.5.0",
88
88
  "eslint-plugin-import": "^2.26.0",
89
89
  "eslint-plugin-prettier": "^4.2.1",
90
+ "eslint-plugin-unicorn": "^44.0.2",
90
91
  "fixturify": "^2.1.1",
91
92
  "fs-extra": "^10.1.0",
92
93
  "github-api": "^3.4.0",
@@ -1,182 +0,0 @@
1
- /*
2
- @license
3
- Rollup.js v3.1.0
4
- Wed, 12 Oct 2022 08:54:50 GMT - commit f7b768992209a970c240799cdff12a4fa437c0d4
5
-
6
- https://github.com/rollup/rollup
7
-
8
- Released under the MIT License.
9
- */
10
- 'use strict';
11
-
12
- const rollup = require('./rollup.js');
13
-
14
- const commandAliases = {
15
- c: 'config',
16
- d: 'dir',
17
- e: 'external',
18
- f: 'format',
19
- g: 'globals',
20
- h: 'help',
21
- i: 'input',
22
- m: 'sourcemap',
23
- n: 'name',
24
- o: 'file',
25
- p: 'plugin',
26
- v: 'version',
27
- w: 'watch'
28
- };
29
- function mergeOptions(config, rawCommandOptions = { external: [], globals: undefined }, defaultOnWarnHandler = rollup.defaultOnWarn) {
30
- const command = getCommandOptions(rawCommandOptions);
31
- const inputOptions = mergeInputOptions(config, command, defaultOnWarnHandler);
32
- const warn = inputOptions.onwarn;
33
- if (command.output) {
34
- Object.assign(command, command.output);
35
- }
36
- const outputOptionsArray = rollup.ensureArray(config.output);
37
- if (outputOptionsArray.length === 0)
38
- outputOptionsArray.push({});
39
- const outputOptions = outputOptionsArray.map(singleOutputOptions => mergeOutputOptions(singleOutputOptions, command, warn));
40
- rollup.warnUnknownOptions(command, Object.keys(inputOptions).concat(Object.keys(outputOptions[0]).filter(option => option !== 'sourcemapPathTransform'), Object.keys(commandAliases), 'bundleConfigAsCjs', 'config', 'environment', 'plugin', 'silent', 'failAfterWarnings', 'stdin', 'waitForBundleInput', 'configPlugin'), 'CLI flags', warn, /^_$|output$|config/);
41
- inputOptions.output = outputOptions;
42
- return inputOptions;
43
- }
44
- function getCommandOptions(rawCommandOptions) {
45
- const external = rawCommandOptions.external && typeof rawCommandOptions.external === 'string'
46
- ? rawCommandOptions.external.split(',')
47
- : [];
48
- return {
49
- ...rawCommandOptions,
50
- external,
51
- globals: typeof rawCommandOptions.globals === 'string'
52
- ? rawCommandOptions.globals.split(',').reduce((globals, globalDefinition) => {
53
- const [id, variableName] = globalDefinition.split(':');
54
- globals[id] = variableName;
55
- if (!external.includes(id)) {
56
- external.push(id);
57
- }
58
- return globals;
59
- }, Object.create(null))
60
- : undefined
61
- };
62
- }
63
- function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
64
- const getOption = (name) => overrides[name] ?? config[name];
65
- const inputOptions = {
66
- acorn: getOption('acorn'),
67
- acornInjectPlugins: config.acornInjectPlugins,
68
- cache: config.cache,
69
- context: getOption('context'),
70
- experimentalCacheExpiry: getOption('experimentalCacheExpiry'),
71
- external: getExternal(config, overrides),
72
- inlineDynamicImports: getOption('inlineDynamicImports'),
73
- input: getOption('input') || [],
74
- makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'),
75
- manualChunks: getOption('manualChunks'),
76
- maxParallelFileOps: getOption('maxParallelFileOps'),
77
- maxParallelFileReads: getOption('maxParallelFileReads'),
78
- moduleContext: getOption('moduleContext'),
79
- onwarn: getOnWarn(config, defaultOnWarnHandler),
80
- perf: getOption('perf'),
81
- plugins: rollup.normalizePluginOption(config.plugins),
82
- preserveEntrySignatures: getOption('preserveEntrySignatures'),
83
- preserveModules: getOption('preserveModules'),
84
- preserveSymlinks: getOption('preserveSymlinks'),
85
- shimMissingExports: getOption('shimMissingExports'),
86
- strictDeprecations: getOption('strictDeprecations'),
87
- treeshake: getObjectOption(config, overrides, 'treeshake', rollup.objectifyOptionWithPresets(rollup.treeshakePresets, 'treeshake', 'false, true, ')),
88
- watch: getWatch(config, overrides)
89
- };
90
- rollup.warnUnknownOptions(config, Object.keys(inputOptions), 'input options', inputOptions.onwarn, /^output$/);
91
- return inputOptions;
92
- }
93
- const getExternal = (config, overrides) => {
94
- const configExternal = config.external;
95
- return typeof configExternal === 'function'
96
- ? (source, importer, isResolved) => configExternal(source, importer, isResolved) || overrides.external.includes(source)
97
- : rollup.ensureArray(configExternal).concat(overrides.external);
98
- };
99
- const getOnWarn = (config, defaultOnWarnHandler) => config.onwarn
100
- ? warning => config.onwarn(warning, defaultOnWarnHandler)
101
- : defaultOnWarnHandler;
102
- const getObjectOption = (config, overrides, name, objectifyValue = rollup.objectifyOption) => {
103
- const commandOption = normalizeObjectOptionValue(overrides[name], objectifyValue);
104
- const configOption = normalizeObjectOptionValue(config[name], objectifyValue);
105
- if (commandOption !== undefined) {
106
- return commandOption && { ...configOption, ...commandOption };
107
- }
108
- return configOption;
109
- };
110
- const getWatch = (config, overrides) => config.watch !== false && getObjectOption(config, overrides, 'watch');
111
- const isWatchEnabled = (optionValue) => {
112
- if (Array.isArray(optionValue)) {
113
- return optionValue.reduce((result, value) => (typeof value === 'boolean' ? value : result), false);
114
- }
115
- return optionValue === true;
116
- };
117
- const normalizeObjectOptionValue = (optionValue, objectifyValue) => {
118
- if (!optionValue) {
119
- return optionValue;
120
- }
121
- if (Array.isArray(optionValue)) {
122
- return optionValue.reduce((result, value) => value && result && { ...result, ...objectifyValue(value) }, {});
123
- }
124
- return objectifyValue(optionValue);
125
- };
126
- function mergeOutputOptions(config, overrides, warn) {
127
- const getOption = (name) => overrides[name] ?? config[name];
128
- const outputOptions = {
129
- amd: getObjectOption(config, overrides, 'amd'),
130
- assetFileNames: getOption('assetFileNames'),
131
- banner: getOption('banner'),
132
- chunkFileNames: getOption('chunkFileNames'),
133
- compact: getOption('compact'),
134
- dir: getOption('dir'),
135
- dynamicImportFunction: getOption('dynamicImportFunction'),
136
- dynamicImportInCjs: getOption('dynamicImportInCjs'),
137
- entryFileNames: getOption('entryFileNames'),
138
- esModule: getOption('esModule'),
139
- exports: getOption('exports'),
140
- extend: getOption('extend'),
141
- externalImportAssertions: getOption('externalImportAssertions'),
142
- externalLiveBindings: getOption('externalLiveBindings'),
143
- file: getOption('file'),
144
- footer: getOption('footer'),
145
- format: getOption('format'),
146
- freeze: getOption('freeze'),
147
- generatedCode: getObjectOption(config, overrides, 'generatedCode', rollup.objectifyOptionWithPresets(rollup.generatedCodePresets, 'output.generatedCode', '')),
148
- globals: getOption('globals'),
149
- hoistTransitiveImports: getOption('hoistTransitiveImports'),
150
- indent: getOption('indent'),
151
- inlineDynamicImports: getOption('inlineDynamicImports'),
152
- interop: getOption('interop'),
153
- intro: getOption('intro'),
154
- manualChunks: getOption('manualChunks'),
155
- minifyInternalExports: getOption('minifyInternalExports'),
156
- name: getOption('name'),
157
- namespaceToStringTag: getOption('namespaceToStringTag'),
158
- noConflict: getOption('noConflict'),
159
- outro: getOption('outro'),
160
- paths: getOption('paths'),
161
- plugins: rollup.normalizePluginOption(config.plugins),
162
- preferConst: getOption('preferConst'),
163
- preserveModules: getOption('preserveModules'),
164
- preserveModulesRoot: getOption('preserveModulesRoot'),
165
- sanitizeFileName: getOption('sanitizeFileName'),
166
- sourcemap: getOption('sourcemap'),
167
- sourcemapBaseUrl: getOption('sourcemapBaseUrl'),
168
- sourcemapExcludeSources: getOption('sourcemapExcludeSources'),
169
- sourcemapFile: getOption('sourcemapFile'),
170
- sourcemapPathTransform: getOption('sourcemapPathTransform'),
171
- strict: getOption('strict'),
172
- systemNullSetters: getOption('systemNullSetters'),
173
- validate: getOption('validate')
174
- };
175
- rollup.warnUnknownOptions(config, Object.keys(outputOptions), 'output options', warn);
176
- return outputOptions;
177
- }
178
-
179
- exports.commandAliases = commandAliases;
180
- exports.isWatchEnabled = isWatchEnabled;
181
- exports.mergeOptions = mergeOptions;
182
- //# sourceMappingURL=mergeOptions.js.map