rollup 2.34.2 → 2.36.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.
package/dist/rollup.d.ts CHANGED
@@ -354,6 +354,7 @@ export interface OutputBundleWithPlaceholders {
354
354
  export interface PluginHooks extends OutputPluginHooks {
355
355
  buildEnd: (this: PluginContext, err?: Error) => Promise<void> | void;
356
356
  buildStart: (this: PluginContext, options: NormalizedInputOptions) => Promise<void> | void;
357
+ closeBundle: (this: PluginContext) => Promise<void> | void;
357
358
  closeWatcher: (this: PluginContext) => void;
358
359
  load: LoadHook;
359
360
  moduleParsed: ModuleParsedHook;
@@ -416,7 +417,8 @@ export type AsyncPluginHooks =
416
417
  | 'resolveDynamicImport'
417
418
  | 'resolveId'
418
419
  | 'transform'
419
- | 'writeBundle';
420
+ | 'writeBundle'
421
+ | 'closeBundle';
420
422
 
421
423
  export type PluginValueHooks = 'banner' | 'footer' | 'intro' | 'outro';
422
424
 
@@ -451,7 +453,8 @@ export type ParallelPluginHooks =
451
453
  | 'outro'
452
454
  | 'renderError'
453
455
  | 'renderStart'
454
- | 'writeBundle';
456
+ | 'writeBundle'
457
+ | 'closeBundle';
455
458
 
456
459
  interface OutputPluginValueHooks {
457
460
  banner: AddonHook;
@@ -769,6 +772,8 @@ export interface RollupOutput {
769
772
 
770
773
  export interface RollupBuild {
771
774
  cache: RollupCache | undefined;
775
+ close: () => Promise<void>;
776
+ closed: boolean;
772
777
  generate: (outputOptions: OutputOptions) => Promise<RollupOutput>;
773
778
  getTimings?: () => SerializedTimings;
774
779
  watchFiles: string[];
@@ -852,7 +857,7 @@ export type RollupWatcherEvent =
852
857
  result: RollupBuild;
853
858
  }
854
859
  | { code: 'END' }
855
- | { code: 'ERROR'; error: RollupError };
860
+ | { code: 'ERROR'; error: RollupError; result: RollupBuild | null };
856
861
 
857
862
  export interface RollupWatcher
858
863
  extends TypedEventEmitter<{
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.34.2
4
- Sun, 06 Dec 2020 05:40:46 GMT - commit 92a2dfa8f18350373aa2329dec45e56bd076909d
3
+ Rollup.js v2.36.1
4
+ Wed, 06 Jan 2021 14:06:54 GMT - commit d6600638c61b5eb7f389681d5fa4af9a1b95823e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.34.2
4
- Sun, 06 Dec 2020 05:40:46 GMT - commit 92a2dfa8f18350373aa2329dec45e56bd076909d
3
+ Rollup.js v2.36.1
4
+ Wed, 06 Jan 2021 14:06:54 GMT - commit d6600638c61b5eb7f389681d5fa4af9a1b95823e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.34.2
4
- Sun, 06 Dec 2020 05:40:46 GMT - commit 92a2dfa8f18350373aa2329dec45e56bd076909d
3
+ Rollup.js v2.36.1
4
+ Wed, 06 Jan 2021 14:06:54 GMT - commit d6600638c61b5eb7f389681d5fa4af9a1b95823e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.34.2
4
- Sun, 06 Dec 2020 05:40:46 GMT - commit 92a2dfa8f18350373aa2329dec45e56bd076909d
3
+ Rollup.js v2.36.1
4
+ Wed, 06 Jan 2021 14:06:54 GMT - commit d6600638c61b5eb7f389681d5fa4af9a1b95823e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.34.2
4
- Sun, 06 Dec 2020 05:40:46 GMT - commit 92a2dfa8f18350373aa2329dec45e56bd076909d
3
+ Rollup.js v2.36.1
4
+ Wed, 06 Jan 2021 14:06:54 GMT - commit d6600638c61b5eb7f389681d5fa4af9a1b95823e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -19,7 +19,7 @@ function _interopNamespaceDefaultOnly(e) {
19
19
  return {__proto__: null, 'default': e};
20
20
  }
21
21
 
22
- var version = "2.34.2";
22
+ var version = "2.36.1";
23
23
 
24
24
  function ensureArray(items) {
25
25
  if (Array.isArray(items)) {
@@ -5282,6 +5282,7 @@ function augmentCodeLocation(props, pos, source, id) {
5282
5282
  }
5283
5283
  var Errors;
5284
5284
  (function (Errors) {
5285
+ Errors["ALREADY_CLOSED"] = "ALREADY_CLOSED";
5285
5286
  Errors["ASSET_NOT_FINALISED"] = "ASSET_NOT_FINALISED";
5286
5287
  Errors["ASSET_NOT_FOUND"] = "ASSET_NOT_FOUND";
5287
5288
  Errors["ASSET_SOURCE_ALREADY_SET"] = "ASSET_SOURCE_ALREADY_SET";
@@ -5290,8 +5291,9 @@ var Errors;
5290
5291
  Errors["CANNOT_EMIT_FROM_OPTIONS_HOOK"] = "CANNOT_EMIT_FROM_OPTIONS_HOOK";
5291
5292
  Errors["CHUNK_NOT_GENERATED"] = "CHUNK_NOT_GENERATED";
5292
5293
  Errors["DEPRECATED_FEATURE"] = "DEPRECATED_FEATURE";
5293
- Errors["FILE_NOT_FOUND"] = "FILE_NOT_FOUND";
5294
+ Errors["EXTERNAL_SYNTHETIC_EXPORTS"] = "EXTERNAL_SYNTHETIC_EXPORTS";
5294
5295
  Errors["FILE_NAME_CONFLICT"] = "FILE_NAME_CONFLICT";
5296
+ Errors["FILE_NOT_FOUND"] = "FILE_NOT_FOUND";
5295
5297
  Errors["INPUT_HOOK_IN_OUTPUT_PLUGIN"] = "INPUT_HOOK_IN_OUTPUT_PLUGIN";
5296
5298
  Errors["INVALID_CHUNK"] = "INVALID_CHUNK";
5297
5299
  Errors["INVALID_EXPORT_OPTION"] = "INVALID_EXPORT_OPTION";
@@ -5305,12 +5307,11 @@ var Errors;
5305
5307
  Errors["NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE"] = "NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE";
5306
5308
  Errors["PLUGIN_ERROR"] = "PLUGIN_ERROR";
5307
5309
  Errors["PREFER_NAMED_EXPORTS"] = "PREFER_NAMED_EXPORTS";
5310
+ Errors["SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT"] = "SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT";
5308
5311
  Errors["UNEXPECTED_NAMED_IMPORT"] = "UNEXPECTED_NAMED_IMPORT";
5309
5312
  Errors["UNRESOLVED_ENTRY"] = "UNRESOLVED_ENTRY";
5310
5313
  Errors["UNRESOLVED_IMPORT"] = "UNRESOLVED_IMPORT";
5311
5314
  Errors["VALIDATION_ERROR"] = "VALIDATION_ERROR";
5312
- Errors["EXTERNAL_SYNTHETIC_EXPORTS"] = "EXTERNAL_SYNTHETIC_EXPORTS";
5313
- Errors["SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT"] = "SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT";
5314
5315
  })(Errors || (Errors = {}));
5315
5316
  function errAssetNotFinalisedForFileName(name) {
5316
5317
  return {
@@ -5533,6 +5534,12 @@ function errFailedValidation(message) {
5533
5534
  message
5534
5535
  };
5535
5536
  }
5537
+ function errAlreadyClosed() {
5538
+ return {
5539
+ code: Errors.ALREADY_CLOSED,
5540
+ message: 'Bundle is already closed, no more calls to "generate" or "write" are allowed.'
5541
+ };
5542
+ }
5536
5543
  function warnDeprecation(deprecation, activeDeprecation, options) {
5537
5544
  warnDeprecationWithOptions(deprecation, activeDeprecation, options.onwarn, options.strictDeprecations);
5538
5545
  }
@@ -6194,12 +6201,28 @@ class AssignmentExpression extends NodeBase {
6194
6201
  if (!this.deoptimized)
6195
6202
  this.applyDeoptimizations();
6196
6203
  this.included = true;
6197
- this.left.include(context, includeChildrenRecursively);
6204
+ let hasEffectsContext;
6205
+ if (includeChildrenRecursively ||
6206
+ this.operator !== '=' ||
6207
+ this.left.included ||
6208
+ ((hasEffectsContext = createHasEffectsContext()),
6209
+ this.left.hasEffects(hasEffectsContext) ||
6210
+ this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, hasEffectsContext))) {
6211
+ this.left.include(context, includeChildrenRecursively);
6212
+ }
6198
6213
  this.right.include(context, includeChildrenRecursively);
6199
6214
  }
6200
- render(code, options) {
6201
- this.left.render(code, options);
6202
- this.right.render(code, options);
6215
+ render(code, options, { renderedParentType } = BLANK) {
6216
+ if (this.left.included) {
6217
+ this.left.render(code, options);
6218
+ this.right.render(code, options);
6219
+ }
6220
+ else {
6221
+ this.right.render(code, options, {
6222
+ renderedParentType: renderedParentType || this.parent.type
6223
+ });
6224
+ code.remove(this.start, this.right.start);
6225
+ }
6203
6226
  if (options.format === 'system') {
6204
6227
  const exportNames = this.left.variable && options.exportNamesByVariable.get(this.left.variable);
6205
6228
  if (this.left.type === 'Identifier' && exportNames) {
@@ -18602,6 +18625,7 @@ function getPluginContexts(pluginCache, graph, options, fileEmitter) {
18602
18625
  const inputHookNames = {
18603
18626
  buildEnd: 1,
18604
18627
  buildStart: 1,
18628
+ closeBundle: 1,
18605
18629
  closeWatcher: 1,
18606
18630
  load: 1,
18607
18631
  moduleParsed: 1,
@@ -19944,17 +19968,29 @@ async function rollupInternal(rawInputOptions, watcher) {
19944
19968
  err.watchFiles = watchFiles;
19945
19969
  }
19946
19970
  await graph.pluginDriver.hookParallel('buildEnd', [err]);
19971
+ await graph.pluginDriver.hookParallel('closeBundle', []);
19947
19972
  throw err;
19948
19973
  }
19949
19974
  await graph.pluginDriver.hookParallel('buildEnd', []);
19950
19975
  timeEnd('BUILD', 1);
19951
19976
  const result = {
19952
19977
  cache: useCache ? graph.getCache() : undefined,
19978
+ closed: false,
19979
+ async close() {
19980
+ if (result.closed)
19981
+ return;
19982
+ result.closed = true;
19983
+ await graph.pluginDriver.hookParallel('closeBundle', []);
19984
+ },
19953
19985
  async generate(rawOutputOptions) {
19986
+ if (result.closed)
19987
+ return error(errAlreadyClosed());
19954
19988
  return handleGenerateWrite(false, inputOptions, unsetInputOptions, rawOutputOptions, graph);
19955
19989
  },
19956
19990
  watchFiles: Object.keys(graph.watchFiles),
19957
19991
  async write(rawOutputOptions) {
19992
+ if (result.closed)
19993
+ return error(errAlreadyClosed());
19958
19994
  return handleGenerateWrite(true, inputOptions, unsetInputOptions, rawOutputOptions, graph);
19959
19995
  }
19960
19996
  };
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.34.2
4
- Sun, 06 Dec 2020 05:40:46 GMT - commit 92a2dfa8f18350373aa2329dec45e56bd076909d
3
+ Rollup.js v2.36.1
4
+ Wed, 06 Jan 2021 14:06:54 GMT - commit d6600638c61b5eb7f389681d5fa4af9a1b95823e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -421,6 +421,9 @@ async function watch(command) {
421
421
  loadConfigFile_js.stderr(`\n[${dateTime_1()}] waiting for changes...`);
422
422
  }
423
423
  }
424
+ if ('result' in event && event.result) {
425
+ event.result.close().catch(error => loadConfigFile_js.handleError(error, true));
426
+ }
424
427
  });
425
428
  }
426
429
  function close(code) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.34.2
4
- Sun, 06 Dec 2020 05:40:46 GMT - commit 92a2dfa8f18350373aa2329dec45e56bd076909d
3
+ Rollup.js v2.36.1
4
+ Wed, 06 Jan 2021 14:06:54 GMT - commit d6600638c61b5eb7f389681d5fa4af9a1b95823e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -662,22 +662,13 @@ class Watcher {
662
662
  this.emitter.emit('event', {
663
663
  code: 'START'
664
664
  });
665
- try {
666
- for (const task of this.tasks) {
667
- await task.run();
668
- }
669
- this.running = false;
670
- this.emitter.emit('event', {
671
- code: 'END'
672
- });
673
- }
674
- catch (error) {
675
- this.running = false;
676
- this.emitter.emit('event', {
677
- code: 'ERROR',
678
- error
679
- });
665
+ for (const task of this.tasks) {
666
+ await task.run();
680
667
  }
668
+ this.running = false;
669
+ this.emitter.emit('event', {
670
+ code: 'END'
671
+ });
681
672
  if (this.rerun) {
682
673
  this.rerun = false;
683
674
  this.invalidate();
@@ -738,8 +729,9 @@ class Task {
738
729
  input: this.options.input,
739
730
  output: this.outputFiles
740
731
  });
732
+ let result = null;
741
733
  try {
742
- const result = await rollup.rollupInternal(options, this.watcher.emitter);
734
+ result = await rollup.rollupInternal(options, this.watcher.emitter);
743
735
  if (this.closed) {
744
736
  return;
745
737
  }
@@ -754,18 +746,21 @@ class Task {
754
746
  });
755
747
  }
756
748
  catch (error) {
757
- if (this.closed) {
758
- return;
759
- }
760
- if (Array.isArray(error.watchFiles)) {
761
- for (const id of error.watchFiles) {
762
- this.watchFile(id);
749
+ if (!this.closed) {
750
+ if (Array.isArray(error.watchFiles)) {
751
+ for (const id of error.watchFiles) {
752
+ this.watchFile(id);
753
+ }
754
+ }
755
+ if (error.id) {
756
+ this.cache.modules = this.cache.modules.filter(module => module.id !== error.id);
763
757
  }
764
758
  }
765
- if (error.id) {
766
- this.cache.modules = this.cache.modules.filter(module => module.id !== error.id);
767
- }
768
- throw error;
759
+ this.watcher.emitter.emit('event', {
760
+ code: 'ERROR',
761
+ error,
762
+ result
763
+ });
769
764
  }
770
765
  }
771
766
  updateWatchedFiles(result) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "2.34.2",
3
+ "version": "2.36.1",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -65,7 +65,7 @@
65
65
  "@rollup/plugin-node-resolve": "^10.0.0",
66
66
  "@rollup/plugin-replace": "^2.3.4",
67
67
  "@types/micromatch": "^4.0.1",
68
- "@types/node": "^10.17.48",
68
+ "@types/node": "^10.17.49",
69
69
  "@types/require-relative": "^0.8.0",
70
70
  "@types/signal-exit": "^3.0.0",
71
71
  "@types/yargs-parser": "^15.0.0",
@@ -79,18 +79,18 @@
79
79
  "chokidar": "^3.4.3",
80
80
  "codecov": "^3.8.1",
81
81
  "colorette": "^1.2.1",
82
- "core-js": "^3.8.0",
82
+ "core-js": "^3.8.1",
83
83
  "date-time": "^3.1.0",
84
84
  "es5-shim": "^4.5.14",
85
85
  "es6-shim": "^0.35.6",
86
- "eslint": "^7.14.0",
86
+ "eslint": "^7.15.0",
87
87
  "eslint-plugin-import": "^2.22.1",
88
- "execa": "^4.1.0",
88
+ "execa": "^5.0.0",
89
89
  "fixturify": "^2.1.0",
90
90
  "hash.js": "^1.1.7",
91
- "husky": "^4.3.0",
91
+ "husky": "^4.3.6",
92
92
  "is-reference": "^1.2.1",
93
- "lint-staged": "^10.5.2",
93
+ "lint-staged": "^10.5.3",
94
94
  "locate-character": "^2.0.5",
95
95
  "magic-string": "^0.25.7",
96
96
  "markdownlint-cli": "^0.25.0",
@@ -103,7 +103,7 @@
103
103
  "pretty-ms": "^7.0.1",
104
104
  "require-relative": "^0.8.7",
105
105
  "requirejs": "^2.3.6",
106
- "rollup": "^2.34.0",
106
+ "rollup": "^2.34.2",
107
107
  "rollup-plugin-license": "^2.2.0",
108
108
  "rollup-plugin-string": "^3.0.0",
109
109
  "rollup-plugin-terser": "^7.0.2",
@@ -120,7 +120,7 @@
120
120
  "terser": "^5.5.1",
121
121
  "tslib": "^2.0.3",
122
122
  "tslint": "^6.1.3",
123
- "typescript": "^4.1.2",
123
+ "typescript": "^4.1.3",
124
124
  "url-parse": "^1.4.7",
125
125
  "weak-napi": "^2.0.2",
126
126
  "yargs-parser": "^20.2.4"