rollup 0.36.0 → 0.36.4

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,27 @@
1
1
  # rollup changelog
2
2
 
3
+ ## 0.36.4
4
+
5
+ * Only depend on program-level call expressions ([#977](https://github.com/rollup/rollup/issues/977))
6
+
7
+ ## 0.36.3
8
+
9
+ * Add `legacy` option for IE8 support ([#989](https://github.com/rollup/rollup/pull/989))
10
+
11
+ ## 0.36.2
12
+
13
+ * Insert semicolons where necessary to fix broken code ([#1004](https://github.com/rollup/rollup/issues/1004))
14
+ * Include module ID and location when warning about top-level `this` ([#1012](https://github.com/rollup/rollup/pull/1012))
15
+ * More informative error for missing exports ([#1033](https://github.com/rollup/rollup/issues/1033))
16
+ * `options.moduleContext` for per-module context overrides ([#1023](https://github.com/rollup/rollup/pull/1023))
17
+
18
+ ## 0.36.1
19
+
20
+ * Include naked block statements ([#981](https://github.com/rollup/rollup/issues/981))
21
+ * Correctly include falsy alternate statements in optimised if blocks ([#973](https://github.com/rollup/rollup/issues/973))
22
+ * Prevent omission of default exports that are only used by the exporting module ([#967](https://github.com/rollup/rollup/pull/967))
23
+ * Prevent warning on `auto` exports with ES output ([#966](https://github.com/rollup/rollup/pull/966))
24
+
3
25
  ## 0.36.0
4
26
 
5
27
  * `export { foo as default }` no longer creates a live binding ([#860](https://github.com/rollup/rollup/issues/860))
package/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
  alt="license">
15
15
  </a>
16
16
  <a href="https://david-dm.org/rollup/rollup">
17
- <img src="https://david-dm.org/rollup/rollup.svg"
17
+ <img src="https://david-dm.org/rollup/rollup/status.svg"
18
18
  alt="dependency status">
19
19
  </a>
20
20
  <a href="https://codecov.io/github/rollup/rollup?branch=master">
@@ -36,6 +36,8 @@
36
36
 
37
37
  Rollup can be used via a [JavaScript API](https://github.com/rollup/rollup/wiki/JavaScript-API) or a [Command Line Interface](https://github.com/rollup/rollup/wiki/Command-Line-Interface). Install with `npm install -g rollup` and run `rollup --help` to get started.
38
38
 
39
+ If the command line's not your jam, there's also a [step-by-step tutorial video series](https://code.lengstorf.com/learn-rollup-js/) (with accompanying written walkthrough).
40
+
39
41
  [Dive into the wiki](https://github.com/rollup/rollup/wiki) when you're ready to learn more about Rollup and ES6 modules.
40
42
 
41
43
 
package/bin/rollup CHANGED
@@ -257,7 +257,7 @@ var minimist = interopDefault(index);
257
257
 
258
258
  var help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] <entry file>\n\nBasic options:\n\n-v, --version Show version number\n-h, --help Show this help message\n-c, --config Use this config file (if argument is used but value\n is unspecified, defaults to rollup.config.js)\n-w, --watch Watch files in bundle and rebuild on changes\n-i, --input Input (alternative to <entry file>)\n-o, --output <output> Output (if absent, prints to stdout)\n-f, --format [es] Type of output (amd, cjs, es, iife, umd)\n-e, --external Comma-separate list of module IDs to exclude\n-g, --globals Comma-separate list of `module ID:Global` pairs\n Any module IDs defined here are added to external\n-n, --name Name for UMD export\n-u, --id ID for AMD module (default is anonymous)\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n--no-strict Don't emit a `\"use strict\";` in the generated modules.\n--no-indent Don't indent result\n--environment <values> Settings passed to config file (see example)\n--no-conflict Generate a noConflict method for UMD globals\n--intro Content to insert at top of bundle (inside wrapper)\n--outro Content to insert at end of bundle (inside wrapper)\n--banner Content to insert at top of bundle (outside wrapper)\n--footer Content to insert at end of bundle (outside wrapper)\n\nExamples:\n\n# use settings in config file\nrollup -c\n\n# in config file, process.env.INCLUDE_DEPS === 'true'\n# and process.env.BUILD === 'production'\nrollup -c --environment INCLUDE_DEPS,BUILD:production\n\n# create CommonJS bundle.js from src/main.js\nrollup --format=cjs --output=bundle.js -- src/main.js\n\n# create self-executing IIFE using `window.jQuery`\n# and `window._` as external globals\nrollup -f iife --globals jquery:jQuery,lodash:_ \\\n -i src/app.js -o build/app.js -m build/app.js.map\n\nNotes:\n\n* When piping to stdout, only inline sourcemaps are permitted\n\nFor more information visit https://github.com/rollup/rollup/wiki\n";
259
259
 
260
- var version = "0.36.0";
260
+ var version = "0.36.4";
261
261
 
262
262
  var index$1 = createCommonjsModule(function (module) {
263
263
  /*
@@ -1,6 +1,6 @@
1
1
  /*
2
- Rollup.js v0.36.0
3
- Sun Sep 18 2016 17:58:06 GMT-0400 (EDT) - commit 152afb9732975188c7f4bf716c143da549afd432
2
+ Rollup.js v0.36.4
3
+ Wed Nov 23 2016 09:01:44 GMT-0500 (EST) - commit fca14dbab102a9fa8efc7249287e2145583712ea
4
4
 
5
5
 
6
6
  https://github.com/rollup/rollup
@@ -224,9 +224,7 @@ function mapSequence ( array, fn ) {
224
224
  return promise.then( function () { return results; } );
225
225
  }
226
226
 
227
- function validateKeys ( object, allowedKeys ) {
228
- var actualKeys = keys( object );
229
-
227
+ function validateKeys ( actualKeys, allowedKeys ) {
230
228
  var i = actualKeys.length;
231
229
 
232
230
  while ( i-- ) {
@@ -5049,6 +5047,11 @@ function makeLegalIdentifier ( str ) {
5049
5047
  return str;
5050
5048
  }
5051
5049
 
5050
+ function relativeId ( id ) {
5051
+ if ( typeof process === 'undefined' ) return id;
5052
+ return id.replace( process.cwd(), '' ).replace( /^[\/\\]/, '' );
5053
+ }
5054
+
5052
5055
  // properties are for debugging purposes only
5053
5056
  var ARRAY = { ARRAY: true, toString: function () { return '[[ARRAY]]'; } };
5054
5057
  var NUMBER = { NUMBER: true, toString: function () { return '[[NUMBER]]'; } };
@@ -5093,7 +5096,7 @@ SyntheticNamespaceDeclaration.prototype.getName = function getName () {
5093
5096
  return this.name;
5094
5097
  };
5095
5098
 
5096
- SyntheticNamespaceDeclaration.prototype.renderBlock = function renderBlock ( es, indentString ) {
5099
+ SyntheticNamespaceDeclaration.prototype.renderBlock = function renderBlock ( es, legacy, indentString ) {
5097
5100
  var this$1 = this;
5098
5101
 
5099
5102
  var members = keys( this.originals ).map( function (name) {
@@ -5106,7 +5109,8 @@ SyntheticNamespaceDeclaration.prototype.renderBlock = function renderBlock ( es,
5106
5109
  return ("" + indentString + name + ": " + (original.getName( es )));
5107
5110
  });
5108
5111
 
5109
- return ((this.module.bundle.varOrConst) + " " + (this.getName( es )) + " = Object.freeze({\n" + (members.join( ',\n' )) + "\n});\n\n");
5112
+ var callee = legacy ? "(Object.freeze || Object)" : "Object.freeze";
5113
+ return ((this.module.bundle.varOrConst) + " " + (this.getName( es )) + " = " + callee + "({\n" + (members.join( ',\n' )) + "\n});\n\n");
5110
5114
  };
5111
5115
 
5112
5116
  var ExternalDeclaration = function ExternalDeclaration ( module, name ) {
@@ -5256,6 +5260,12 @@ Node$1.prototype.initialise = function initialise ( scope ) {
5256
5260
  this.eachChild( function (child) { return child.initialise( this$1.scope || scope ); } );
5257
5261
  };
5258
5262
 
5263
+ Node$1.prototype.insertSemicolon = function insertSemicolon ( code ) {
5264
+ if ( code.original[ this.end - 1 ] !== ';' ) {
5265
+ code.insertLeft( this.end, ';' );
5266
+ }
5267
+ };
5268
+
5259
5269
  Node$1.prototype.locate = function locate () {
5260
5270
  // useful for debugging
5261
5271
  var location = getLocation( this.module.code, this.start );
@@ -5324,7 +5334,7 @@ Parameter.prototype.getName = function getName () {
5324
5334
  };
5325
5335
 
5326
5336
  var Scope = function Scope ( options ) {
5327
- options = options || {};
5337
+ if ( options === void 0 ) options = {};
5328
5338
 
5329
5339
  this.parent = options.parent;
5330
5340
  this.isBlockScope = !!options.isBlockScope;
@@ -5699,6 +5709,16 @@ var BlockStatement = (function (Statement) {
5699
5709
  }
5700
5710
  };
5701
5711
 
5712
+ BlockStatement.prototype.render = function render ( code, es ) {
5713
+ if (this.body.length) {
5714
+ for ( var node of this.body ) {
5715
+ node.render( code, es );
5716
+ }
5717
+ } else {
5718
+ Statement.prototype.render.call(this, code, es);
5719
+ }
5720
+ };
5721
+
5702
5722
  return BlockStatement;
5703
5723
  }(Statement));
5704
5724
 
@@ -5886,7 +5906,9 @@ var CallExpression = (function (Node) {
5886
5906
  };
5887
5907
 
5888
5908
  CallExpression.prototype.initialise = function initialise ( scope ) {
5889
- this.module.bundle.dependentExpressions.push( this );
5909
+ if ( isProgramLevel( this ) ) {
5910
+ this.module.bundle.dependentExpressions.push( this );
5911
+ }
5890
5912
  Node.prototype.initialise.call( this, scope );
5891
5913
  };
5892
5914
 
@@ -5897,6 +5919,17 @@ var CallExpression = (function (Node) {
5897
5919
  return CallExpression;
5898
5920
  }(Node$1));
5899
5921
 
5922
+ function isProgramLevel ( node ) {
5923
+ do {
5924
+ if ( node.type === 'Program' ) {
5925
+ return true;
5926
+ }
5927
+ node = node.parent;
5928
+ } while ( node && !/Function/.test( node.type ) );
5929
+
5930
+ return false;
5931
+ }
5932
+
5900
5933
  // TODO is this basically identical to FunctionDeclaration?
5901
5934
  var ClassDeclaration = (function (Node) {
5902
5935
  function ClassDeclaration () {
@@ -6153,7 +6186,7 @@ var ExportDefaultDeclaration = (function (Node) {
6153
6186
  var treeshake = this.module.bundle.treeshake;
6154
6187
  var name = this.getName( es );
6155
6188
 
6156
- if ( this.shouldInclude ) {
6189
+ if ( this.shouldInclude || this.declaration.activated ) {
6157
6190
  if ( this.activated ) {
6158
6191
  if ( functionOrClassDeclaration.test( this.declaration.type ) ) {
6159
6192
  if ( this.declaration.id ) {
@@ -6171,6 +6204,8 @@ var ExportDefaultDeclaration = (function (Node) {
6171
6204
  } else {
6172
6205
  code.overwrite( this.start, this.declaration.start, ((this.module.bundle.varOrConst) + " " + name + " = ") );
6173
6206
  }
6207
+
6208
+ this.insertSemicolon( code );
6174
6209
  }
6175
6210
  } else {
6176
6211
  // remove `var foo` from `var foo = bar()`, if `foo` is unused
@@ -6180,7 +6215,7 @@ var ExportDefaultDeclaration = (function (Node) {
6180
6215
  Node.prototype.render.call( this, code, es );
6181
6216
  } else {
6182
6217
  if ( treeshake ) {
6183
- if ( functionOrClassDeclaration.test( this.declaration.type ) && !this.declaration.activated ) {
6218
+ if ( functionOrClassDeclaration.test( this.declaration.type ) ) {
6184
6219
  code.remove( this.leadingCommentStart || this.start, this.next || this.end );
6185
6220
  } else {
6186
6221
  var hasEffects = this.declaration.hasEffects( this.module.scope );
@@ -6290,11 +6325,16 @@ var ExportNamedDeclaration = (function (Node) {
6290
6325
  var ExpressionStatement = (function (Statement) {
6291
6326
  function ExpressionStatement () {
6292
6327
  Statement.apply(this, arguments);
6293
- }if ( Statement ) ExpressionStatement.__proto__ = Statement;
6328
+ }
6329
+
6330
+ if ( Statement ) ExpressionStatement.__proto__ = Statement;
6294
6331
  ExpressionStatement.prototype = Object.create( Statement && Statement.prototype );
6295
6332
  ExpressionStatement.prototype.constructor = ExpressionStatement;
6296
6333
 
6297
-
6334
+ ExpressionStatement.prototype.render = function render ( code, es ) {
6335
+ Statement.prototype.render.call( this, code, es );
6336
+ if ( this.shouldInclude ) this.insertSemicolon( code );
6337
+ };
6298
6338
 
6299
6339
  return ExpressionStatement;
6300
6340
  }(Statement));
@@ -6557,6 +6597,16 @@ var Identifier = (function (Node) {
6557
6597
  return Identifier;
6558
6598
  }(Node$1));
6559
6599
 
6600
+ // Statement types which may contain if-statements as direct children.
6601
+ var statementsWithIfStatements = new Set([
6602
+ 'DoWhileStatement',
6603
+ 'ForInStatement',
6604
+ 'ForOfStatement',
6605
+ 'ForStatement',
6606
+ 'IfStatement',
6607
+ 'WhileStatement'
6608
+ ]);
6609
+
6560
6610
  // TODO DRY this out
6561
6611
  var IfStatement = (function (Statement) {
6562
6612
  function IfStatement () {
@@ -6578,7 +6628,9 @@ var IfStatement = (function (Statement) {
6578
6628
  else if ( this.testValue ) {
6579
6629
  this.consequent.initialise( scope );
6580
6630
  this.alternate = null;
6581
- } else {
6631
+ }
6632
+
6633
+ else {
6582
6634
  if ( this.alternate ) this.alternate.initialise( scope );
6583
6635
  this.consequent = null;
6584
6636
  }
@@ -6605,9 +6657,18 @@ var IfStatement = (function (Statement) {
6605
6657
  code.remove( this.start, this.consequent.start );
6606
6658
  code.remove( this.consequent.end, this.end );
6607
6659
  this.consequent.render( code, es );
6608
- } else {
6660
+ }
6661
+
6662
+ else {
6609
6663
  code.remove( this.start, this.alternate ? this.alternate.start : this.next || this.end );
6610
- if ( this.alternate ) this.alternate.render( code, es );
6664
+
6665
+ if ( this.alternate ) {
6666
+ this.alternate.render( code, es );
6667
+ }
6668
+
6669
+ else if ( statementsWithIfStatements.has( this.parent.type ) ) {
6670
+ code.insertRight( this.start, '{}' );
6671
+ }
6611
6672
  }
6612
6673
  }
6613
6674
  }
@@ -6835,6 +6896,8 @@ var TemplateLiteral = (function (Node) {
6835
6896
  return TemplateLiteral;
6836
6897
  }(Node$1));
6837
6898
 
6899
+ var warning = "The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten. See https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined for more information";
6900
+
6838
6901
  var ThisExpression = (function (Node) {
6839
6902
  function ThisExpression () {
6840
6903
  Node.apply(this, arguments);
@@ -6848,9 +6911,13 @@ var ThisExpression = (function (Node) {
6848
6911
  var lexicalBoundary = scope.findLexicalBoundary();
6849
6912
 
6850
6913
  if ( lexicalBoundary.isModuleScope ) {
6851
- this.alias = this.module.bundle.context;
6914
+ this.alias = this.module.context;
6852
6915
  if ( this.alias === 'undefined' ) {
6853
- this.module.bundle.onwarn( 'The `this` keyword is equivalent to `undefined` at the top level of an ES module, and has been rewritten' );
6916
+ var ref = getLocation( this.module.code, this.start );
6917
+ var line = ref.line;
6918
+ var column = ref.column;
6919
+ var detail = (relativeId( this.module.id )) + " (" + line + ":" + (column + 1) + ")"; // use one-based column number convention
6920
+ this.module.bundle.onwarn( (detail + " " + warning) );
6854
6921
  }
6855
6922
  }
6856
6923
  };
@@ -7081,7 +7148,7 @@ function getSeparator ( code, start ) {
7081
7148
  return (";\n" + lineStart);
7082
7149
  }
7083
7150
 
7084
- var forStatement = /^For(?:Of|In)Statement/;
7151
+ var forStatement = /^For(?:Of|In)?Statement/;
7085
7152
 
7086
7153
  var VariableDeclaration = (function (Node) {
7087
7154
  function VariableDeclaration () {
@@ -7171,9 +7238,16 @@ var VariableDeclaration = (function (Node) {
7171
7238
 
7172
7239
  if ( treeshake && empty ) {
7173
7240
  code.remove( this.leadingCommentStart || this.start, this.next || this.end );
7174
- } else if ( this.end > c ) {
7175
- var hasSemicolon = code.original[ this.end - 1 ] === ';';
7176
- code.overwrite( c, this.end, hasSemicolon ? ';' : '' );
7241
+ } else {
7242
+ // always include a semi-colon (https://github.com/rollup/rollup/pull/1013),
7243
+ // unless it's a var declaration in a loop head
7244
+ var needsSemicolon = !forStatement.test( this.parent.type );
7245
+
7246
+ if ( this.end > c ) {
7247
+ code.overwrite( c, this.end, needsSemicolon ? ';' : '' );
7248
+ } else if ( needsSemicolon ) {
7249
+ this.insertSemicolon( code );
7250
+ }
7177
7251
  }
7178
7252
  };
7179
7253
 
@@ -7390,6 +7464,7 @@ var Module = function Module (ref) {
7390
7464
  this.bundle = bundle;
7391
7465
  this.id = id;
7392
7466
  this.excludeFromSourcemap = /\0/.test( id );
7467
+ this.context = bundle.getModuleContext( id );
7393
7468
 
7394
7469
  // all dependencies
7395
7470
  this.sources = [];
@@ -7538,11 +7613,11 @@ Module.prototype.addImport = function addImport ( node ) {
7538
7613
  if ( !~this.sources.indexOf( source ) ) this.sources.push( source );
7539
7614
 
7540
7615
  node.specifiers.forEach( function (specifier) {
7541
- var localName = specifier.local.name;
7616
+ var localName = specifier.local.name;
7542
7617
 
7543
7618
  if ( this$1.imports[ localName ] ) {
7544
7619
  var err = new Error( ("Duplicated import '" + localName + "'") );
7545
- err.file = this$1.id;
7620
+ err.file = this$1.id;
7546
7621
  err.loc = getLocation( this$1.code, specifier.start );
7547
7622
  throw err;
7548
7623
  }
@@ -7629,18 +7704,18 @@ Module.prototype.findParent = function findParent () {
7629
7704
 
7630
7705
  Module.prototype.findScope = function findScope () {
7631
7706
  return this.scope;
7632
- };
7707
+ };
7633
7708
 
7634
- Module.prototype.getExports = function getExports () {
7635
- var exports = blank();
7709
+ Module.prototype.getExports = function getExports () {
7710
+ var exports = blank();
7636
7711
 
7637
- keys( this.exports ).forEach( function (name) {
7712
+ keys( this.exports ).forEach( function (name) {
7638
7713
  exports[ name ] = true;
7639
7714
  });
7640
7715
 
7641
7716
  keys( this.reexports ).forEach( function (name) {
7642
- exports[ name ] = true;
7643
- });
7717
+ exports[ name ] = true;
7718
+ });
7644
7719
 
7645
7720
  this.exportAllModules.forEach( function (module) {
7646
7721
  if ( module.isExternal ) return; // TODO
@@ -7661,7 +7736,7 @@ Module.prototype.namespace = function namespace () {
7661
7736
  return this.declarations['*'];
7662
7737
  };
7663
7738
 
7664
- Module.prototype.render = function render ( es ) {
7739
+ Module.prototype.render = function render ( es, legacy ) {
7665
7740
  var magicString = this.magicString.clone();
7666
7741
 
7667
7742
  for ( var node of this.ast.body ) {
@@ -7669,7 +7744,7 @@ Module.prototype.render = function render ( es ) {
7669
7744
  }
7670
7745
 
7671
7746
  if ( this.namespace().needsNamespaceBlock ) {
7672
- magicString.append( '\n\n' + this.namespace().renderBlock( es, '\t' ) ); // TODO use correct indentation
7747
+ magicString.append( '\n\n' + this.namespace().renderBlock( es, legacy, '\t' ) ); // TODO use correct indentation
7673
7748
  }
7674
7749
 
7675
7750
  return magicString.trim();
@@ -7713,7 +7788,7 @@ Module.prototype.trace = function trace ( name ) {
7713
7788
 
7714
7789
  var declaration = otherModule.traceExport( importDeclaration.name );
7715
7790
 
7716
- if ( !declaration ) throw new Error( ("Module " + (otherModule.id) + " does not export " + (importDeclaration.name) + " (imported by " + (this.id) + ")") );
7791
+ if ( !declaration ) throw new Error( ("'" + (importDeclaration.name) + "' is not exported by " + (relativeId( otherModule.id )) + " (imported by " + (relativeId( this.id )) + "). For help fixing this error see https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module") );
7717
7792
  return declaration;
7718
7793
  }
7719
7794
 
@@ -8216,7 +8291,11 @@ function badExports ( option, keys ) {
8216
8291
  throw new Error( ("'" + option + "' was specified for options.exports, but entry module has following exports: " + (keys.join(', '))) );
8217
8292
  }
8218
8293
 
8219
- function getExportMode ( bundle, exportMode, moduleName ) {
8294
+ function getExportMode ( bundle, ref ) {
8295
+ var exportMode = ref.exports;
8296
+ var moduleName = ref.moduleName;
8297
+ var format = ref.format;
8298
+
8220
8299
  var exportKeys = keys( bundle.entryModule.exports )
8221
8300
  .concat( keys( bundle.entryModule.reexports ) )
8222
8301
  .concat( bundle.entryModule.exportAllSources ); // not keys, but makes our job easier this way
@@ -8235,7 +8314,7 @@ function getExportMode ( bundle, exportMode, moduleName ) {
8235
8314
  } else if ( exportKeys.length === 1 && exportKeys[0] === 'default' ) {
8236
8315
  exportMode = 'default';
8237
8316
  } else {
8238
- if ( bundle.entryModule.exports.default ) {
8317
+ if ( bundle.entryModule.exports.default && format !== 'es') {
8239
8318
  bundle.onwarn( ("Using named and default exports together. Consumers of your bundle will have to use " + (moduleName || 'bundle') + "['default'] to access the default export, which may not be what you want. Use `exports: 'named'` to disable this warning. See https://github.com/rollup/rollup/wiki/JavaScript-API#exports for more information") );
8240
8319
  }
8241
8320
  exportMode = 'named';
@@ -8573,11 +8652,10 @@ var Bundle = function Bundle ( options ) {
8573
8652
 
8574
8653
  this.plugins = ensureArray( options.plugins );
8575
8654
 
8576
- this.plugins.forEach( function (plugin) {
8577
- if ( plugin.options ) {
8578
- options = plugin.options( options ) || options;
8579
- }
8580
- });
8655
+ options = this.plugins.reduce( function ( acc, plugin ) {
8656
+ if ( plugin.options ) return plugin.options( acc ) || acc;
8657
+ return acc;
8658
+ }, options);
8581
8659
 
8582
8660
  this.entry = options.entry;
8583
8661
  this.entryId = null;
@@ -8615,6 +8693,18 @@ var Bundle = function Bundle ( options ) {
8615
8693
 
8616
8694
  this.context = String( options.context );
8617
8695
 
8696
+ if ( typeof options.moduleContext === 'function' ) {
8697
+ this.getModuleContext = function (id) { return options.moduleContext( id ) || this$1.context; };
8698
+ } else if ( typeof options.moduleContext === 'object' ) {
8699
+ var moduleContext = new Map();
8700
+ Object.keys( options.moduleContext ).forEach( function (key) {
8701
+ moduleContext.set( resolve( key ), options.moduleContext[ key ] );
8702
+ });
8703
+ this.getModuleContext = function (id) { return moduleContext.get( id ) || this$1.context; };
8704
+ } else {
8705
+ this.getModuleContext = function () { return this$1.context; };
8706
+ }
8707
+
8618
8708
  if ( typeof options.external === 'function' ) {
8619
8709
  this.isExternal = options.external;
8620
8710
  } else {
@@ -8625,6 +8715,7 @@ var Bundle = function Bundle ( options ) {
8625
8715
  this.onwarn = options.onwarn || makeOnwarn();
8626
8716
 
8627
8717
  this.varOrConst = options.preferConst ? 'const' : 'var';
8718
+ this.legacy = options.legacy;
8628
8719
  this.acornOptions = options.acorn || {};
8629
8720
 
8630
8721
  this.dependentExpressions = [];
@@ -8820,7 +8911,7 @@ Bundle.prototype.fetchModule = function fetchModule ( id, importer ) {
8820
8911
  });
8821
8912
 
8822
8913
  this$1.modules.push( module );
8823
- this$1.moduleById.set( id, module );
8914
+ this$1.moduleById.set( id, module );
8824
8915
 
8825
8916
  return this$1.fetchAllDependencies( module ).then( function () {
8826
8917
  keys( module.exports ).forEach( function (name) {
@@ -8895,6 +8986,7 @@ Bundle.prototype.getPathRelativeToEntryDirname = function getPathRelativeToEntry
8895
8986
  };
8896
8987
 
8897
8988
  Bundle.prototype.render = function render ( options ) {
8989
+ var this$1 = this;
8898
8990
  if ( options === void 0 ) options = {};
8899
8991
 
8900
8992
  if ( options.format === 'es6' ) {
@@ -8905,7 +8997,7 @@ Bundle.prototype.render = function render ( options ) {
8905
8997
  var format = options.format || 'es';
8906
8998
 
8907
8999
  // Determine export mode - 'default', 'named', 'none'
8908
- var exportMode = getExportMode( this, options.exports, options.moduleName );
9000
+ var exportMode = getExportMode( this, options );
8909
9001
 
8910
9002
  var magicString = new Bundle$1({ separator: '\n\n' });
8911
9003
  var usedModules = [];
@@ -8913,7 +9005,7 @@ Bundle.prototype.render = function render ( options ) {
8913
9005
  timeStart( 'render modules' );
8914
9006
 
8915
9007
  this.orderedModules.forEach( function (module) {
8916
- var source = module.render( format === 'es' );
9008
+ var source = module.render( format === 'es', this$1.legacy );
8917
9009
 
8918
9010
  if ( source.toString().length ) {
8919
9011
  magicString.addSource( source );
@@ -8990,7 +9082,7 @@ Bundle.prototype.render = function render ( options ) {
8990
9082
  return { code: code, map: map };
8991
9083
  };
8992
9084
 
8993
- Bundle.prototype.sort = function sort () {
9085
+ Bundle.prototype.sort = function sort () {
8994
9086
  var this$1 = this;
8995
9087
 
8996
9088
  var hasCycles;
@@ -9058,7 +9150,7 @@ Bundle.prototype.sort = function sort () {
9058
9150
  visited[ module.id ] = true;
9059
9151
  for ( var i = 0; i < module.dependencies.length; i += 1 ) {
9060
9152
  var dependency = module.dependencies[i];
9061
- if ( !visited[ dependency.id ] && findParent( dependency ) ) return true;
9153
+ if ( !visited[ dependency.id ] && findParent( dependency ) ) return true;
9062
9154
  }
9063
9155
  };
9064
9156
 
@@ -9077,7 +9169,7 @@ Bundle.prototype.sort = function sort () {
9077
9169
  return ordered;
9078
9170
  };
9079
9171
 
9080
- var VERSION = '0.36.0';
9172
+ var VERSION = '0.36.4';
9081
9173
 
9082
9174
  var ALLOWED_KEYS = [
9083
9175
  'acorn',
@@ -9094,6 +9186,8 @@ var ALLOWED_KEYS = [
9094
9186
  'indent',
9095
9187
  'interop',
9096
9188
  'intro',
9189
+ 'legacy',
9190
+ 'moduleContext',
9097
9191
  'moduleId',
9098
9192
  'moduleName',
9099
9193
  'noConflict',
@@ -9109,20 +9203,24 @@ var ALLOWED_KEYS = [
9109
9203
  'useStrict'
9110
9204
  ];
9111
9205
 
9112
- function rollup ( options ) {
9206
+ function checkOptions ( options ) {
9113
9207
  if ( !options || !options.entry ) {
9114
- return Promise.reject( new Error( 'You must supply options.entry to rollup' ) );
9208
+ return new Error( 'You must supply options.entry to rollup' );
9115
9209
  }
9116
9210
 
9117
9211
  if ( options.transform || options.load || options.resolveId || options.resolveExternal ) {
9118
- return Promise.reject( new Error( 'The `transform`, `load`, `resolveId` and `resolveExternal` options are deprecated in favour of a unified plugin API. See https://github.com/rollup/rollup/wiki/Plugins for details' ) );
9212
+ return new Error( 'The `transform`, `load`, `resolveId` and `resolveExternal` options are deprecated in favour of a unified plugin API. See https://github.com/rollup/rollup/wiki/Plugins for details' );
9119
9213
  }
9120
9214
 
9121
- var error = validateKeys( options, ALLOWED_KEYS );
9215
+ var error = validateKeys( keys(options), ALLOWED_KEYS );
9216
+ if ( error ) return error;
9122
9217
 
9123
- if ( error ) {
9124
- return Promise.reject( error );
9125
- }
9218
+ return null;
9219
+ }
9220
+
9221
+ function rollup ( options ) {
9222
+ var error = checkOptions ( options );
9223
+ if ( error ) return Promise.reject( error );
9126
9224
 
9127
9225
  var bundle = new Bundle( options );
9128
9226