rollup 0.25.4 → 0.25.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # rollup changelog
2
2
 
3
+ ## 0.25.8
4
+
5
+ * Unixize entry path ([#586](https://github.com/rollup/rollup/pull/586))
6
+
7
+ ## 0.25.7
8
+
9
+ * Expand deshadowed shorthand properties ([#575](https://github.com/rollup/rollup/issues/575))
10
+ * Allow external files to be non-existent ([#532](https://github.com/rollup/rollup/issues/532))
11
+
12
+ ## 0.25.6
13
+
14
+ * Fix a regression introduced by #566 ([#569](https://github.com/rollup/rollup/issues/569))
15
+ * Prune dead conditional expressions more carefully ([#567](https://github.com/rollup/rollup/issues/567))
16
+
17
+ ## 0.25.5
18
+
19
+ * Make sure shorthand destructuring assignments don't break ([#528](https://github.com/rollup/rollup/issues/528))
20
+ * Allow 'exports' key ([#542](https://github.com/rollup/rollup/issues/542))
21
+ * Ensure `foo. bar` where `foo` is a namespace import is rewritten correctly ([#566](https://github.com/rollup/rollup/issues/566))
22
+ * Fix an edge case for exported globals (e.g. `export { document }`) ([#562](https://github.com/rollup/rollup/issues/562))
23
+
3
24
  ## 0.25.4
4
25
 
5
26
  * Fix misnamed exports of default imports in ES bundles ([#513](https://github.com/rollup/rollup/issues/513))
@@ -1,6 +1,6 @@
1
1
  /*
2
- Rollup.js v0.25.4
3
- Sun Feb 14 2016 10:51:33 GMT-0500 (EST) - commit 7c07a77e2e2d09bd72ea36af1cb6adeb41a20804
2
+ Rollup.js v0.25.8
3
+ Sun Apr 03 2016 10:31:30 GMT-0400 (EDT) - commit 49e9fac201793b7590f70e8ece9434fb71605ee3
4
4
 
5
5
 
6
6
  https://github.com/rollup/rollup
@@ -4353,7 +4353,7 @@
4353
4353
 
4354
4354
  var root = node;
4355
4355
  while (root.type === 'MemberExpression') {
4356
- this.parts.unshift(root.property.name);
4356
+ this.parts.unshift(root.property);
4357
4357
  root = root.object;
4358
4358
  }
4359
4359
 
@@ -4579,9 +4579,9 @@
4579
4579
  // if we have e.g. `foo.bar`, we can optimise
4580
4580
  // the reference by pointing directly to `bar`
4581
4581
  if (reference.parts.length) {
4582
- reference.name = reference.parts.shift();
4583
-
4584
- reference.end += reference.name.length + 1; // TODO this is brittle
4582
+ var ref = reference.parts.shift();
4583
+ reference.name = ref.name;
4584
+ reference.end = ref.end;
4585
4585
 
4586
4586
  var original = this.originals[reference.name];
4587
4587
 
@@ -4907,7 +4907,7 @@
4907
4907
  var readDepth = 0;
4908
4908
 
4909
4909
  walk(this.node, {
4910
- enter: function (node, parent) {
4910
+ enter: function (node, parent, prop) {
4911
4911
  // warn about eval
4912
4912
  if (node.type === 'CallExpression' && node.callee.name === 'eval' && !scope.contains('eval')) {
4913
4913
  module.bundle.onwarn('Use of `eval` (in ' + module.id + ') is discouraged, as it may cause issues with minification. See https://github.com/rollup/rollup/wiki/Troubleshooting#avoiding-eval for more details');
@@ -4924,15 +4924,6 @@
4924
4924
  if (node._scope) scope = node._scope;
4925
4925
  if (/Function/.test(node.type)) readDepth += 1;
4926
4926
 
4927
- // special case – shorthand properties. because node.key === node.value,
4928
- // we can't differentiate once we've descended into the node
4929
- if (node.type === 'Property' && node.shorthand && parent.type !== 'ObjectPattern') {
4930
- var reference = new Reference(node.key, scope);
4931
- reference.isShorthandProperty = true; // TODO feels a bit kludgy
4932
- references.push(reference);
4933
- return this.skip();
4934
- }
4935
-
4936
4927
  var isReassignment = undefined;
4937
4928
 
4938
4929
  if (parent && isModifierNode(parent)) {
@@ -4966,9 +4957,19 @@
4966
4957
  // with the parent scope
4967
4958
  var referenceScope = parent.type === 'FunctionDeclaration' && node === parent.id ? scope.parent : scope;
4968
4959
 
4960
+ var isShorthandProperty = parent.type === 'Property' && parent.shorthand;
4961
+
4962
+ // Since `node.key` can equal `node.value` for shorthand properties
4963
+ // we must use the `prop` argument provided by `estree-walker` to determine
4964
+ // if we're looking at the key or the value.
4965
+ // If they are equal, we'll return to not create duplicate references.
4966
+ if (isShorthandProperty && parent.value === parent.key && prop === 'value') {
4967
+ return;
4968
+ }
4969
+
4969
4970
  var reference = new Reference(node, referenceScope, statement);
4970
4971
  reference.isReassignment = isReassignment;
4971
-
4972
+ reference.isShorthandProperty = isShorthandProperty;
4972
4973
  references.push(reference);
4973
4974
 
4974
4975
  this.skip(); // don't descend from `foo.bar.baz` into `foo.bar`
@@ -5271,7 +5272,7 @@
5271
5272
  var declaration = _this4.declarations[name];
5272
5273
  var statement = declaration.statement;
5273
5274
 
5274
- if (statement.node.type !== 'VariableDeclaration') return;
5275
+ if (!statement || statement.node.type !== 'VariableDeclaration') return;
5275
5276
 
5276
5277
  var init = statement.node.declarations[0].init;
5277
5278
  if (!init || init.type === 'FunctionExpression') return;
@@ -5393,7 +5394,7 @@
5393
5394
  }
5394
5395
 
5395
5396
  walk(ast, {
5396
- enter: function (node, parent, prop) {
5397
+ enter: function (node) {
5397
5398
  // eliminate dead branches early
5398
5399
  if (node.type === 'IfStatement') {
5399
5400
  if (isFalsy(node.test)) {
@@ -5403,7 +5404,15 @@
5403
5404
  _this7.magicString.overwrite(node.alternate.start, node.alternate.end, '{}');
5404
5405
  node.alternate = emptyBlockStatement(node.alternate.start, node.alternate.end);
5405
5406
  }
5406
- } else if (node.type === 'ConditionalExpression') {
5407
+ }
5408
+
5409
+ _this7.magicString.addSourcemapLocation(node.start);
5410
+ _this7.magicString.addSourcemapLocation(node.end);
5411
+ },
5412
+
5413
+ leave: function (node, parent, prop) {
5414
+ // eliminate dead branches early
5415
+ if (node.type === 'ConditionalExpression') {
5407
5416
  if (isFalsy(node.test)) {
5408
5417
  _this7.magicString.remove(node.start, node.alternate.start);
5409
5418
  parent[prop] = node.alternate;
@@ -5413,9 +5422,6 @@
5413
5422
  parent[prop] = node.consequent;
5414
5423
  }
5415
5424
  }
5416
-
5417
- _this7.magicString.addSourcemapLocation(node.start);
5418
- _this7.magicString.addSourcemapLocation(node.end);
5419
5425
  }
5420
5426
  });
5421
5427
 
@@ -5607,7 +5613,8 @@
5607
5613
  if (keys(toDeshadow).length) {
5608
5614
  statement.references.forEach(function (reference) {
5609
5615
  if (!reference.rewritten && reference.name in toDeshadow) {
5610
- magicString.overwrite(reference.start, reference.end, toDeshadow[reference.name], true);
5616
+ var replacement = toDeshadow[reference.name];
5617
+ magicString.overwrite(reference.start, reference.end, reference.isShorthandProperty ? reference.name + ': ' + replacement : replacement, true);
5611
5618
  }
5612
5619
  });
5613
5620
  }
@@ -6571,7 +6578,7 @@
6571
6578
  }
6572
6579
  });
6573
6580
 
6574
- this.entry = options.entry;
6581
+ this.entry = unixizePath(options.entry);
6575
6582
  this.entryModule = null;
6576
6583
 
6577
6584
  this.resolveId = first([function (id) {
@@ -6740,8 +6747,15 @@
6740
6747
 
6741
6748
  return mapSequence(module.sources, function (source) {
6742
6749
  return _this4.resolveId(source, module.id).then(function (resolvedId) {
6743
- // If the `resolvedId` is supposed to be external, make it so.
6744
- var forcedExternal = resolvedId && ~_this4.external.indexOf(resolvedId.replace(/[\/\\]/g, '/'));
6750
+ var externalName = undefined;
6751
+ if (resolvedId) {
6752
+ // If the `resolvedId` is supposed to be external, make it so.
6753
+ externalName = resolvedId.replace(/[\/\\]/g, '/');
6754
+ } else if (isRelative(source)) {
6755
+ // This could be an external, relative dependency, based on the current module's parent dir.
6756
+ externalName = resolve(module.id, '..', source);
6757
+ }
6758
+ var forcedExternal = externalName && ~_this4.external.indexOf(externalName);
6745
6759
 
6746
6760
  if (!resolvedId || forcedExternal) {
6747
6761
  if (!forcedExternal) {
@@ -6923,9 +6937,9 @@
6923
6937
  return Bundle;
6924
6938
  })();
6925
6939
 
6926
- var VERSION = '0.25.4';
6940
+ var VERSION = '0.25.8';
6927
6941
 
6928
- var ALLOWED_KEYS = ['banner', 'dest', 'entry', 'external', 'footer', 'format', 'globals', 'indent', 'intro', 'moduleId', 'moduleName', 'onwarn', 'outro', 'plugins', 'sourceMap'];
6942
+ var ALLOWED_KEYS = ['banner', 'dest', 'entry', 'exports', 'external', 'footer', 'format', 'globals', 'indent', 'intro', 'moduleId', 'moduleName', 'onwarn', 'outro', 'plugins', 'sourceMap'];
6929
6943
 
6930
6944
  function rollup(options) {
6931
6945
  if (!options || !options.entry) {