rollup 3.0.0-4 → 3.0.0-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 v3.0.0-3
4
- Mon, 15 Aug 2022 04:43:13 GMT - commit 84a4a595851ef71494b6f2ab558968bfbc148bdb
3
+ Rollup.js v3.0.0-4
4
+ Wed, 31 Aug 2022 05:26:36 GMT - commit 392609619bcb75a0c7216f38e40d9573419a8e3f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -48,7 +48,7 @@ function mergeOptions(config, rawCommandOptions = { external: [], globals: undef
48
48
  if (outputOptionsArray.length === 0)
49
49
  outputOptionsArray.push({});
50
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), 'config', 'environment', 'plugin', 'silent', 'failAfterWarnings', 'stdin', 'waitForBundleInput', 'configPlugin'), 'CLI flags', warn, /^_$|output$|config/);
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
52
  inputOptions.output = outputOptions;
53
53
  return inputOptions;
54
54
  }
@@ -4803,6 +4803,7 @@ class Watcher {
4803
4803
  constructor(configs, emitter) {
4804
4804
  this.buildDelay = 0;
4805
4805
  this.buildTimeout = null;
4806
+ this.closed = false;
4806
4807
  this.invalidatedIds = new Map();
4807
4808
  this.rerun = false;
4808
4809
  this.running = true;
@@ -4815,12 +4816,15 @@ class Watcher {
4815
4816
  process$1.nextTick(() => this.run());
4816
4817
  }
4817
4818
  async close() {
4819
+ if (this.closed)
4820
+ return;
4821
+ this.closed = true;
4818
4822
  if (this.buildTimeout)
4819
4823
  clearTimeout(this.buildTimeout);
4820
4824
  for (const task of this.tasks) {
4821
4825
  task.close();
4822
4826
  }
4823
- await this.emitter.emitAndAwait('close');
4827
+ await this.emitter.emit('close');
4824
4828
  this.emitter.removeAllListeners();
4825
4829
  }
4826
4830
  invalidate(file) {
@@ -4847,20 +4851,20 @@ class Watcher {
4847
4851
  this.buildTimeout = setTimeout(async () => {
4848
4852
  this.buildTimeout = null;
4849
4853
  try {
4850
- await Promise.all([...this.invalidatedIds].map(([id, event]) => this.emitter.emitAndAwait('change', id, { event })));
4854
+ await Promise.all([...this.invalidatedIds].map(([id, event]) => this.emitter.emit('change', id, { event })));
4851
4855
  this.invalidatedIds.clear();
4852
- this.emitter.emit('restart');
4853
- this.emitter.removeAwaited();
4856
+ await this.emitter.emit('restart');
4857
+ this.emitter.removeListenersForCurrentRun();
4854
4858
  this.run();
4855
4859
  }
4856
4860
  catch (error) {
4857
4861
  this.invalidatedIds.clear();
4858
- this.emitter.emit('event', {
4862
+ await this.emitter.emit('event', {
4859
4863
  code: 'ERROR',
4860
4864
  error,
4861
4865
  result: null
4862
4866
  });
4863
- this.emitter.emit('event', {
4867
+ await this.emitter.emit('event', {
4864
4868
  code: 'END'
4865
4869
  });
4866
4870
  }
@@ -4868,14 +4872,14 @@ class Watcher {
4868
4872
  }
4869
4873
  async run() {
4870
4874
  this.running = true;
4871
- this.emitter.emit('event', {
4875
+ await this.emitter.emit('event', {
4872
4876
  code: 'START'
4873
4877
  });
4874
4878
  for (const task of this.tasks) {
4875
4879
  await task.run();
4876
4880
  }
4877
4881
  this.running = false;
4878
- this.emitter.emit('event', {
4882
+ await this.emitter.emit('event', {
4879
4883
  code: 'END'
4880
4884
  });
4881
4885
  if (this.rerun) {
@@ -4933,7 +4937,7 @@ class Task {
4933
4937
  cache: this.cache
4934
4938
  };
4935
4939
  const start = Date.now();
4936
- this.watcher.emitter.emit('event', {
4940
+ await this.watcher.emitter.emit('event', {
4937
4941
  code: 'BUNDLE_START',
4938
4942
  input: this.options.input,
4939
4943
  output: this.outputFiles
@@ -4946,7 +4950,7 @@ class Task {
4946
4950
  }
4947
4951
  this.updateWatchedFiles(result);
4948
4952
  this.skipWrite || (await Promise.all(this.outputs.map(output => result.write(output))));
4949
- this.watcher.emitter.emit('event', {
4953
+ await this.watcher.emitter.emit('event', {
4950
4954
  code: 'BUNDLE_END',
4951
4955
  duration: Date.now() - start,
4952
4956
  input: this.options.input,
@@ -4965,7 +4969,7 @@ class Task {
4965
4969
  this.cache.modules = this.cache.modules.filter(module => module.id !== error.id);
4966
4970
  }
4967
4971
  }
4968
- this.watcher.emitter.emit('event', {
4972
+ await this.watcher.emitter.emit('event', {
4969
4973
  code: 'ERROR',
4970
4974
  error,
4971
4975
  result
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.0.0-3
4
- Mon, 15 Aug 2022 04:43:13 GMT - commit 84a4a595851ef71494b6f2ab558968bfbc148bdb
3
+ Rollup.js v3.0.0-4
4
+ Wed, 31 Aug 2022 05:26:36 GMT - commit 392609619bcb75a0c7216f38e40d9573419a8e3f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -9,21 +9,19 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
12
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13
13
 
14
+ require('node:fs');
14
15
  require('node:path');
16
+ require('node:process');
15
17
  require('node:url');
16
18
  const loadConfigFile_js = require('./shared/loadConfigFile.js');
17
19
  require('./shared/rollup.js');
18
20
  require('./shared/mergeOptions.js');
19
- require('path');
20
- require('fs');
21
- require('util');
22
- require('node:process');
23
21
  require('tty');
22
+ require('path');
24
23
  require('node:perf_hooks');
25
24
  require('node:crypto');
26
- require('node:fs');
27
25
  require('node:events');
28
26
 
29
27
 
package/dist/rollup.d.ts CHANGED
@@ -28,6 +28,7 @@ export interface RollupLog {
28
28
  pluginCode?: string;
29
29
  pos?: number;
30
30
  reexporter?: string;
31
+ stack?: string;
31
32
  url?: string;
32
33
  }
33
34
 
@@ -571,7 +572,7 @@ interface GeneratedCodeOptions extends Partial<NormalizedGeneratedCodeOptions> {
571
572
 
572
573
  export type OptionsPaths = Record<string, string> | ((id: string) => string);
573
574
 
574
- export type InteropType = boolean | 'auto' | 'esModule' | 'default' | 'defaultOnly';
575
+ export type InteropType = 'compat' | 'auto' | 'esModule' | 'default' | 'defaultOnly';
575
576
 
576
577
  export type GetInterop = (id: string | null) => InteropType;
577
578
 
@@ -591,6 +592,7 @@ export type AmdOptions = (
591
592
  }
592
593
  ) & {
593
594
  define?: string;
595
+ forceJsExtensionForImports?: boolean;
594
596
  };
595
597
 
596
598
  export type NormalizedAmdOptions = (
@@ -604,6 +606,7 @@ export type NormalizedAmdOptions = (
604
606
  }
605
607
  ) & {
606
608
  define: string;
609
+ forceJsExtensionForImports: boolean;
607
610
  };
608
611
 
609
612
  type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
@@ -619,7 +622,7 @@ export interface OutputOptions {
619
622
  /** @deprecated Use the "renderDynamicImport" plugin hook instead. */
620
623
  dynamicImportFunction?: string;
621
624
  entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
622
- esModule?: boolean;
625
+ esModule?: boolean | 'if-default-prop';
623
626
  exports?: 'default' | 'named' | 'none' | 'auto';
624
627
  extend?: boolean;
625
628
  externalLiveBindings?: boolean;
@@ -669,7 +672,7 @@ export interface NormalizedOutputOptions {
669
672
  /** @deprecated Use the "renderDynamicImport" plugin hook instead. */
670
673
  dynamicImportFunction: string | undefined;
671
674
  entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
672
- esModule: boolean;
675
+ esModule: boolean | 'if-default-prop';
673
676
  exports: 'default' | 'named' | 'none' | 'auto';
674
677
  extend: boolean;
675
678
  externalLiveBindings: boolean;
@@ -839,40 +842,37 @@ export interface RollupWatchOptions extends InputOptions {
839
842
  watch?: WatcherOptions | false;
840
843
  }
841
844
 
842
- interface TypedEventEmitter<T extends { [event: string]: (...args: any) => any }> {
843
- addListener<K extends keyof T>(event: K, listener: T[K]): this;
844
- emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): boolean;
845
- eventNames(): Array<keyof T>;
846
- getMaxListeners(): number;
847
- listenerCount(type: keyof T): number;
848
- listeners<K extends keyof T>(event: K): Array<T[K]>;
849
- off<K extends keyof T>(event: K, listener: T[K]): this;
850
- on<K extends keyof T>(event: K, listener: T[K]): this;
851
- once<K extends keyof T>(event: K, listener: T[K]): this;
852
- prependListener<K extends keyof T>(event: K, listener: T[K]): this;
853
- prependOnceListener<K extends keyof T>(event: K, listener: T[K]): this;
854
- rawListeners<K extends keyof T>(event: K): Array<T[K]>;
855
- removeAllListeners<K extends keyof T>(event?: K): this;
856
- removeListener<K extends keyof T>(event: K, listener: T[K]): this;
857
- setMaxListeners(n: number): this;
858
- }
859
-
860
- export interface RollupAwaitingEmitter<T extends { [event: string]: (...args: any) => any }>
861
- extends TypedEventEmitter<T> {
845
+ export type AwaitedEventListener<
846
+ T extends { [event: string]: (...args: any) => any },
847
+ K extends keyof T
848
+ > = (...args: Parameters<T[K]>) => void | Promise<void>;
849
+
850
+ export interface AwaitingEventEmitter<T extends { [event: string]: (...args: any) => any }> {
862
851
  close(): Promise<void>;
863
- emitAndAwait<K extends keyof T>(event: K, ...args: Parameters<T[K]>): Promise<ReturnType<T[K]>[]>;
852
+ emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): Promise<unknown>;
853
+ /**
854
+ * Removes an event listener.
855
+ */
856
+ off<K extends keyof T>(event: K, listener: AwaitedEventListener<T, K>): this;
857
+ /**
858
+ * Registers an event listener that will be awaited before Rollup continues.
859
+ * All listeners will be awaited in parallel while rejections are tracked via
860
+ * Promise.all.
861
+ */
862
+ on<K extends keyof T>(event: K, listener: AwaitedEventListener<T, K>): this;
864
863
  /**
865
- * Registers an event listener that will be awaited before Rollup continues
866
- * for events emitted via emitAndAwait. All listeners will be awaited in
867
- * parallel while rejections are tracked via Promise.all.
868
- * Listeners are removed automatically when removeAwaited is called, which
869
- * happens automatically after each run.
864
+ * Registers an event listener that will be awaited before Rollup continues.
865
+ * All listeners will be awaited in parallel while rejections are tracked via
866
+ * Promise.all.
867
+ * Listeners are removed automatically when removeListenersForCurrentRun is
868
+ * called, which happens automatically after each run.
870
869
  */
871
- onCurrentAwaited<K extends keyof T>(
870
+ onCurrentRun<K extends keyof T>(
872
871
  event: K,
873
872
  listener: (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>>
874
873
  ): this;
875
- removeAwaited(): this;
874
+ removeAllListeners(): this;
875
+ removeListenersForCurrentRun(): this;
876
876
  }
877
877
 
878
878
  export type RollupWatcherEvent =
@@ -888,7 +888,7 @@ export type RollupWatcherEvent =
888
888
  | { code: 'END' }
889
889
  | { code: 'ERROR'; error: RollupError; result: RollupBuild | null };
890
890
 
891
- export type RollupWatcher = RollupAwaitingEmitter<{
891
+ export type RollupWatcher = AwaitingEventEmitter<{
892
892
  change: (id: string, change: { event: ChangeEvent }) => void;
893
893
  close: () => void;
894
894
  event: (event: RollupWatcherEvent) => void;
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.0.0-3
4
- Mon, 15 Aug 2022 04:43:13 GMT - commit 84a4a595851ef71494b6f2ab558968bfbc148bdb
3
+ Rollup.js v3.0.0-4
4
+ Wed, 31 Aug 2022 05:26:36 GMT - commit 392609619bcb75a0c7216f38e40d9573419a8e3f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -9,7 +9,7 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
12
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13
13
 
14
14
  const rollup = require('./shared/rollup.js');
15
15
  require('node:path');
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.0.0-3
4
- Mon, 15 Aug 2022 04:43:13 GMT - commit 84a4a595851ef71494b6f2ab558968bfbc148bdb
3
+ Rollup.js v3.0.0-4
4
+ Wed, 31 Aug 2022 05:26:36 GMT - commit 392609619bcb75a0c7216f38e40d9573419a8e3f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.0.0-3
4
- Mon, 15 Aug 2022 04:43:13 GMT - commit 84a4a595851ef71494b6f2ab558968bfbc148bdb
3
+ Rollup.js v3.0.0-4
4
+ Wed, 31 Aug 2022 05:26:36 GMT - commit 392609619bcb75a0c7216f38e40d9573419a8e3f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -9,12 +9,10 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
+ const node_fs = require('node:fs');
12
13
  const node_path = require('node:path');
13
- const node_url = require('node:url');
14
- const require$$0 = require('path');
15
- const require$$0$1 = require('fs');
16
- const require$$2 = require('util');
17
14
  const process$1 = require('node:process');
15
+ const node_url = require('node:url');
18
16
  const tty = require('tty');
19
17
  const rollup = require('./rollup.js');
20
18
  const mergeOptions = require('./mergeOptions.js');
@@ -174,122 +172,6 @@ function handleError(err, recover = false) {
174
172
  process$1.exit(1);
175
173
  }
176
174
 
177
- var getPackageType$2 = {exports: {}};
178
-
179
- const path$2 = require$$0;
180
-
181
- function isNodeModules$2(directory) {
182
- let basename = path$2.basename(directory);
183
- /* istanbul ignore next: platform specific branch */
184
- if (path$2.sep === '\\') {
185
- basename = basename.toLowerCase();
186
- }
187
-
188
- return basename === 'node_modules';
189
- }
190
-
191
- var isNodeModules_1 = isNodeModules$2;
192
-
193
- var cache = new Map();
194
-
195
- const path$1 = require$$0;
196
- const {promisify} = require$$2;
197
- const readFile = promisify(require$$0$1.readFile);
198
-
199
- const isNodeModules$1 = isNodeModules_1;
200
- const resultsCache$1 = cache;
201
-
202
- const promiseCache = new Map();
203
-
204
- async function getDirectoryTypeActual$1(directory) {
205
- if (isNodeModules$1(directory)) {
206
- return 'commonjs';
207
- }
208
-
209
- try {
210
- return JSON.parse(await readFile(path$1.resolve(directory, 'package.json'))).type || 'commonjs';
211
- } catch (_) {
212
- }
213
-
214
- const parent = path$1.dirname(directory);
215
- if (parent === directory) {
216
- return 'commonjs';
217
- }
218
-
219
- return getDirectoryType$1(parent);
220
- }
221
-
222
- async function getDirectoryType$1(directory) {
223
- if (resultsCache$1.has(directory)) {
224
- return resultsCache$1.get(directory);
225
- }
226
-
227
- if (promiseCache.has(directory)) {
228
- return promiseCache.get(directory);
229
- }
230
-
231
- const promise = getDirectoryTypeActual$1(directory);
232
- promiseCache.set(directory, promise);
233
- const result = await promise;
234
- resultsCache$1.set(directory, result);
235
- promiseCache.delete(directory);
236
-
237
- return result;
238
- }
239
-
240
- function getPackageType$1(filename) {
241
- return getDirectoryType$1(path$1.resolve(path$1.dirname(filename)));
242
- }
243
-
244
- var async = getPackageType$1;
245
-
246
- const path = require$$0;
247
- const {readFileSync} = require$$0$1;
248
-
249
- const isNodeModules = isNodeModules_1;
250
- const resultsCache = cache;
251
-
252
- function getDirectoryTypeActual(directory) {
253
- if (isNodeModules(directory)) {
254
- return 'commonjs';
255
- }
256
-
257
- try {
258
- return JSON.parse(readFileSync(path.resolve(directory, 'package.json'))).type || 'commonjs';
259
- } catch (_) {
260
- }
261
-
262
- const parent = path.dirname(directory);
263
- if (parent === directory) {
264
- return 'commonjs';
265
- }
266
-
267
- return getDirectoryType(parent);
268
- }
269
-
270
- function getDirectoryType(directory) {
271
- if (resultsCache.has(directory)) {
272
- return resultsCache.get(directory);
273
- }
274
-
275
- const result = getDirectoryTypeActual(directory);
276
- resultsCache.set(directory, result);
277
-
278
- return result;
279
- }
280
-
281
- function getPackageTypeSync$1(filename) {
282
- return getDirectoryType(path.resolve(path.dirname(filename)));
283
- }
284
-
285
- var sync = getPackageTypeSync$1;
286
-
287
- const getPackageType = async;
288
- const getPackageTypeSync = sync;
289
-
290
- getPackageType$2.exports = filename => getPackageType(filename);
291
- getPackageType$2.exports.sync = getPackageTypeSync;
292
-
293
175
  function batchWarnings() {
294
176
  let count = 0;
295
177
  const deferredWarnings = new Map();
@@ -665,7 +547,7 @@ async function requireOrImport(pluginPath) {
665
547
  }
666
548
 
667
549
  async function loadConfigFile(fileName, commandOptions = {}) {
668
- const configs = await loadConfigsFromFile(fileName, commandOptions);
550
+ const configs = await getConfigList(getDefaultFromCjs(await getConfigFileExport(fileName, commandOptions)), commandOptions);
669
551
  const warnings = batchWarnings();
670
552
  try {
671
553
  const normalizedConfigs = [];
@@ -681,19 +563,50 @@ async function loadConfigFile(fileName, commandOptions = {}) {
681
563
  throw err;
682
564
  }
683
565
  }
684
- async function loadConfigsFromFile(fileName, commandOptions) {
685
- const extension = node_path.extname(fileName);
686
- const configFileExport = commandOptions.configPlugin ||
687
- // We always transpile the .js non-module case because many legacy code bases rely on this
688
- (extension === '.js' && getPackageType$2.exports.sync(fileName) !== 'module')
689
- ? await getDefaultFromTranspiledConfigFile(fileName, commandOptions)
690
- : getDefaultFromCjs((await import(node_url.pathToFileURL(fileName).href)).default);
691
- return getConfigList(configFileExport, commandOptions);
566
+ async function getConfigFileExport(fileName, commandOptions) {
567
+ if (commandOptions.configPlugin || commandOptions.bundleConfigAsCjs) {
568
+ try {
569
+ return await loadTranspiledConfigFile(fileName, commandOptions);
570
+ }
571
+ catch (err) {
572
+ if (err.message.includes('not defined in ES module scope')) {
573
+ return rollup.error(rollup.errCannotBundleConfigAsEsm(err));
574
+ }
575
+ throw err;
576
+ }
577
+ }
578
+ let cannotLoadEsm = false;
579
+ const handleWarning = (warning) => {
580
+ if (warning.message.includes('To load an ES module')) {
581
+ cannotLoadEsm = true;
582
+ }
583
+ };
584
+ process$1.on('warning', handleWarning);
585
+ try {
586
+ const fileUrl = node_url.pathToFileURL(fileName);
587
+ if (process$1.env.ROLLUP_WATCH) {
588
+ // We are adding the current date to allow reloads in watch mode
589
+ fileUrl.search = `?${Date.now()}`;
590
+ }
591
+ return (await import(fileUrl.href)).default;
592
+ }
593
+ catch (err) {
594
+ if (cannotLoadEsm) {
595
+ return rollup.error(rollup.errCannotLoadConfigAsCjs(err));
596
+ }
597
+ if (err.message.includes('not defined in ES module scope')) {
598
+ return rollup.error(rollup.errCannotLoadConfigAsEsm(err));
599
+ }
600
+ throw err;
601
+ }
602
+ finally {
603
+ process$1.off('warning', handleWarning);
604
+ }
692
605
  }
693
606
  function getDefaultFromCjs(namespace) {
694
- return namespace.__esModule ? namespace.default : namespace;
607
+ return namespace.default || namespace;
695
608
  }
696
- async function getDefaultFromTranspiledConfigFile(fileName, commandOptions) {
609
+ async function loadTranspiledConfigFile(fileName, { bundleConfigAsCjs, configPlugin, silent }) {
697
610
  const warnings = batchWarnings();
698
611
  const inputOptions = {
699
612
  external: (id) => (id[0] !== '.' && !node_path.isAbsolute(id)) || id.slice(-5, id.length) === '.json',
@@ -702,15 +615,15 @@ async function getDefaultFromTranspiledConfigFile(fileName, commandOptions) {
702
615
  plugins: [],
703
616
  treeshake: false
704
617
  };
705
- await addPluginsFromCommandOption(commandOptions.configPlugin, inputOptions);
618
+ await addPluginsFromCommandOption(configPlugin, inputOptions);
706
619
  const bundle = await rollup.rollup(inputOptions);
707
- if (!commandOptions.silent && warnings.count > 0) {
620
+ if (!silent && warnings.count > 0) {
708
621
  stderr(bold(`loaded ${rollup.relativeId(fileName)} with warnings`));
709
622
  warnings.flush();
710
623
  }
711
624
  const { output: [{ code }] } = await bundle.generate({
712
625
  exports: 'named',
713
- format: 'cjs',
626
+ format: bundleConfigAsCjs ? 'cjs' : 'es',
714
627
  plugins: [
715
628
  {
716
629
  name: 'transpile-import-meta',
@@ -725,33 +638,16 @@ async function getDefaultFromTranspiledConfigFile(fileName, commandOptions) {
725
638
  }
726
639
  ]
727
640
  });
728
- return loadConfigFromBundledFile(fileName, code);
641
+ return loadConfigFromWrittenFile(node_path.join(node_path.dirname(fileName), `rollup.config-${Date.now()}.${bundleConfigAsCjs ? 'cjs' : 'mjs'}`), code);
729
642
  }
730
- function loadConfigFromBundledFile(fileName, bundledCode) {
731
- const resolvedFileName = require.resolve(fileName);
732
- const extension = node_path.extname(resolvedFileName);
733
- const defaultLoader = require.extensions[extension];
734
- require.extensions[extension] = (module, requiredFileName) => {
735
- if (requiredFileName === resolvedFileName) {
736
- module._compile(bundledCode, requiredFileName);
737
- }
738
- else {
739
- if (defaultLoader) {
740
- defaultLoader(module, requiredFileName);
741
- }
742
- }
743
- };
744
- delete require.cache[resolvedFileName];
643
+ async function loadConfigFromWrittenFile(bundledFileName, bundledCode) {
644
+ await node_fs.promises.writeFile(bundledFileName, bundledCode);
745
645
  try {
746
- const config = getDefaultFromCjs(require(fileName));
747
- require.extensions[extension] = defaultLoader;
748
- return config;
646
+ return (await import(node_url.pathToFileURL(bundledFileName).href)).default;
749
647
  }
750
- catch (err) {
751
- if (err.code === 'ERR_REQUIRE_ESM') {
752
- return rollup.error(rollup.errTranspiledEsmConfig(fileName));
753
- }
754
- throw err;
648
+ finally {
649
+ // Not awaiting here saves some ms while potentially hiding a non-critical error
650
+ node_fs.promises.unlink(bundledFileName);
755
651
  }
756
652
  }
757
653
  async function getConfigList(configFileExport, commandOptions) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.0.0-3
4
- Mon, 15 Aug 2022 04:43:13 GMT - commit 84a4a595851ef71494b6f2ab558968bfbc148bdb
3
+ Rollup.js v3.0.0-4
4
+ Wed, 31 Aug 2022 05:26:36 GMT - commit 392609619bcb75a0c7216f38e40d9573419a8e3f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -37,7 +37,7 @@ function mergeOptions(config, rawCommandOptions = { external: [], globals: undef
37
37
  if (outputOptionsArray.length === 0)
38
38
  outputOptionsArray.push({});
39
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), 'config', 'environment', 'plugin', 'silent', 'failAfterWarnings', 'stdin', 'waitForBundleInput', 'configPlugin'), 'CLI flags', warn, /^_$|output$|config/);
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
41
  inputOptions.output = outputOptions;
42
42
  return inputOptions;
43
43
  }