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
 
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { resolve } from 'node:path';
11
11
  import process$1 from 'node:process';
12
- import { ensureArray, warnUnknownOptions, defaultOnWarn, normalizePluginOption, objectifyOptionWithPresets, treeshakePresets, objectifyOption, generatedCodePresets, picomatch as picomatch$2, getAugmentedNamespace, fseventsImporter, createFilter, rollupInternal } from './rollup.js';
12
+ import { picomatch as picomatch$2, getAugmentedNamespace, fseventsImporter, createFilter, rollupInternal } from './rollup.js';
13
13
  import { platform } from 'node:os';
14
14
  import require$$0$1 from 'fs';
15
15
  import require$$2 from 'util';
@@ -21,165 +21,7 @@ import 'node:perf_hooks';
21
21
  import 'node:crypto';
22
22
  import 'node:fs';
23
23
  import 'node:events';
24
-
25
- const commandAliases = {
26
- c: 'config',
27
- d: 'dir',
28
- e: 'external',
29
- f: 'format',
30
- g: 'globals',
31
- h: 'help',
32
- i: 'input',
33
- m: 'sourcemap',
34
- n: 'name',
35
- o: 'file',
36
- p: 'plugin',
37
- v: 'version',
38
- w: 'watch'
39
- };
40
- function mergeOptions(config, rawCommandOptions = { external: [], globals: undefined }, defaultOnWarnHandler = defaultOnWarn) {
41
- const command = getCommandOptions(rawCommandOptions);
42
- const inputOptions = mergeInputOptions(config, command, defaultOnWarnHandler);
43
- const warn = inputOptions.onwarn;
44
- if (command.output) {
45
- Object.assign(command, command.output);
46
- }
47
- const outputOptionsArray = ensureArray(config.output);
48
- if (outputOptionsArray.length === 0)
49
- outputOptionsArray.push({});
50
- const outputOptions = outputOptionsArray.map(singleOutputOptions => mergeOutputOptions(singleOutputOptions, command, warn));
51
- 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/);
52
- inputOptions.output = outputOptions;
53
- return inputOptions;
54
- }
55
- function getCommandOptions(rawCommandOptions) {
56
- const external = rawCommandOptions.external && typeof rawCommandOptions.external === 'string'
57
- ? rawCommandOptions.external.split(',')
58
- : [];
59
- return {
60
- ...rawCommandOptions,
61
- external,
62
- globals: typeof rawCommandOptions.globals === 'string'
63
- ? rawCommandOptions.globals.split(',').reduce((globals, globalDefinition) => {
64
- const [id, variableName] = globalDefinition.split(':');
65
- globals[id] = variableName;
66
- if (!external.includes(id)) {
67
- external.push(id);
68
- }
69
- return globals;
70
- }, Object.create(null))
71
- : undefined
72
- };
73
- }
74
- function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
75
- const getOption = (name) => overrides[name] ?? config[name];
76
- const inputOptions = {
77
- acorn: getOption('acorn'),
78
- acornInjectPlugins: config.acornInjectPlugins,
79
- cache: config.cache,
80
- context: getOption('context'),
81
- experimentalCacheExpiry: getOption('experimentalCacheExpiry'),
82
- external: getExternal(config, overrides),
83
- inlineDynamicImports: getOption('inlineDynamicImports'),
84
- input: getOption('input') || [],
85
- makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'),
86
- manualChunks: getOption('manualChunks'),
87
- maxParallelFileOps: getOption('maxParallelFileOps'),
88
- maxParallelFileReads: getOption('maxParallelFileReads'),
89
- moduleContext: getOption('moduleContext'),
90
- onwarn: getOnWarn(config, defaultOnWarnHandler),
91
- perf: getOption('perf'),
92
- plugins: normalizePluginOption(config.plugins),
93
- preserveEntrySignatures: getOption('preserveEntrySignatures'),
94
- preserveModules: getOption('preserveModules'),
95
- preserveSymlinks: getOption('preserveSymlinks'),
96
- shimMissingExports: getOption('shimMissingExports'),
97
- strictDeprecations: getOption('strictDeprecations'),
98
- treeshake: getObjectOption(config, overrides, 'treeshake', objectifyOptionWithPresets(treeshakePresets, 'treeshake', 'false, true, ')),
99
- watch: getWatch(config, overrides)
100
- };
101
- warnUnknownOptions(config, Object.keys(inputOptions), 'input options', inputOptions.onwarn, /^output$/);
102
- return inputOptions;
103
- }
104
- const getExternal = (config, overrides) => {
105
- const configExternal = config.external;
106
- return typeof configExternal === 'function'
107
- ? (source, importer, isResolved) => configExternal(source, importer, isResolved) || overrides.external.includes(source)
108
- : ensureArray(configExternal).concat(overrides.external);
109
- };
110
- const getOnWarn = (config, defaultOnWarnHandler) => config.onwarn
111
- ? warning => config.onwarn(warning, defaultOnWarnHandler)
112
- : defaultOnWarnHandler;
113
- const getObjectOption = (config, overrides, name, objectifyValue = objectifyOption) => {
114
- const commandOption = normalizeObjectOptionValue(overrides[name], objectifyValue);
115
- const configOption = normalizeObjectOptionValue(config[name], objectifyValue);
116
- if (commandOption !== undefined) {
117
- return commandOption && { ...configOption, ...commandOption };
118
- }
119
- return configOption;
120
- };
121
- const getWatch = (config, overrides) => config.watch !== false && getObjectOption(config, overrides, 'watch');
122
- const normalizeObjectOptionValue = (optionValue, objectifyValue) => {
123
- if (!optionValue) {
124
- return optionValue;
125
- }
126
- if (Array.isArray(optionValue)) {
127
- return optionValue.reduce((result, value) => value && result && { ...result, ...objectifyValue(value) }, {});
128
- }
129
- return objectifyValue(optionValue);
130
- };
131
- function mergeOutputOptions(config, overrides, warn) {
132
- const getOption = (name) => overrides[name] ?? config[name];
133
- const outputOptions = {
134
- amd: getObjectOption(config, overrides, 'amd'),
135
- assetFileNames: getOption('assetFileNames'),
136
- banner: getOption('banner'),
137
- chunkFileNames: getOption('chunkFileNames'),
138
- compact: getOption('compact'),
139
- dir: getOption('dir'),
140
- dynamicImportFunction: getOption('dynamicImportFunction'),
141
- dynamicImportInCjs: getOption('dynamicImportInCjs'),
142
- entryFileNames: getOption('entryFileNames'),
143
- esModule: getOption('esModule'),
144
- exports: getOption('exports'),
145
- extend: getOption('extend'),
146
- externalImportAssertions: getOption('externalImportAssertions'),
147
- externalLiveBindings: getOption('externalLiveBindings'),
148
- file: getOption('file'),
149
- footer: getOption('footer'),
150
- format: getOption('format'),
151
- freeze: getOption('freeze'),
152
- generatedCode: getObjectOption(config, overrides, 'generatedCode', objectifyOptionWithPresets(generatedCodePresets, 'output.generatedCode', '')),
153
- globals: getOption('globals'),
154
- hoistTransitiveImports: getOption('hoistTransitiveImports'),
155
- indent: getOption('indent'),
156
- inlineDynamicImports: getOption('inlineDynamicImports'),
157
- interop: getOption('interop'),
158
- intro: getOption('intro'),
159
- manualChunks: getOption('manualChunks'),
160
- minifyInternalExports: getOption('minifyInternalExports'),
161
- name: getOption('name'),
162
- namespaceToStringTag: getOption('namespaceToStringTag'),
163
- noConflict: getOption('noConflict'),
164
- outro: getOption('outro'),
165
- paths: getOption('paths'),
166
- plugins: normalizePluginOption(config.plugins),
167
- preferConst: getOption('preferConst'),
168
- preserveModules: getOption('preserveModules'),
169
- preserveModulesRoot: getOption('preserveModulesRoot'),
170
- sanitizeFileName: getOption('sanitizeFileName'),
171
- sourcemap: getOption('sourcemap'),
172
- sourcemapBaseUrl: getOption('sourcemapBaseUrl'),
173
- sourcemapExcludeSources: getOption('sourcemapExcludeSources'),
174
- sourcemapFile: getOption('sourcemapFile'),
175
- sourcemapPathTransform: getOption('sourcemapPathTransform'),
176
- strict: getOption('strict'),
177
- systemNullSetters: getOption('systemNullSetters'),
178
- validate: getOption('validate')
179
- };
180
- warnUnknownOptions(config, Object.keys(outputOptions), 'output options', warn);
181
- return outputOptions;
182
- }
24
+ import 'tty';
183
25
 
