rollup 0.43.1 → 0.45.2

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.
@@ -1,6 +1,6 @@
1
1
  /*
2
- Rollup.js v0.43.1
3
- Sun Jul 09 2017 19:16:44 GMT-0400 (EDT) - commit 6f3f349afff179d3ea85764390fe74d38544a88b
2
+ Rollup.js v0.45.2
3
+ Wed Jul 12 2017 22:25:07 GMT-0400 (EDT) - commit b7a4edf2b7c26f58c8201a63c820541d9b37186d
4
4
 
5
5
 
6
6
  https://github.com/rollup/rollup
@@ -5497,13 +5497,26 @@ var builtins = 'Infinity NaN undefined null true false eval uneval isFinite isNa
5497
5497
  var blacklisted = blank();
5498
5498
  reservedWords$1.concat( builtins ).forEach( function (word) { return blacklisted[ word ] = true; } );
5499
5499
 
5500
+ var illegalCharacters = /[^$_a-zA-Z0-9]/g;
5500
5501
 
5501
- function makeLegalIdentifier ( str ) {
5502
+ var startsWithDigit = function (str) { return /\d/.test( str[0] ); };
5503
+
5504
+ function isLegal ( str ) {
5505
+ if ( startsWithDigit(str) || blacklisted[ str ] ) {
5506
+ return false;
5507
+ }
5508
+ if ( illegalCharacters.test(str) ) {
5509
+ return false;
5510
+ }
5511
+ return true;
5512
+ }
5513
+
5514
+ function makeLegal ( str ) {
5502
5515
  str = str
5503
5516
  .replace( /-(\w)/g, function ( _, letter ) { return letter.toUpperCase(); } )
5504
- .replace( /[^$_a-zA-Z0-9]/g, '_' );
5517
+ .replace( illegalCharacters, '_' );
5505
5518
 
5506
- if ( /\d/.test( str[0] ) || blacklisted[ str ] ) { str = "_" + str; }
5519
+ if ( startsWithDigit(str) || blacklisted[ str ] ) { str = "_" + str; }
5507
5520
 
5508
5521
  return str;
5509
5522
  }
@@ -5586,7 +5599,7 @@ Declaration.prototype.addReference = function addReference ( reference ) {
5586
5599
  reference.declaration = this;
5587
5600
 
5588
5601
  if ( reference.name !== this.name ) {
5589
- this.name = makeLegalIdentifier( reference.name ); // TODO handle differences of opinion
5602
+ this.name = makeLegal( reference.name ); // TODO handle differences of opinion
5590
5603
  }
5591
5604
 
5592
5605
  if ( reference.isReassignment ) { this.isReassigned = true; }
@@ -6514,6 +6527,25 @@ var CallExpression = (function (Node) {
6514
6527
  return CallExpression;
6515
6528
  }(Node$1));
6516
6529
 
6530
+ var CatchClause = (function (Node) {
6531
+ function CatchClause () {
6532
+ Node.apply(this, arguments);
6533
+ }
6534
+
6535
+ if ( Node ) CatchClause.__proto__ = Node;
6536
+ CatchClause.prototype = Object.create( Node && Node.prototype );
6537
+ CatchClause.prototype.constructor = CatchClause;
6538
+
6539
+ CatchClause.prototype.initialise = function initialise ( scope ) {
6540
+ this.body.createScope( scope );
6541
+ this.scope = this.body.scope;
6542
+
6543
+ this.body.initialise( this.scope );
6544
+ };
6545
+
6546
+ return CatchClause;
6547
+ }(Node$1));
6548
+
6517
6549
  // TODO is this basically identical to FunctionDeclaration?
6518
6550
  var ClassDeclaration = (function (Node) {
6519
6551
  function ClassDeclaration () {
@@ -7959,6 +7991,7 @@ var nodes = {
7959
7991
  BinaryExpression: BinaryExpression,
7960
7992
  BlockStatement: BlockStatement,
7961
7993
  CallExpression: CallExpression,
7994
+ CatchClause: CatchClause,
7962
7995
  ClassDeclaration: ClassDeclaration,
7963
7996
  ClassExpression: ClassExpression,
7964
7997
  ConditionalExpression: ConditionalExpression,
@@ -8165,6 +8198,7 @@ var Module = function Module (ref) {
8165
8198
  var ast = ref.ast;
8166
8199
  var sourceMapChain = ref.sourceMapChain;
8167
8200
  var resolvedIds = ref.resolvedIds;
8201
+ var resolvedExternalIds = ref.resolvedExternalIds;
8168
8202
  var bundle = ref.bundle;
8169
8203
 
8170
8204
  this.code = code;
@@ -8197,6 +8231,7 @@ var Module = function Module (ref) {
8197
8231
  this.sources = [];
8198
8232
  this.dependencies = [];
8199
8233
  this.resolvedIds = resolvedIds || blank();
8234
+ this.resolvedExternalIds = resolvedExternalIds || blank();
8200
8235
 
8201
8236
  // imports and exports, indexed by local name
8202
8237
  this.imports = blank();
@@ -8391,7 +8426,7 @@ Module.prototype.basename = function basename$1 () {
8391
8426
  var base = basename( this.id );
8392
8427
  var ext = extname( this.id );
8393
8428
 
8394
- return makeLegalIdentifier( ext ? base.slice( 0, -ext.length ) : base );
8429
+ return makeLegal( ext ? base.slice( 0, -ext.length ) : base );
8395
8430
  };
8396
8431
 
8397
8432
  Module.prototype.bindImportSpecifiers = function bindImportSpecifiers () {
@@ -8401,21 +8436,23 @@ Module.prototype.bindImportSpecifiers = function bindImportSpecifiers () {
8401
8436
  keys( specifiers ).forEach( function (name) {
8402
8437
  var specifier = specifiers[ name ];
8403
8438
 
8404
- var id = this$1.resolvedIds[ specifier.source ];
8439
+ var id = this$1.resolvedIds[ specifier.source ] || this$1.resolvedExternalIds[ specifier.source ];
8405
8440
  specifier.module = this$1.bundle.moduleById.get( id );
8406
8441
  });
8407
8442
  });
8408
8443
 
8409
8444
  this.exportAllModules = this.exportAllSources.map( function (source) {
8410
- var id = this$1.resolvedIds[ source ];
8445
+ var id = this$1.resolvedIds[ source ] || this$1.resolvedExternalIds[ source ];
8411
8446
  return this$1.bundle.moduleById.get( id );
8412
8447
  });
8413
8448
 
8414
8449
  this.sources.forEach( function (source) {
8415
8450
  var id = this$1.resolvedIds[ source ];
8416
- var module = this$1.bundle.moduleById.get( id );
8417
8451
 
8418
- if ( !module.isExternal ) { this$1.dependencies.push( module ); }
8452
+ if ( id ) {
8453
+ var module = this$1.bundle.moduleById.get( id );
8454
+ this$1.dependencies.push( module );
8455
+ }
8419
8456
  });
8420
8457
  };
8421
8458
 
@@ -8526,7 +8563,8 @@ Module.prototype.toJSON = function toJSON () {
8526
8563
  originalSourceMap: this.originalSourceMap,
8527
8564
  ast: this.astClone,
8528
8565
  sourceMapChain: this.sourceMapChain,
8529
- resolvedIds: this.resolvedIds
8566
+ resolvedIds: this.resolvedIds,
8567
+ resolvedExternalIds: this.resolvedExternalIds
8530
8568
  };
8531
8569
  };
8532
8570
 
@@ -8622,7 +8660,7 @@ var ExternalModule = function ExternalModule ( id, relativePath ) {
8622
8660
  this.id = id;
8623
8661
  this.path = relativePath;
8624
8662
 
8625
- this.name = makeLegalIdentifier( relativePath );
8663
+ this.name = makeLegal( relativePath );
8626
8664
 
8627
8665
  this.nameSuggestions = blank();
8628
8666
  this.mostCommonSuggestion = 0;
@@ -8678,7 +8716,7 @@ function getInteropBlock ( bundle, options ) {
8678
8716
  return ((bundle.varOrConst) + " " + (module.name) + "__default = 'default' in " + (module.name) + " ? " + (module.name) + "['default'] : " + (module.name) + ";");
8679
8717
  }
8680
8718
 
8681
- return ((module.name) + " = " + (module.name) + " && 'default' in " + (module.name) + " ? " + (module.name) + "['default'] : " + (module.name) + ";");
8719
+ return ((module.name) + " = " + (module.name) + " && " + (module.name) + ".hasOwnProperty('default') ? " + (module.name) + "['default'] : " + (module.name) + ";");
8682
8720
  })
8683
8721
  .filter( Boolean )
8684
8722
  .join( '\n' );
@@ -9034,8 +9072,17 @@ function iife ( bundle, magicString, ref, options ) {
9034
9072
 
9035
9073
  var globalNameMaker = getGlobalNameMaker( options.globals || blank(), bundle, 'null' );
9036
9074
 
9075
+ var extend = options.extend;
9037
9076
  var name = options.moduleName;
9038
- var isNamespaced = name && ~name.indexOf( '.' );
9077
+ var isNamespaced = name && name.indexOf( '.' ) !== -1;
9078
+ var possibleVariableAssignment = !extend && !isNamespaced;
9079
+
9080
+ if ( name && possibleVariableAssignment && !isLegal(name) ) {
9081
+ error({
9082
+ code: 'ILLEGAL_IDENTIFIER_AS_NAME',
9083
+ message: ("Given moduleName (" + name + ") is not legal JS identifier. If you need this you can try --extend option")
9084
+ });
9085
+ }
9039
9086
 
9040
9087
  warnOnBuiltins( bundle );
9041
9088
 
@@ -9050,17 +9097,19 @@ function iife ( bundle, magicString, ref, options ) {
9050
9097
  });
9051
9098
  }
9052
9099
 
9053
- if ( exportMode === 'named' ) {
9100
+ if ( extend ) {
9054
9101
  dependencies.unshift( ("(" + (thisProp(name)) + " = " + (thisProp(name)) + " || {})") );
9055
9102
  args.unshift( 'exports' );
9103
+ } else if ( exportMode === 'named' ) {
9104
+ dependencies.unshift( '{}' );
9105
+ args.unshift( 'exports' );
9056
9106
  }
9057
9107
 
9058
9108
  var useStrict = options.useStrict !== false ? (indentString + "'use strict';\n\n") : "";
9059
9109
 
9060
9110
  var wrapperIntro = "(function (" + args + ") {\n" + useStrict;
9061
- var wrapperOutro = "\n\n}(" + dependencies + "));";
9062
9111
 
9063
- if ( exportMode === 'default' ) {
9112
+ if ( exportMode !== 'none' && !extend) {
9064
9113
  wrapperIntro = ( isNamespaced ? thisProp(name) : ((bundle.varOrConst) + " " + name) ) + " = " + wrapperIntro;
9065
9114
  }
9066
9115
 
@@ -9068,6 +9117,12 @@ function iife ( bundle, magicString, ref, options ) {
9068
9117
  wrapperIntro = setupNamespace( name ) + wrapperIntro;
9069
9118
  }
9070
9119
 
9120
+ var wrapperOutro = "\n\n}(" + dependencies + "));";
9121
+
9122
+ if (possibleVariableAssignment && exportMode === 'named') {
9123
+ wrapperOutro = "\n\n" + indentString + "return exports;" + wrapperOutro;
9124
+ }
9125
+
9071
9126
  // var foo__default = 'default' in foo ? foo['default'] : foo;
9072
9127
  var interopBlock = getInteropBlock( bundle, options );
9073
9128
  if ( interopBlock ) { magicString.prepend( interopBlock + '\n\n' ); }
@@ -9100,6 +9155,15 @@ function setupNamespace$1 ( name ) {
9100
9155
  .join( ', ' );
9101
9156
  }
9102
9157
 
9158
+ function safeAccess ( name ) {
9159
+ var parts = name.split( '.' );
9160
+
9161
+ var acc = 'global';
9162
+ return parts
9163
+ .map( function (part) { return ( acc += property( part ), acc ); } )
9164
+ .join( " && " );
9165
+ }
9166
+
9103
9167
  var wrapperOutro = '\n\n})));';
9104
9168
 
9105
9169
  function umd ( bundle, magicString, ref, options ) {
@@ -9129,7 +9193,7 @@ function umd ( bundle, magicString, ref, options ) {
9129
9193
  if ( exportMode === 'named' ) {
9130
9194
  amdDeps.unshift( "'exports'" );
9131
9195
  cjsDeps.unshift( "exports" );
9132
- globalDeps.unshift( ("(" + (setupNamespace$1(options.moduleName)) + " = " + (globalProp(options.moduleName)) + " || {})") );
9196
+ globalDeps.unshift( ("(" + (setupNamespace$1(options.moduleName)) + " = " + (options.extend ? ((globalProp(options.moduleName)) + " || ") : '') + "{})") );
9133
9197
 
9134
9198
  args.unshift( 'exports' );
9135
9199
  }
@@ -9147,8 +9211,21 @@ function umd ( bundle, magicString, ref, options ) {
9147
9211
 
9148
9212
  var useStrict = options.useStrict !== false ? " 'use strict';" : "";
9149
9213
 
9150
- var globalExport = options.noConflict === true ?
9151
- ("(function() {\n\t\t\t\tvar current = " + (globalProp(options.moduleName)) + ";\n\t\t\t\tvar exports = factory(" + globalDeps + ");\n\t\t\t\t" + (globalProp(options.moduleName)) + " = exports;\n\t\t\t\texports.noConflict = function() { " + (globalProp(options.moduleName)) + " = current; return exports; };\n\t\t\t})()") : ("(" + defaultExport + "factory(" + globalDeps + "))");
9214
+ var globalExport;
9215
+
9216
+ if (options.noConflict === true) {
9217
+ var factory;
9218
+
9219
+ if ( exportMode === 'default' ) {
9220
+ factory = "var exports = factory(" + globalDeps + ");";
9221
+ } else if ( exportMode === 'named' ) {
9222
+ var module = globalDeps.shift();
9223
+ factory = "var exports = " + module + ";\n\t\t\t\tfactory(" + (['exports'].concat(globalDeps)) + ");";
9224
+ }
9225
+ globalExport = "(function() {\n\t\t\t\tvar current = " + (safeAccess(options.moduleName)) + ";\n\t\t\t\t" + factory + "\n\t\t\t\t" + (globalProp(options.moduleName)) + " = exports;\n\t\t\t\texports.noConflict = function() { " + (globalProp(options.moduleName)) + " = current; return exports; };\n\t\t\t})()";
9226
+ } else {
9227
+ globalExport = "(" + defaultExport + "factory(" + globalDeps + "))";
9228
+ }
9152
9229
 
9153
9230
  var wrapperIntro =
9154
9231
  ("(function (global, factory) {\n\t\t\ttypeof exports === 'object' && typeof module !== 'undefined' ? " + cjsExport + "factory(" + (cjsDeps.join( ', ' )) + ") :\n\t\t\ttypeof " + define + " === 'function' && " + define + ".amd ? " + define + "(" + amdParams + "factory) :\n\t\t\t" + globalExport + ";\n\t\t}(this, (function (" + args + ") {" + useStrict + "\n\n\t\t").replace( /^\t\t/gm, '' ).replace( /^\t/gm, indentString || '\t' );
@@ -9403,39 +9480,40 @@ function transform ( bundle, source, id, plugins ) {
9403
9480
  }
9404
9481
 
9405
9482
  function transformBundle ( code, plugins, sourceMapChain, options ) {
9406
- return plugins.reduce( function ( code, plugin ) {
9407
- if ( !plugin.transformBundle ) { return code; }
9408
-
9409
- var result;
9410
-
9411
- try {
9412
- result = plugin.transformBundle( code, { format : options.format } );
9413
- } catch ( err ) {
9414
- error({
9415
- code: 'BAD_BUNDLE_TRANSFORMER',
9416
- message: ("Error transforming bundle" + (plugin.name ? (" with '" + (plugin.name) + "' plugin") : '') + ": " + (err.message)),
9417
- plugin: plugin.name
9418
- });
9419
- }
9420
-
9421
- if ( result == null ) { return code; }
9483
+ return plugins.reduce( function ( promise, plugin ) {
9484
+ if ( !plugin.transformBundle ) { return promise; }
9485
+
9486
+ return promise.then( function (code) {
9487
+ return Promise.resolve().then( function () {
9488
+ return plugin.transformBundle( code, { format : options.format } );
9489
+ }).then( function (result) {
9490
+ if ( result == null ) { return code; }
9491
+
9492
+ if ( typeof result === 'string' ) {
9493
+ result = {
9494
+ code: result,
9495
+ map: null
9496
+ };
9497
+ }
9422
9498
 
9423
- if ( typeof result === 'string' ) {
9424
- result = {
9425
- code: result,
9426
- map: null
9427
- };
9428
- }
9499
+ var map = typeof result.map === 'string' ? JSON.parse( result.map ) : result.map;
9500
+ if ( map && typeof map.mappings === 'string' ) {
9501
+ map.mappings = decode$$1( map.mappings );
9502
+ }
9429
9503
 
9430
- var map = typeof result.map === 'string' ? JSON.parse( result.map ) : result.map;
9431
- if ( map && typeof map.mappings === 'string' ) {
9432
- map.mappings = decode$$1( map.mappings );
9433
- }
9504
+ sourceMapChain.push( map );
9434
9505
 
9435
- sourceMapChain.push( map );
9506
+ return result.code;
9507
+ }).catch( function (err) {
9508
+ error({
9509
+ code: 'BAD_BUNDLE_TRANSFORMER',
9510
+ message: ("Error transforming bundle" + (plugin.name ? (" with '" + (plugin.name) + "' plugin") : '') + ": " + (err.message)),
9511
+ plugin: plugin.name
9512
+ });
9513
+ });
9514
+ });
9436
9515
 
9437
- return result.code;
9438
- }, code );
9516
+ }, Promise.resolve( code ) );
9439
9517
  }
9440
9518
 
9441
9519
  var Source = function Source ( filename, content ) {
@@ -10002,7 +10080,7 @@ Bundle.prototype.fetchModule = function fetchModule ( id, importer ) {
10002
10080
  }
10003
10081
  });
10004
10082
  module.exportAllSources.forEach( function (source) {
10005
- var id = module.resolvedIds[ source ];
10083
+ var id = module.resolvedIds[ source ] || module.resolvedExternalIds[ source ];
10006
10084
  var exportAllModule = this$1.moduleById.get( id );
10007
10085
  if ( exportAllModule.isExternal ) { return; }
10008
10086
 
@@ -10052,7 +10130,7 @@ Bundle.prototype.fetchAllDependencies = function fetchAllDependencies ( module )
10052
10130
  }
10053
10131
 
10054
10132
  if ( isExternal ) {
10055
- module.resolvedIds[ source ] = externalId;
10133
+ module.resolvedExternalIds[ source ] = externalId;
10056
10134
 
10057
10135
  if ( !this$1.moduleById.has( externalId ) ) {
10058
10136
  var module$1 = new ExternalModule( externalId, this$1.getPath( externalId ) );
@@ -10105,119 +10183,121 @@ Bundle.prototype.render = function render ( options ) {
10105
10183
  var this$1 = this;
10106
10184
  if ( options === void 0 ) options = {};
10107
10185
 
10108
- if ( options.format === 'es6' ) {
10109
- this.warn({
10110
- code: 'DEPRECATED_ES6',
10111
- message: 'The es6 format is deprecated – use `es` instead'
10112
- });
10113
-
10114
- options.format = 'es';
10115
- }
10186
+ return Promise.resolve().then( function () {
10187
+ if ( options.format === 'es6' ) {
10188
+ this$1.warn({
10189
+ code: 'DEPRECATED_ES6',
10190
+ message: 'The es6 format is deprecated – use `es` instead'
10191
+ });
10116
10192
 
10117
- // Determine export mode - 'default', 'named', 'none'
10118
- var exportMode = getExportMode( this, options );
10193
+ options.format = 'es';
10194
+ }
10119
10195
 
10120
- var magicString = new Bundle$2({ separator: '\n\n' });
10121
- var usedModules = [];
10196
+ // Determine export mode - 'default', 'named', 'none'
10197
+ var exportMode = getExportMode( this$1, options );
10122
10198
 
10123
- timeStart( 'render modules' );
10199
+ var magicString = new Bundle$2({ separator: '\n\n' });
10200
+ var usedModules = [];
10124
10201
 
10125
- this.orderedModules.forEach( function (module) {
10126
- var source = module.render( options.format === 'es', this$1.legacy );
10202
+ timeStart( 'render modules' );
10127
10203
 
10128
- if ( source.toString().length ) {
10129
- magicString.addSource( source );
10130
- usedModules.push( module );
10131
- }
10132
- });
10204
+ this$1.orderedModules.forEach( function (module) {
10205
+ var source = module.render( options.format === 'es', this$1.legacy );
10133
10206
 
10134
- if ( !magicString.toString().trim() && this.entryModule.getExports().length === 0 ) {
10135
- this.warn({
10136
- code: 'EMPTY_BUNDLE',
10137
- message: 'Generated an empty bundle'
10207
+ if ( source.toString().length ) {
10208
+ magicString.addSource( source );
10209
+ usedModules.push( module );
10210
+ }
10138
10211
  });
10139
- }
10140
10212
 
10141
- timeEnd( 'render modules' );
10213
+ if ( !magicString.toString().trim() && this$1.entryModule.getExports().length === 0 ) {
10214
+ this$1.warn({
10215
+ code: 'EMPTY_BUNDLE',
10216
+ message: 'Generated an empty bundle'
10217
+ });
10218
+ }
10142
10219
 
10143
- var intro = [ options.intro ]
10144
- .concat(
10145
- this.plugins.map( function (plugin) { return plugin.intro && plugin.intro(); } )
10146
- )
10147
- .filter( Boolean )
10148
- .join( '\n\n' );
10220
+ timeEnd( 'render modules' );
10149
10221
 
10150
- if ( intro ) { intro += '\n\n'; }
10222
+ var intro = [ options.intro ]
10223
+ .concat(
10224
+ this$1.plugins.map( function (plugin) { return plugin.intro && plugin.intro(); } )
10225
+ )
10226
+ .filter( Boolean )
10227
+ .join( '\n\n' );
10151
10228
 
10152
- var outro = [ options.outro ]
10153
- .concat(
10154
- this.plugins.map( function (plugin) { return plugin.outro && plugin.outro(); } )
10155
- )
10156
- .filter( Boolean )
10157
- .join( '\n\n' );
10229
+ if ( intro ) { intro += '\n\n'; }
10158
10230
 
10159
- if ( outro ) { outro = "\n\n" + outro; }
10231
+ var outro = [ options.outro ]
10232
+ .concat(
10233
+ this$1.plugins.map( function (plugin) { return plugin.outro && plugin.outro(); } )
10234
+ )
10235
+ .filter( Boolean )
10236
+ .join( '\n\n' );
10160
10237
 
10161
- var indentString = getIndentString( magicString, options );
10238
+ if ( outro ) { outro = "\n\n" + outro; }
10162
10239
 
10163
- var finalise = finalisers[ options.format ];
10164
- if ( !finalise ) {
10165
- error({
10166
- code: 'INVALID_OPTION',
10167
- message: ("You must specify an output type - valid options are " + (keys( finalisers ).join( ', ' )))
10168
- });
10169
- }
10240
+ var indentString = getIndentString( magicString, options );
10170
10241
 
10171
- timeStart( 'render format' );
10242
+ var finalise = finalisers[ options.format ];
10243
+ if ( !finalise ) {
10244
+ error({
10245
+ code: 'INVALID_OPTION',
10246
+ message: ("You must specify an output type - valid options are " + (keys( finalisers ).join( ', ' )))
10247
+ });
10248
+ }
10172
10249
 
10173
- magicString = finalise( this, magicString.trim(), { exportMode: exportMode, indentString: indentString, intro: intro, outro: outro }, options );
10250
+ timeStart( 'render format' );
10174
10251
 
10175
- timeEnd( 'render format' );
10252
+ magicString = finalise( this$1, magicString.trim(), { exportMode: exportMode, indentString: indentString, intro: intro, outro: outro }, options );
10176
10253
 
10177
- var banner = [ options.banner ]
10178
- .concat( this.plugins.map( function (plugin) { return plugin.banner; } ) )
10179
- .map( callIfFunction )
10180
- .filter( Boolean )
10181
- .join( '\n' );
10254
+ timeEnd( 'render format' );
10182
10255
 
10183
- var footer = [ options.footer ]
10184
- .concat( this.plugins.map( function (plugin) { return plugin.footer; } ) )
10185
- .map( callIfFunction )
10186
- .filter( Boolean )
10187
- .join( '\n' );
10256
+ var banner = [ options.banner ]
10257
+ .concat( this$1.plugins.map( function (plugin) { return plugin.banner; } ) )
10258
+ .map( callIfFunction )
10259
+ .filter( Boolean )
10260
+ .join( '\n' );
10188
10261
 
10189
- if ( banner ) { magicString.prepend( banner + '\n' ); }
10190
- if ( footer ) { magicString.append( '\n' + footer ); }
10262
+ var footer = [ options.footer ]
10263
+ .concat( this$1.plugins.map( function (plugin) { return plugin.footer; } ) )
10264
+ .map( callIfFunction )
10265
+ .filter( Boolean )
10266
+ .join( '\n' );
10191
10267
 
10192
- var code = magicString.toString();
10193
- var map = null;
10194
- var bundleSourcemapChain = [];
10268
+ if ( banner ) { magicString.prepend( banner + '\n' ); }
10269
+ if ( footer ) { magicString.append( '\n' + footer ); }
10195
10270
 
10196
- code = transformBundle( code, this.plugins, bundleSourcemapChain, options );
10271
+ var prevCode = magicString.toString();
10272
+ var map = null;
10273
+ var bundleSourcemapChain = [];
10197
10274
 
10198
- if ( options.sourceMap ) {
10199
- timeStart( 'sourceMap' );
10275
+ return transformBundle( prevCode, this$1.plugins, bundleSourcemapChain, options ).then( function (code) {
10276
+ if ( options.sourceMap ) {
10277
+ timeStart( 'sourceMap' );
10200
10278
 
10201
- var file = options.sourceMapFile || options.dest;
10202
- if ( file ) { file = resolve( typeof process !== 'undefined' ? process.cwd() : '', file ); }
10279
+ var file = options.sourceMapFile || options.dest;
10280
+ if ( file ) { file = resolve( typeof process !== 'undefined' ? process.cwd() : '', file ); }
10203
10281
 
10204
- if ( this.hasLoaders || find( this.plugins, function (plugin) { return plugin.transform || plugin.transformBundle; } ) ) {
10205
- map = magicString.generateMap({});
10206
- if ( typeof map.mappings === 'string' ) {
10207
- map.mappings = decode$$1( map.mappings );
10208
- }
10209
- map = collapseSourcemaps( this, file, map, usedModules, bundleSourcemapChain );
10210
- } else {
10211
- map = magicString.generateMap({ file: file, includeContent: true });
10212
- }
10282
+ if ( this$1.hasLoaders || find( this$1.plugins, function (plugin) { return plugin.transform || plugin.transformBundle; } ) ) {
10283
+ map = magicString.generateMap({});
10284
+ if ( typeof map.mappings === 'string' ) {
10285
+ map.mappings = decode$$1( map.mappings );
10286
+ }
10287
+ map = collapseSourcemaps( this$1, file, map, usedModules, bundleSourcemapChain );
10288
+ } else {
10289
+ map = magicString.generateMap({ file: file, includeContent: true });
10290
+ }
10213
10291
 
10214
- map.sources = map.sources.map( normalize );
10292
+ map.sources = map.sources.map( normalize );
10215
10293
 
10216
- timeEnd( 'sourceMap' );
10217
- }
10294
+ timeEnd( 'sourceMap' );
10295
+ }
10218
10296
 
10219
- if ( code[ code.length - 1 ] !== '\n' ) { code += '\n'; }
10220
- return { code: code, map: map };
10297
+ if ( code[ code.length - 1 ] !== '\n' ) { code += '\n'; }
10298
+ return { code: code, map: map };
10299
+ });
10300
+ });
10221
10301
  };
10222
10302
 
10223
10303
  Bundle.prototype.sort = function sort () {
@@ -10322,7 +10402,7 @@ Bundle.prototype.warn = function warn ( warning ) {
10322
10402
  this.onwarn( warning );
10323
10403
  };
10324
10404
 
10325
- var VERSION = '0.43.1';
10405
+ var VERSION = '0.45.2';
10326
10406
 
10327
10407
  var ALLOWED_KEYS = [
10328
10408
  'acorn',
@@ -10333,6 +10413,7 @@ var ALLOWED_KEYS = [
10333
10413
  'dest',
10334
10414
  'entry',
10335
10415
  'exports',
10416
+ 'extend',
10336
10417
  'external',
10337
10418
  'footer',
10338
10419
  'format',
@@ -10389,6 +10470,12 @@ function checkOptions ( options ) {
10389
10470
  if ( err ) { throw err; }
10390
10471
  }
10391
10472
 
10473
+ var throwAsyncGenerateError = {
10474
+ get: function get () {
10475
+ throw new Error( "bundle.generate(...) now returns a Promise instead of a { code, map } object" );
10476
+ }
10477
+ };
10478
+
10392
10479
  function rollup ( options ) {
10393
10480
  try {
10394
10481
  checkOptions( options );
@@ -10416,21 +10503,28 @@ function rollup ( options ) {
10416
10503
 
10417
10504
  timeStart( '--GENERATE--' );
10418
10505
 
10419
- var rendered = bundle.render( options );
10506
+ var promise = Promise.resolve()
10507
+ .then( function () { return bundle.render( options ); } )
10508
+ .then( function (rendered) {
10509
+ timeEnd( '--GENERATE--' );
10420
10510
 
10421
- timeEnd( '--GENERATE--' );
10511
+ bundle.plugins.forEach( function (plugin) {
10512
+ if ( plugin.ongenerate ) {
10513
+ plugin.ongenerate( assign({
10514
+ bundle: result
10515
+ }, options ), rendered);
10516
+ }
10517
+ });
10422
10518
 
10423
- bundle.plugins.forEach( function (plugin) {
10424
- if ( plugin.ongenerate ) {
10425
- plugin.ongenerate( assign({
10426
- bundle: result
10427
- }, options ), rendered);
10428
- }
10429
- });
10519
+ flushTime();
10430
10520
 
10431
- flushTime();
10521
+ return rendered;
10522
+ });
10523
+
10524
+ Object.defineProperty( promise, 'code', throwAsyncGenerateError );
10525
+ Object.defineProperty( promise, 'map', throwAsyncGenerateError );
10432
10526
 
10433
- return rendered;
10527
+ return promise;
10434
10528
  }
10435
10529
 
10436
10530
  var result = {
@@ -10448,31 +10542,32 @@ function rollup ( options ) {
10448
10542
  }
10449
10543
 
10450
10544
  var dest = options.dest;
10451
- var output = generate( options );
10452
- var code = output.code;
10453
- var map = output.map;
10545
+ return generate( options ).then( function (output) {
10546
+ var code = output.code;
10547
+ var map = output.map;
10454
10548
 
10455
- var promises = [];
10549
+ var promises = [];
10456
10550
 
10457
- if ( options.sourceMap ) {
10458
- var url;
10551
+ if ( options.sourceMap ) {
10552
+ var url;
10459
10553
 
10460
- if ( options.sourceMap === 'inline' ) {
10461
- url = map.toUrl();
10462
- } else {
10463
- url = (basename( dest )) + ".map";
10464
- promises.push( writeFile( dest + '.map', map.toString() ) );
10465
- }
10554
+ if ( options.sourceMap === 'inline' ) {
10555
+ url = map.toUrl();
10556
+ } else {
10557
+ url = (basename( dest )) + ".map";
10558
+ promises.push( writeFile( dest + '.map', map.toString() ) );
10559
+ }
10466
10560
 
10467
- code += "//# " + SOURCEMAPPING_URL + "=" + url + "\n";
10468
- }
10561
+ code += "//# " + SOURCEMAPPING_URL + "=" + url + "\n";
10562
+ }
10469
10563
 
10470
- promises.push( writeFile( dest, code ) );
10471
- return Promise.all( promises ).then( function () {
10472
- return mapSequence( bundle.plugins.filter( function (plugin) { return plugin.onwrite; } ), function (plugin) {
10473
- return Promise.resolve( plugin.onwrite( assign({
10474
- bundle: result
10475
- }, options ), output));
10564
+ promises.push( writeFile( dest, code ) );
10565
+ return Promise.all( promises ).then( function () {
10566
+ return mapSequence( bundle.plugins.filter( function (plugin) { return plugin.onwrite; } ), function (plugin) {
10567
+ return Promise.resolve( plugin.onwrite( assign({
10568
+ bundle: result
10569
+ }, options ), output));
10570
+ });
10476
10571
  });
10477
10572
  });
10478
10573
  }