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/es/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
@@ -13,7 +13,7 @@ import { writeFile as writeFile$1, readdirSync, mkdirSync, readFile as readFile$
13
13
  import { createHash as createHash$1 } from 'crypto';
14
14
  import { EventEmitter } from 'events';
15
15
 
16
- var version = "2.0.3";
16
+ var version = "2.1.0";
17
17
 
18
18
  // Reserved word lists for various dialects of the language
19
19
 
@@ -12385,10 +12385,13 @@ class LogicalExpression extends NodeBase {
12385
12385
  return usedBranch.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin);
12386
12386
  }
12387
12387
  hasEffects(context) {
12388
- if (this.usedBranch === null) {
12389
- return this.left.hasEffects(context) || this.right.hasEffects(context);
12388
+ if (this.left.hasEffects(context)) {
12389
+ return true;
12390
12390
  }
12391
- return this.usedBranch.hasEffects(context);
12391
+ if (this.usedBranch !== this.left) {
12392
+ return this.right.hasEffects(context);
12393
+ }
12394
+ return false;
12392
12395
  }
12393
12396
  hasEffectsWhenAccessedAtPath(path, context) {
12394
12397
  if (path.length === 0)
@@ -15174,8 +15177,8 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
15174
15177
  }
15175
15178
  return sourcemapChain.reduce(linkMap, source);
15176
15179
  }