184
26
  var chokidar = {};
185
27
 
@@ -2869,7 +2711,7 @@ const setFsWatchFileListener = (path, fullPath, options, handlers) => {
2869
2711
  /**
2870
2712
  * @mixin
2871
2713
  */
2872
- class NodeFsHandler$1 {
2714
+ let NodeFsHandler$1 = class NodeFsHandler {
2873
2715
 
2874
2716
  /**
2875
2717
  * @param {import("../index").FSWatcher} fsW
@@ -3225,7 +3067,7 @@ async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
3225
3067
  }
3226
3068
  }
3227
3069
 
3228
- }
3070
+ };
3229
3071
 
3230
3072
  var nodefsHandler = NodeFsHandler$1;
3231
3073
 
@@ -3445,7 +3287,7 @@ const sameTypes = (info, stats) => (
3445
3287
  /**
3446
3288
  * @mixin
3447
3289
  */
3448
- class FsEventsHandler$1 {
3290
+ let FsEventsHandler$1 = class FsEventsHandler {
3449
3291
 
3450
3292
  /**
3451
3293
  * @param {import('../index').FSWatcher} fsw
@@ -3751,7 +3593,7 @@ async _addToFsEvents(path, transform, forceAdd, priorDepth) {
3751
3593
  }
3752
3594
  }
3753
3595
 
3754
- }
3596
+ };
3755
3597
 
3756
3598
  fseventsHandler.exports = FsEventsHandler$1;
3757
3599
  fseventsHandler.exports.canUse = canUse;
@@ -4801,7 +4643,7 @@ const eventsRewrites = {
4801
4643
  }
4802
4644
  };
4803
4645
  class Watcher {
4804
- constructor(configs, emitter) {
4646
+ constructor(optionsList, emitter) {
4805
4647
  this.buildDelay = 0;
4806
4648
  this.buildTimeout = null;
4807
4649
  this.closed = false;
@@ -4810,10 +4652,12 @@ class Watcher {
4810
4652
  this.running = true;
4811
4653
  this.emitter = emitter;
4812
4654
  emitter.close = this.close.bind(this);
4813
- this.tasks = configs.map(config => new Task(this, config));
4814
- this.buildDelay = configs.reduce((buildDelay, { watch }) => watch && typeof watch.buildDelay === 'number'
4815
- ? Math.max(buildDelay, watch.buildDelay)
4816
- : buildDelay, this.buildDelay);
4655
+ this.tasks = optionsList.map(options => new Task(this, options));
4656
+ for (const { watch } of optionsList) {
4657
+ if (watch && typeof watch.buildDelay === 'number') {
4658
+ this.buildDelay = Math.max(this.buildDelay, watch.buildDelay);
4659
+ }
4660
+ }
4817
4661
  process$1.nextTick(() => this.run());
4818
4662
  }
4819
4663
  async close() {
@@ -4830,8 +4674,8 @@ class Watcher {
4830
4674
  }
4831
4675
  invalidate(file) {
4832
4676
  if (file) {
4833
- const prevEvent = this.invalidatedIds.get(file.id);
4834
- const event = prevEvent ? eventsRewrites[prevEvent][file.event] : file.event;
4677
+ const previousEvent = this.invalidatedIds.get(file.id);
4678
+ const event = previousEvent ? eventsRewrites[previousEvent][file.event] : file.event;
4835
4679
  if (event === 'buggy') {
4836
4680
  //TODO: throws or warn? Currently just ignore, uses new event
4837
4681
  this.invalidatedIds.set(file.id, file.event);
@@ -4890,15 +4734,15 @@ class Watcher {
4890
4734
  }
4891
4735
  }
4892
4736
  class Task {
4893
- constructor(watcher, config) {
4737
+ constructor(watcher, options) {
4894
4738
  this.cache = { modules: [] };
4895
4739
  this.watchFiles = [];
4896
4740
  this.closed = false;
4897
4741
  this.invalidated = true;
4898
4742
  this.watched = new Set();
4899
4743
  this.watcher = watcher;
4900
- this.skipWrite = Boolean(config.watch && config.watch.skipWrite);
4901
- this.options = mergeOptions(config);
4744
+ this.options = options;
4745
+ this.skipWrite = Boolean(options.watch && options.watch.skipWrite);
4902
4746
  this.outputs = this.options.output;
4903
4747
  this.outputFiles = this.outputs.map(output => {
4904
4748
  if (output.file || output.dir)
@@ -5000,7 +4844,7 @@ class Task {
5000
4844
  if (!this.filter(id))
5001
4845
  return;
5002
4846
  this.watched.add(id);
5003
- if (this.outputFiles.some(file => file === id)) {
4847
+ if (this.outputFiles.includes(id)) {
5004
4848
  throw new Error('Cannot import the generated bundle');
5005
4849
  }
5006
4850
  // this is necessary to ensure that any 'renamed' files
@@ -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
 
@@ -15,14 +15,13 @@ require('node:fs');
15
15
  require('node:path');
16
16
  require('node:process');
17
17
  require('node:url');
18
- const loadConfigFile_js = require('./shared/loadConfigFile.js');
19
18
  require('./shared/rollup.js');
20
- require('./shared/mergeOptions.js');
21
- require('tty');
19
+ const loadConfigFile_js = require('./shared/loadConfigFile.js');
22
20
  require('path');
23
21
  require('node:perf_hooks');
24
22
  require('node:crypto');
25
23
  require('node:events');
24
+ require('tty');
26
25
 
27
26
 
28
27
 
package/dist/rollup.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  export const VERSION: string;
2
2
 
3
+ type FalsyValue = false | null | undefined;
4
+ type MaybeArray<T> = T | T[];
5
+ type MaybePromise<T> = T | Promise<T>;
6
+
3
7
  export interface RollupError extends RollupLog {
4
8
  name?: string;
5
9
  stack?: string;
@@ -176,7 +180,7 @@ export interface PluginContext extends MinimalPluginContext {
176
180
  addWatchFile: (id: string) => void;
177
181
  cache: PluginCache;
178
182
  emitFile: EmitFile;
179
- error: (err: RollupError | string, pos?: number | { column: number; line: number }) => never;
183
+ error: (error: RollupError | string, pos?: number | { column: number; line: number }) => never;
180
184
  getFileName: (fileReferenceId: string) => string;
181
185
  getModuleIds: () => IterableIterator<string>;
182
186
  getModuleInfo: GetModuleInfo;
@@ -287,7 +291,7 @@ export type ResolveDynamicImportHook = (
287
291
 
288
292
  export type ResolveImportMetaHook = (
289
293
  this: PluginContext,
290
- prop: string | null,
294
+ property: string | null,
291
295
  options: { chunkId: string; format: InternalModuleFormat; moduleId: string }
292
296
  ) => string | null | void;
293
297
 
@@ -335,7 +339,7 @@ export interface OutputBundle {
335
339
 
336
340
  export interface FunctionPluginHooks {
337
341
  augmentChunkHash: (this: PluginContext, chunk: RenderedChunk) => string | void;
338
- buildEnd: (this: PluginContext, err?: Error) => void;
342
+ buildEnd: (this: PluginContext, error?: Error) => void;
339
343
  buildStart: (this: PluginContext, options: NormalizedInputOptions) => void;
340
344
  closeBundle: (this: PluginContext) => void;
341
345
  closeWatcher: (this: PluginContext) => void;
@@ -359,7 +363,7 @@ export interface FunctionPluginHooks {
359
363
  targetModuleId: string | null;
360
364
  }
361
365
  ) => { left: string; right: string } | null | void;
362
- renderError: (this: PluginContext, err?: Error) => void;
366
+ renderError: (this: PluginContext, error?: Error) => void;
363
367
  renderStart: (
364
368
  this: PluginContext,
365
369
  outputOptions: NormalizedOutputOptions,
@@ -426,8 +430,11 @@ export type ParallelPluginHooks = Exclude<
426
430
 
427
431
  export type AddonHooks = 'banner' | 'footer' | 'intro' | 'outro';
428
432
 
429
- type MakeAsync<Fn> = Fn extends (this: infer This, ...args: infer Args) => infer Return
430
- ? (this: This, ...args: Args) => Return | Promise<Return>
433
+ type MakeAsync<Function_> = Function_ extends (
434
+ this: infer This,
435
+ ...parameters: infer Arguments
436
+ ) => infer Return
437
+ ? (this: This, ...parameters: Arguments) => Return | Promise<Return>
431
438
  : never;
432
439
 
433
440
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -492,7 +499,7 @@ export type SourcemapPathTransformOption = (
492
499
  sourcemapPath: string
493
500
  ) => string;
494
501
 
495
- export type InputPluginOption = Plugin | null | false | undefined | InputPluginOption[];
502
+ export type InputPluginOption = MaybePromise<Plugin | FalsyValue | InputPluginOption[]>;
496
503
 
497
504
  export interface InputOptions {
498
505
  acorn?: Record<string, unknown>;
@@ -616,7 +623,7 @@ export type NormalizedAmdOptions = (
616
623
 
617
624
  type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
618
625
 
619
- type OutputPluginOption = OutputPlugin | null | false | undefined | OutputPluginOption[];
626
+ type OutputPluginOption = MaybePromise<OutputPlugin | FalsyValue | OutputPluginOption[]>;
620
627
 
621
628
  export interface OutputOptions {
622
629
  amd?: AmdOptions;
@@ -854,13 +861,13 @@ export interface RollupWatchOptions extends InputOptions {
854
861
  }
855
862
 
856
863
  export type AwaitedEventListener<
857
- T extends { [event: string]: (...args: any) => any },
864
+ T extends { [event: string]: (...parameters: any) => any },
858
865
  K extends keyof T
859
- > = (...args: Parameters<T[K]>) => void | Promise<void>;
866
+ > = (...parameters: Parameters<T[K]>) => void | Promise<void>;
860
867
 
861
- export interface AwaitingEventEmitter<T extends { [event: string]: (...args: any) => any }> {
868
+ export interface AwaitingEventEmitter<T extends { [event: string]: (...parameters: any) => any }> {
862
869
  close(): Promise<void>;
863
- emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): Promise<unknown>;
870
+ emit<K extends keyof T>(event: K, ...parameters: Parameters<T[K]>): Promise<unknown>;
864
871
  /**
865
872
  * Removes an event listener.
866
873
  */
@@ -880,7 +887,7 @@ export interface AwaitingEventEmitter<T extends { [event: string]: (...args: any
880
887
  */
881
888
  onCurrentRun<K extends keyof T>(
882
889
  event: K,
883
- listener: (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>>
890
+ listener: (...parameters: Parameters<T[K]>) => Promise<ReturnType<T[K]>>
884
891
  ): this;
885
892
  removeAllListeners(): this;
886
893
  removeListenersForCurrentRun(): this;
package/dist/rollup.js CHANGED
@@ -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
 
@@ -19,6 +19,7 @@ require('node:perf_hooks');
19
19
  require('node:crypto');
20
20
  require('node:fs');
21
21
  require('node:events');
22
+ require('tty');
22
23
 
23
24
 
24
25
 
@@ -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
 
@@ -2705,7 +2705,7 @@ const setFsWatchFileListener = (path, fullPath, options, handlers) => {
2705
2705
  /**
2706
2706
  * @mixin
2707
2707
  */
2708
- class NodeFsHandler$1 {
2708
+ let NodeFsHandler$1 = class NodeFsHandler {
2709
2709
 
2710
2710
  /**
2711
2711
  * @param {import("../index").FSWatcher} fsW
@@ -3061,7 +3061,7 @@ async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
3061
3061
  }
3062
3062
  }
3063
3063
 
3064
- }
3064
+ };
3065
3065
 
3066
3066
  var nodefsHandler = NodeFsHandler$1;
3067
3067
 
@@ -3281,7 +3281,7 @@ const sameTypes = (info, stats) => (
3281
3281
  /**
3282
3282
  * @mixin
3283
3283
  */
3284
- class FsEventsHandler$1 {
3284
+ let FsEventsHandler$1 = class FsEventsHandler {
3285
3285
 
3286
3286
  /**
3287
3287
  * @param {import('../index').FSWatcher} fsw
@@ -3587,7 +3587,7 @@ async _addToFsEvents(path, transform, forceAdd, priorDepth) {
3587
3587
  }
3588
3588
  }
3589
3589
 
3590
- }
3590
+ };
3591
3591
 
3592
3592
  fseventsHandler.exports = FsEventsHandler$1;
3593
3593
  fseventsHandler.exports.canUse = canUse;