rollup 2.0.3 → 2.1.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/dist/rollup.d.ts CHANGED
@@ -134,6 +134,7 @@ export interface EmittedAsset {
134
134
  export interface EmittedChunk {
135
135
  fileName?: string;
136
136
  id: string;
137
+ importer?: string;
137
138
  name?: string;
138
139
  type: 'chunk';
139
140
  }
@@ -175,11 +176,11 @@ export interface PluginContext extends MinimalPluginContext {
175
176
  parse: (input: string, options: any) => AcornNode;
176
177
  resolve: (
177
178
  source: string,
178
- importer: string,
179
+ importer?: string,
179
180
  options?: { skipSelf: boolean }
180
181
  ) => Promise<ResolvedId | null>;
181
182
  /** @deprecated Use `this.resolve` instead */
182
- resolveId: (source: string, importer: string) => Promise<string | null>;
183
+ resolveId: (source: string, importer?: string) => Promise<string | null>;
183
184
  setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
184
185
  warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
185
186
  }
@@ -216,7 +217,7 @@ export type ResolveIdHook = (
216
217
 
217
218
  export type IsExternal = (
218
219
  source: string,
219
- importer: string,
220
+ importer: string | undefined,
220
221
  isResolved: boolean
221
222
  ) => boolean | null | undefined;
222
223
 
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.0.3
4
- Tue, 10 Mar 2020 07:01:48 GMT - commit 3ef6f073e4b54da2b2e61de5e3fd66f9f7352bca
3
+ Rollup.js v2.1.0
4
+ Wed, 18 Mar 2020 05:17:01 GMT - commit f8bc01847155ccf69f9e772ee99fc0905848548f
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.0.3
4
- Tue, 10 Mar 2020 07:01:48 GMT - commit 3ef6f073e4b54da2b2e61de5e3fd66f9f7352bca
3
+ Rollup.js v2.1.0
4
+ Wed, 18 Mar 2020 05:17:01 GMT - commit f8bc01847155ccf69f9e772ee99fc0905848548f
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.0.3
4
- Tue, 10 Mar 2020 07:01:48 GMT - commit 3ef6f073e4b54da2b2e61de5e3fd66f9f7352bca
3
+ Rollup.js v2.1.0
4
+ Wed, 18 Mar 2020 05:17:01 GMT - commit f8bc01847155ccf69f9e772ee99fc0905848548f
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -28,7 +28,7 @@ var fs = require('fs');
28
28
  var crypto = require('crypto');
29
29
  var events = require('events');
30
30
 
31
- var version = "2.0.3";
31
+ var version = "2.1.0";
32
32
 
33
33
  // Reserved word lists for various dialects of the language
34
34
 
@@ -12404,10 +12404,13 @@ class LogicalExpression extends NodeBase {
12404
12404
  return usedBranch.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin);
12405
12405
  }
12406
12406
  hasEffects(context) {
12407
- if (this.usedBranch === null) {
12408
- return this.left.hasEffects(context) || this.right.hasEffects(context);
12407
+ if (this.left.hasEffects(context)) {
12408
+ return true;
12409
12409
  }
12410
- return this.usedBranch.hasEffects(context);
12410
+ if (this.usedBranch !== this.left) {
12411
+ return this.right.hasEffects(context);
12412
+ }
12413
+ return false;
12411
12414
  }
12412
12415
  hasEffectsWhenAccessedAtPath(path, context) {
12413
12416
  if (path.length === 0)
@@ -15193,8 +15196,8 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
15193
15196
  }
15194
15197
  return sourcemapChain.reduce(linkMap, source);
15195
15198
  }
15196
- function collapseSourcemaps(bundle, file, map, modules, bundleSourcemapChain, excludeContent) {
15197
- const linkMap = getLinkMap(bundle.graph);
15199
+ function collapseSourcemaps(graph, file, map, modules, bundleSourcemapChain, excludeContent) {
15200
+ const linkMap = getLinkMap(graph);
15198
15201
  const moduleSources = modules
15199
15202
  .filter(module => !module.excludeFromSourcemap)
15200
15203
  .map(module => getCollapsedSourcemap(module.id, module.originalCode, module.originalSourcemap, module.sourcemapChain, linkMap));
@@ -15227,7 +15230,7 @@ const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT = {
15227
15230
  cjs: deconflictImportsOther,
15228
15231
  es: deconflictImportsEsm,
15229
15232
  iife: deconflictImportsOther,
15230
- system: deconflictImportsEsm,
15233
+ system: deconflictImportsEsmOrSystem,
15231
15234
  umd: deconflictImportsOther
15232
15235
  };
15233
15236
  function deconflictChunk(modules, dependencies, imports, usedNames, format, interop, preserveModules) {
@@ -15240,7 +15243,20 @@ function deconflictChunk(modules, dependencies, imports, usedNames, format, inte
15240
15243
  module.scope.deconflict(format);
15241
15244
  }
15242
15245
  }
15243
- function deconflictImportsEsm(usedNames, imports, _dependencies, interop) {
15246
+ function deconflictImportsEsm(usedNames, imports, dependencies, interop, preserveModules) {
15247
+ // Deconflict re-exported variables of dependencies when preserveModules is true.
15248
+ // However, this implementation will result in unnecessary variable renaming without
15249
+ // a deeper, wider fix.
15250
+ //
15251
+ // TODO: https://github.com/rollup/rollup/pull/3435#discussion_r390792792
15252
+ if (preserveModules) {
15253
+ for (const chunkOrExternalModule of dependencies) {
15254
+ chunkOrExternalModule.variableName = getSafeName(chunkOrExternalModule.variableName, usedNames);
15255
+ }
15256
+ }
15257
+ deconflictImportsEsmOrSystem(usedNames, imports, dependencies, interop);
15258
+ }
15259
+ function deconflictImportsEsmOrSystem(usedNames, imports, _dependencies, interop) {
15244
15260
  for (const variable of imports) {
15245
15261
  const module = variable.module;
15246
15262
  const name = variable.name;
@@ -15793,6 +15809,7 @@ class Chunk$1 {
15793
15809
  }
15794
15810
  render(options, addons, outputChunk, outputPluginDriver) {
15795
15811
  timeStart('render format', 3);
15812
+ const chunkId = this.id;
15796
15813
  const format = options.format;
15797
15814
  const finalise = finalisers[format];
15798
15815
  if (options.dynamicImportFunction && format !== 'es') {
@@ -15872,11 +15889,11 @@ class Chunk$1 {
15872
15889
  if (options.file)
15873
15890
  file = path.resolve(options.sourcemapFile || options.file);
15874
15891
  else if (options.dir)
15875
- file = path.resolve(options.dir, this.id);
15892
+ file = path.resolve(options.dir, chunkId);
15876
15893
  else
15877
- file = path.resolve(this.id);
15894
+ file = path.resolve(chunkId);
15878
15895
  const decodedMap = magicString.generateDecodedMap({});
15879
- map = collapseSourcemaps(this, file, decodedMap, this.usedModules, chunkSourcemapChain, options.sourcemapExcludeSources);
15896
+ map = collapseSourcemaps(this.graph, file, decodedMap, this.usedModules, chunkSourcemapChain, options.sourcemapExcludeSources);
15880
15897
  map.sources = map.sources.map(sourcePath => normalize(options.sourcemapPathTransform ? options.sourcemapPathTransform(sourcePath) : sourcePath));
15881
15898
  timeEnd('sourcemap', 3);
15882
15899
  }
@@ -16477,8 +16494,12 @@ function transform(graph, source, module) {
16477
16494
  });
16478
16495
  }
16479
16496
 
16480
- function normalizeRelativeExternalId(importer, source) {
16481
- return isRelative(source) ? path.resolve(importer, '..', source) : source;
16497
+ function normalizeRelativeExternalId(source, importer) {
16498
+ return isRelative(source)
16499
+ ? importer
16500
+ ? path.resolve(importer, '..', source)
16501
+ : path.resolve(source)
16502
+ : source;
16482
16503
  }
16483
16504
  function getIdMatcher(option) {
16484
16505
  if (option === true) {
@@ -16519,7 +16540,7 @@ class ModuleLoader {
16519
16540
  this.latestLoadModulesPromise = Promise.resolve();
16520
16541
  this.manualChunkModules = {};
16521
16542
  this.nextEntryModuleIndex = 0;
16522
- this.loadEntryModule = (unresolvedId, isEntry) => this.pluginDriver.hookFirst('resolveId', [unresolvedId, undefined]).then(resolveIdResult => {
16543
+ this.loadEntryModule = (unresolvedId, isEntry, importer) => this.pluginDriver.hookFirst('resolveId', [unresolvedId, importer]).then(resolveIdResult => {
16523
16544
  if (resolveIdResult === false ||
16524
16545
  (resolveIdResult && typeof resolveIdResult === 'object' && resolveIdResult.external)) {
16525
16546
  return error(errEntryCannotBeExternal(unresolvedId));
@@ -16542,7 +16563,7 @@ class ModuleLoader {
16542
16563
  addEntryModules(unresolvedEntryModules, isUserDefined) {
16543
16564
  const firstEntryModuleIndex = this.nextEntryModuleIndex;
16544
16565
  this.nextEntryModuleIndex += unresolvedEntryModules.length;
16545
- const loadNewEntryModulesPromise = Promise.all(unresolvedEntryModules.map(({ fileName, id, name }) => this.loadEntryModule(id, true).then(module => {
16566
+ const loadNewEntryModulesPromise = Promise.all(unresolvedEntryModules.map(({ fileName, id, name, importer }) => this.loadEntryModule(id, true, importer).then(module => {
16546
16567
  if (fileName !== null) {
16547
16568
  module.chunkFileNames.add(fileName);
16548
16569
  }
@@ -16585,7 +16606,7 @@ class ModuleLoader {
16585
16606
  unresolvedManualChunks.push({ id, alias });
16586
16607
  }
16587
16608
  }
16588
- const loadNewManualChunkModulesPromise = Promise.all(unresolvedManualChunks.map(({ id }) => this.loadEntryModule(id, false))).then(manualChunkModules => {
16609
+ const loadNewManualChunkModulesPromise = Promise.all(unresolvedManualChunks.map(({ id }) => this.loadEntryModule(id, false, undefined))).then(manualChunkModules => {
16589
16610
  for (let index = 0; index < manualChunkModules.length; index++) {
16590
16611
  this.addModuleToManualChunk(unresolvedManualChunks[index].alias, manualChunkModules[index]);
16591
16612
  }
@@ -16776,11 +16797,11 @@ class ModuleLoader {
16776
16797
  if (this.isExternal(resolveIdResult, importer, true)) {
16777
16798
  external = true;
16778
16799
  }
16779
- id = external ? normalizeRelativeExternalId(importer, resolveIdResult) : resolveIdResult;
16800
+ id = external ? normalizeRelativeExternalId(resolveIdResult, importer) : resolveIdResult;
16780
16801
  }
16781
16802
  }
16782
16803
  else {
16783
- id = normalizeRelativeExternalId(importer, source);
16804
+ id = normalizeRelativeExternalId(source, importer);
16784
16805
  if (resolveIdResult !== false && !this.isExternal(id, importer, true)) {
16785
16806
  return null;
16786
16807
  }
@@ -17130,6 +17151,7 @@ class FileEmitter {
17130
17151
  {
17131
17152
  fileName: emittedChunk.fileName || null,
17132
17153
  id: emittedChunk.id,
17154
+ importer: emittedChunk.importer,
17133
17155
  name: emittedChunk.name || null
17134
17156
  }
17135
17157
  ], false)
@@ -17452,14 +17474,15 @@ class PluginDriver {
17452
17474
 
17453
17475
  function normalizeEntryModules(entryModules) {
17454
17476
  if (typeof entryModules === 'string') {
17455
- return [{ fileName: null, name: null, id: entryModules }];
17477
+ return [{ fileName: null, name: null, id: entryModules, importer: undefined }];
17456
17478
  }
17457
17479
  if (Array.isArray(entryModules)) {
17458
- return entryModules.map(id => ({ fileName: null, name: null, id }));
17480
+ return entryModules.map(id => ({ fileName: null, name: null, id, importer: undefined }));
17459
17481
  }
17460
17482
  return Object.keys(entryModules).map(name => ({
17461
17483
  fileName: null,
17462
17484
  id: entryModules[name],
17485
+ importer: undefined,
17463
17486
  name
17464
17487
  }));
17465
17488
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.0.3
4
- Tue, 10 Mar 2020 07:01:48 GMT - commit 3ef6f073e4b54da2b2e61de5e3fd66f9f7352bca
3
+ Rollup.js v2.1.0
4
+ Wed, 18 Mar 2020 05:17:01 GMT - commit f8bc01847155ccf69f9e772ee99fc0905848548f
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -70,7 +70,7 @@
70
70
  "@rollup/plugin-node-resolve": "^7.1.1",
71
71
  "@rollup/plugin-replace": "^2.3.1",
72
72
  "@types/micromatch": "^4.0.1",
73
- "@types/node": "^13.9.0",
73
+ "@types/node": "^13.9.1",
74
74
  "@types/yargs-parser": "^15.0.0",
75
75
  "acorn": "^7.1.1",
76
76
  "acorn-export-ns-from": "^0.1.0",
@@ -107,10 +107,10 @@
107
107
  "pretty-ms": "^6.0.1",
108
108
  "require-relative": "^0.8.7",
109
109
  "requirejs": "^2.3.6",
110
- "rollup": "^2.0.0",
110
+ "rollup": "^2.0.6",
111
111
  "rollup-plugin-license": "^0.13.0",
112
112
  "rollup-plugin-string": "^3.0.0",
113
- "rollup-plugin-terser": "^5.2.0",
113
+ "rollup-plugin-terser": "^5.3.0",
114
114
  "rollup-plugin-typescript": "^1.0.1",
115
115
  "rollup-pluginutils": "^2.8.2",
116
116
  "sander": "^0.6.0",
@@ -119,13 +119,13 @@
119
119
  "source-map": "^0.7.3",
120
120
  "source-map-support": "^0.5.16",
121
121
  "sourcemap-codec": "^1.4.8",
122
- "systemjs": "^6.2.5",
123
- "terser": "^4.6.6",
122
+ "systemjs": "^6.2.6",
123
+ "terser": "^4.6.7",
124
124
  "tslib": "^1.11.1",
125
- "tslint": "^6.0.0",
125
+ "tslint": "^6.1.0",
126
126
  "typescript": "^3.8.3",
127
127
  "url-parse": "^1.4.7",
128
- "yargs-parser": "^16.1.0"
128
+ "yargs-parser": "^18.1.1"
129
129
  },
130
130
  "files": [
131
131
  "dist/**/*.js",