15177
- function collapseSourcemaps(bundle, file, map, modules, bundleSourcemapChain, excludeContent) {
15178
- const linkMap = getLinkMap(bundle.graph);
15180
+ function collapseSourcemaps(graph, file, map, modules, bundleSourcemapChain, excludeContent) {
15181
+ const linkMap = getLinkMap(graph);
15179
15182
  const moduleSources = modules
15180
15183
  .filter(module => !module.excludeFromSourcemap)
15181
15184
  .map(module => getCollapsedSourcemap(module.id, module.originalCode, module.originalSourcemap, module.sourcemapChain, linkMap));
@@ -15208,7 +15211,7 @@ const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT = {
15208
15211
  cjs: deconflictImportsOther,
15209
15212
  es: deconflictImportsEsm,
15210
15213
  iife: deconflictImportsOther,
15211
- system: deconflictImportsEsm,
15214
+ system: deconflictImportsEsmOrSystem,
15212
15215
  umd: deconflictImportsOther
15213
15216
  };
15214
15217
  function deconflictChunk(modules, dependencies, imports, usedNames, format, interop, preserveModules) {
@@ -15221,7 +15224,20 @@ function deconflictChunk(modules, dependencies, imports, usedNames, format, inte
15221
15224
  module.scope.deconflict(format);
15222
15225
  }
15223
15226
  }
15224
- function deconflictImportsEsm(usedNames, imports, _dependencies, interop) {
15227
+ function deconflictImportsEsm(usedNames, imports, dependencies, interop, preserveModules) {
15228
+ // Deconflict re-exported variables of dependencies when preserveModules is true.
15229
+ // However, this implementation will result in unnecessary variable renaming without
15230
+ // a deeper, wider fix.
15231
+ //
15232
+ // TODO: https://github.com/rollup/rollup/pull/3435#discussion_r390792792
15233
+ if (preserveModules) {
15234
+ for (const chunkOrExternalModule of dependencies) {
15235
+ chunkOrExternalModule.variableName = getSafeName(chunkOrExternalModule.variableName, usedNames);
15236
+ }
15237
+ }
15238
+ deconflictImportsEsmOrSystem(usedNames, imports, dependencies, interop);
15239
+ }
15240
+ function deconflictImportsEsmOrSystem(usedNames, imports, _dependencies, interop) {
15225
15241
  for (const variable of imports) {
15226
15242
  const module = variable.module;
15227
15243
  const name = variable.name;
@@ -15774,6 +15790,7 @@ class Chunk$1 {
15774
15790
  }
15775
15791
  render(options, addons, outputChunk, outputPluginDriver) {
15776
15792
  timeStart('render format', 3);
15793
+ const chunkId = this.id;
15777
15794
  const format = options.format;
15778
15795
  const finalise = finalisers[format];
15779
15796
  if (options.dynamicImportFunction && format !== 'es') {
@@ -15853,11 +15870,11 @@ class Chunk$1 {
15853
15870
  if (options.file)
15854
15871
  file = resolve(options.sourcemapFile || options.file);
15855
15872
  else if (options.dir)
15856
- file = resolve(options.dir, this.id);
15873
+ file = resolve(options.dir, chunkId);
15857
15874
  else
15858
- file = resolve(this.id);
15875
+ file = resolve(chunkId);
15859
15876
  const decodedMap = magicString.generateDecodedMap({});
15860
- map = collapseSourcemaps(this, file, decodedMap, this.usedModules, chunkSourcemapChain, options.sourcemapExcludeSources);
15877
+ map = collapseSourcemaps(this.graph, file, decodedMap, this.usedModules, chunkSourcemapChain, options.sourcemapExcludeSources);
15861
15878
  map.sources = map.sources.map(sourcePath => normalize(options.sourcemapPathTransform ? options.sourcemapPathTransform(sourcePath) : sourcePath));
15862
15879
  timeEnd('sourcemap', 3);
15863
15880
  }
@@ -16458,8 +16475,12 @@ function transform(graph, source, module) {
16458
16475
  });
16459
16476
  }
16460
16477
 
16461
- function normalizeRelativeExternalId(importer, source) {
16462
- return isRelative(source) ? resolve(importer, '..', source) : source;
16478
+ function normalizeRelativeExternalId(source, importer) {
16479
+ return isRelative(source)
16480
+ ? importer
16481
+ ? resolve(importer, '..', source)
16482
+ : resolve(source)
16483
+ : source;
16463
16484
  }
16464
16485
  function getIdMatcher(option) {
16465
16486
  if (option === true) {
@@ -16500,7 +16521,7 @@ class ModuleLoader {
16500
16521
  this.latestLoadModulesPromise = Promise.resolve();
16501
16522
  this.manualChunkModules = {};
16502
16523
  this.nextEntryModuleIndex = 0;
16503
- this.loadEntryModule = (unresolvedId, isEntry) => this.pluginDriver.hookFirst('resolveId', [unresolvedId, undefined]).then(resolveIdResult => {
16524
+ this.loadEntryModule = (unresolvedId, isEntry, importer) => this.pluginDriver.hookFirst('resolveId', [unresolvedId, importer]).then(resolveIdResult => {
16504
16525
  if (resolveIdResult === false ||
16505
16526
  (resolveIdResult && typeof resolveIdResult === 'object' && resolveIdResult.external)) {
16506
16527
  return error(errEntryCannotBeExternal(unresolvedId));
@@ -16523,7 +16544,7 @@ class ModuleLoader {
16523
16544
  addEntryModules(unresolvedEntryModules, isUserDefined) {
16524
16545
  const firstEntryModuleIndex = this.nextEntryModuleIndex;
16525
16546
  this.nextEntryModuleIndex += unresolvedEntryModules.length;
16526
- const loadNewEntryModulesPromise = Promise.all(unresolvedEntryModules.map(({ fileName, id, name }) => this.loadEntryModule(id, true).then(module => {
16547
+ const loadNewEntryModulesPromise = Promise.all(unresolvedEntryModules.map(({ fileName, id, name, importer }) => this.loadEntryModule(id, true, importer).then(module => {
16527
16548
  if (fileName !== null) {
16528
16549
  module.chunkFileNames.add(fileName);
16529
16550
  }
@@ -16566,7 +16587,7 @@ class ModuleLoader {
16566
16587
  unresolvedManualChunks.push({ id, alias });
16567
16588
  }
16568
16589
  }
16569
- const loadNewManualChunkModulesPromise = Promise.all(unresolvedManualChunks.map(({ id }) => this.loadEntryModule(id, false))).then(manualChunkModules => {
16590
+ const loadNewManualChunkModulesPromise = Promise.all(unresolvedManualChunks.map(({ id }) => this.loadEntryModule(id, false, undefined))).then(manualChunkModules => {
16570
16591
  for (let index = 0; index < manualChunkModules.length; index++) {
16571
16592
  this.addModuleToManualChunk(unresolvedManualChunks[index].alias, manualChunkModules[index]);
16572
16593
  }
@@ -16757,11 +16778,11 @@ class ModuleLoader {
16757
16778
  if (this.isExternal(resolveIdResult, importer, true)) {
16758
16779
  external = true;
16759
16780
  }
16760
- id = external ? normalizeRelativeExternalId(importer, resolveIdResult) : resolveIdResult;
16781
+ id = external ? normalizeRelativeExternalId(resolveIdResult, importer) : resolveIdResult;
16761
16782
  }
16762
16783
  }
16763
16784
  else {
16764
- id = normalizeRelativeExternalId(importer, source);
16785
+ id = normalizeRelativeExternalId(source, importer);
16765
16786
  if (resolveIdResult !== false && !this.isExternal(id, importer, true)) {
16766
16787
  return null;
16767
16788
  }
@@ -17111,6 +17132,7 @@ class FileEmitter {
17111
17132
  {
17112
17133
  fileName: emittedChunk.fileName || null,
17113
17134
  id: emittedChunk.id,
17135
+ importer: emittedChunk.importer,
17114
17136
  name: emittedChunk.name || null
17115
17137
  }
17116
17138
  ], false)
@@ -17433,14 +17455,15 @@ class PluginDriver {
17433
17455
 
17434
17456
  function normalizeEntryModules(entryModules) {
17435
17457
  if (typeof entryModules === 'string') {
17436
- return [{ fileName: null, name: null, id: entryModules }];
17458
+ return [{ fileName: null, name: null, id: entryModules, importer: undefined }];
17437
17459
  }
17438
17460
  if (Array.isArray(entryModules)) {
17439
- return entryModules.map(id => ({ fileName: null, name: null, id }));
17461
+ return entryModules.map(id => ({ fileName: null, name: null, id, importer: undefined }));
17440
17462
  }
17441
17463
  return Object.keys(entryModules).map(name => ({
17442
17464
  fileName: null,
17443
17465
  id: entryModules[name],
17466
+ importer: undefined,
17444
17467
  name
17445
17468
  }));
17446
17469
  }
@@ -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