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.
package/dist/rollup.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
- Rollup.js v0.43.1
3
- Sun Jul 09 2017 19:16:27 GMT-0400 (EDT) - commit 6f3f349afff179d3ea85764390fe74d38544a88b
2
+ Rollup.js v0.45.2
3
+ Wed Jul 12 2017 22:24:48 GMT-0400 (EDT) - commit b7a4edf2b7c26f58c8201a63c820541d9b37186d
4
4
 
5
5
 
6
6
  https://github.com/rollup/rollup
@@ -5442,13 +5442,26 @@ var builtins = 'Infinity NaN undefined null true false eval uneval isFinite isNa
5442
5442
  var blacklisted = blank();
5443
5443
  reservedWords$1.concat( builtins ).forEach( function (word) { return blacklisted[ word ] = true; } );
5444
5444
 
5445
+ var illegalCharacters = /[^$_a-zA-Z0-9]/g;
5445
5446
 
5446
- function makeLegalIdentifier ( str ) {
5447
+ var startsWithDigit = function (str) { return /\d/.test( str[0] ); };
5448
+
5449
+ function isLegal ( str ) {
5450
+ if ( startsWithDigit(str) || blacklisted[ str ] ) {
5451
+ return false;
5452
+ }
5453
+ if ( illegalCharacters.test(str) ) {
5454
+ return false;
5455
+ }
5456
+ return true;
5457
+ }
5458
+
5459
+ function makeLegal ( str ) {
5447
5460
  str = str
5448
5461
  .replace( /-(\w)/g, function ( _, letter ) { return letter.toUpperCase(); } )
5449
- .replace( /[^$_a-zA-Z0-9]/g, '_' );
5462
+ .replace( illegalCharacters, '_' );
5450
5463
 
5451
- if ( /\d/.test( str[0] ) || blacklisted[ str ] ) { str = "_" + str; }
5464
+ if ( startsWithDigit(str) || blacklisted[ str ] ) { str = "_" + str; }
5452
5465
 
5453
5466
  return str;
5454
5467
  }
@@ -5531,7 +5544,7 @@ Declaration.prototype.addReference = function addReference ( reference ) {
5531
5544
  reference.declaration = this;
5532
5545
 
5533
5546
  if ( reference.name !== this.name ) {
5534
- this.name = makeLegalIdentifier( reference.name ); // TODO handle differences of opinion
5547
+ this.name = makeLegal( reference.name ); // TODO handle differences of opinion
5535
5548
  }
5536
5549
 
5537
5550
  if ( reference.isReassignment ) { this.isReassigned = true; }
@@ -6459,6 +6472,25 @@ var CallExpression = (function (Node) {
6459
6472
  return CallExpression;
6460
6473
  }(Node$1));
6461
6474
 
6475
+ var CatchClause = (function (Node) {
6476
+ function CatchClause () {
6477
+ Node.apply(this, arguments);
6478
+ }
6479
+
6480
+ if ( Node ) CatchClause.__proto__ = Node;
6481
+ CatchClause.prototype = Object.create( Node && Node.prototype );
6482
+ CatchClause.prototype.constructor = CatchClause;
6483
+
6484
+ CatchClause.prototype.initialise = function initialise ( scope ) {
6485
+ this.body.createScope( scope );
6486
+ this.scope = this.body.scope;
6487
+
6488
+ this.body.initialise( this.scope );
6489
+ };
6490
+
6491
+ return CatchClause;
6492
+ }(Node$1));
6493
+
6462
6494
  // TODO is this basically identical to FunctionDeclaration?
6463
6495
  var ClassDeclaration = (function (Node) {
6464
6496
  function ClassDeclaration () {
@@ -7904,6 +7936,7 @@ var nodes = {
7904
7936
  BinaryExpression: BinaryExpression,
7905
7937
  BlockStatement: BlockStatement,
7906
7938
  CallExpression: CallExpression,
7939
+ CatchClause: CatchClause,
7907
7940
  ClassDeclaration: ClassDeclaration,
7908
7941
  ClassExpression: ClassExpression,
7909
7942
  ConditionalExpression: ConditionalExpression,
@@ -8110,6 +8143,7 @@ var Module = function Module (ref) {
8110
8143
  var ast = ref.ast;
8111
8144
  var sourceMapChain = ref.sourceMapChain;
8112
8145
  var resolvedIds = ref.resolvedIds;
8146
+ var resolvedExternalIds = ref.resolvedExternalIds;
8113
8147
  var bundle = ref.bundle;
8114
8148
 
8115
8149
  this.code = code;
@@ -8142,6 +8176,7 @@ var Module = function Module (ref) {
8142
8176
  this.sources = [];
8143
8177
  this.dependencies = [];
8144
8178
  this.resolvedIds = resolvedIds || blank();
8179
+ this.resolvedExternalIds = resolvedExternalIds || blank();
8145
8180
 
8146
8181
  // imports and exports, indexed by local name
8147
8182
  this.imports = blank();
@@ -8336,7 +8371,7 @@ Module.prototype.basename = function basename$1 () {
8336
8371
  var base = basename( this.id );
8337
8372
  var ext = extname( this.id );
8338
8373
 
8339
- return makeLegalIdentifier( ext ? base.slice( 0, -ext.length ) : base );
8374
+ return makeLegal( ext ? base.slice( 0, -ext.length ) : base );
8340
8375
  };
8341
8376
 
8342
8377
  Module.prototype.bindImportSpecifiers = function bindImportSpecifiers () {
@@ -8346,21 +8381,23 @@ Module.prototype.bindImportSpecifiers = function bindImportSpecifiers () {
8346
8381
  keys( specifiers ).forEach( function (name) {
8347
8382
  var specifier = specifiers[ name ];
8348
8383
 
8349
- var id = this$1.resolvedIds[ specifier.source ];
8384
+ var id = this$1.resolvedIds[ specifier.source ] || this$1.resolvedExternalIds[ specifier.source ];
8350
8385
  specifier.module = this$1.bundle.moduleById.get( id );
8351
8386
  });
8352
8387
  });
8353
8388
 
8354
8389
  this.exportAllModules = this.exportAllSources.map( function (source) {
8355
- var id = this$1.resolvedIds[ source ];
8390
+ var id = this$1.resolvedIds[ source ] || this$1.resolvedExternalIds[ source ];
8356
8391
  return this$1.bundle.moduleById.get( id );
8357
8392
  });
8358
8393
 
8359
8394
  this.sources.forEach( function (source) {
8360
8395
  var id = this$1.resolvedIds[ source ];
8361
- var module = this$1.bundle.moduleById.get( id );
8362
8396
 
8363
- if ( !module.isExternal ) { this$1.dependencies.push( module ); }
8397
+ if ( id ) {
8398
+ var module = this$1.bundle.moduleById.get( id );
8399
+ this$1.dependencies.push( module );
8400
+ }
8364
8401
  });
8365
8402
  };
8366
8403
 
@@ -8471,7 +8508,8 @@ Module.prototype.toJSON = function toJSON () {
8471
8508
  originalSourceMap: this.originalSourceMap,
8472
8509
  ast: this.astClone,
8473
8510
  sourceMapChain: this.sourceMapChain,
8474
- resolvedIds: this.resolvedIds
8511
+ resolvedIds: this.resolvedIds,
8512
+ resolvedExternalIds: this.resolvedExternalIds
8475
8513
  };
8476
8514
  };
8477
8515
 
@@ -8567,7 +8605,7 @@ var ExternalModule = function ExternalModule ( id, relativePath ) {
8567
8605
  this.id = id;
8568
8606
  this.path = relativePath;
8569
8607
 
8570
- this.name = makeLegalIdentifier( relativePath );
8608
+ this.name = makeLegal( relativePath );
8571
8609
 
8572
8610
  this.nameSuggestions = blank();
8573
8611
  this.mostCommonSuggestion = 0;
@@ -8623,7 +8661,7 @@ function getInteropBlock ( bundle, options ) {
8623
8661
  return ((bundle.varOrConst) + " " + (module.name) + "__default = 'default' in " + (module.name) + " ? " + (module.name) + "['default'] : " + (module.name) + ";");
8624
8662
  }
8625
8663
 
8626
- return ((module.name) + " = " + (module.name) + " && 'default' in " + (module.name) + " ? " + (module.name) + "['default'] : " + (module.name) + ";");
8664
+ return ((module.name) + " = " + (module.name) + " && " + (module.name) + ".hasOwnProperty('default') ? " + (module.name) + "['default'] : " + (module.name) + ";");
8627
8665
  })
8628
8666
  .filter( Boolean )
8629
8667
  .join( '\n' );
@@ -8979,8 +9017,17 @@ function iife ( bundle, magicString, ref, options ) {
8979
9017
 
8980
9018
  var globalNameMaker = getGlobalNameMaker( options.globals || blank(), bundle, 'null' );
8981
9019
 
9020
+ var extend = options.extend;
8982
9021
  var name = options.moduleName;
8983
- var isNamespaced = name && ~name.indexOf( '.' );
9022
+ var isNamespaced = name && name.indexOf( '.' ) !== -1;
9023
+ var possibleVariableAssignment = !extend && !isNamespaced;
9024
+
9025
+ if ( name && possibleVariableAssignment && !isLegal(name) ) {
9026
+ error({
9027
+ code: 'ILLEGAL_IDENTIFIER_AS_NAME',
9028
+ message: ("Given moduleName (" + name + ") is not legal JS identifier. If you need this you can try --extend option")
9029
+ });
9030
+ }
8984
9031
 
8985
9032
  warnOnBuiltins( bundle );
8986
9033
 
@@ -8995,17 +9042,19 @@ function iife ( bundle, magicString, ref, options ) {
8995
9042
  });
8996
9043
  }
8997
9044
 
8998
- if ( exportMode === 'named' ) {
9045
+ if ( extend ) {
8999
9046
  dependencies.unshift( ("(" + (thisProp(name)) + " = " + (thisProp(name)) + " || {})") );
9000
9047
  args.unshift( 'exports' );
9048
+ } else if ( exportMode === 'named' ) {
9049
+ dependencies.unshift( '{}' );
9050
+ args.unshift( 'exports' );
9001
9051
  }
9002
9052
 
9003
9053
  var useStrict = options.useStrict !== false ? (indentString + "'use strict';\n\n") : "";
9004
9054
 
9005
9055
  var wrapperIntro = "(function (" + args + ") {\n" + useStrict;
9006
- var wrapperOutro = "\n\n}(" + dependencies + "));";
9007
9056
 
9008
- if ( exportMode === 'default' ) {
9057
+ if ( exportMode !== 'none' && !extend) {
9009
9058
  wrapperIntro = ( isNamespaced ? thisProp(name) : ((bundle.varOrConst) + " " + name) ) + " = " + wrapperIntro;
9010
9059
  }
9011
9060
 
@@ -9013,6 +9062,12 @@ function iife ( bundle, magicString, ref, options ) {
9013
9062
  wrapperIntro = setupNamespace( name ) + wrapperIntro;
9014
9063
  }
9015
9064
 
9065
+ var wrapperOutro = "\n\n}(" + dependencies + "));";
9066
+
9067
+ if (possibleVariableAssignment && exportMode === 'named') {
9068
+ wrapperOutro = "\n\n" + indentString + "return exports;" + wrapperOutro;
9069
+ }
9070
+
9016
9071
  // var foo__default = 'default' in foo ? foo['default'] : foo;
9017
9072
  var interopBlock = getInteropBlock( bundle, options );
9018
9073
  if ( interopBlock ) { magicString.prepend( interopBlock + '\n\n' ); }
@@ -9045,6 +9100,15 @@ function setupNamespace$1 ( name ) {
9045
9100
  .join( ', ' );
9046
9101
  }
9047
9102
 
9103
+ function safeAccess ( name ) {
9104
+ var parts = name.split( '.' );
9105
+
9106
+ var acc = 'global';
9107
+ return parts
9108
+ .map( function (part) { return ( acc += property( part ), acc ); } )
9109
+ .join( " && " );
9110
+ }
9111
+
9048
9112
  var wrapperOutro = '\n\n})));';
9049
9113
 
9050
9114
  function umd ( bundle, magicString, ref, options ) {
@@ -9074,7 +9138,7 @@ function umd ( bundle, magicString, ref, options ) {
9074
9138
  if ( exportMode === 'named' ) {
9075
9139
  amdDeps.unshift( "'exports'" );
9076
9140
  cjsDeps.unshift( "exports" );
9077
- globalDeps.unshift( ("(" + (setupNamespace$1(options.moduleName)) + " = " + (globalProp(options.moduleName)) + " || {})") );
9141
+ globalDeps.unshift( ("(" + (setupNamespace$1(options.moduleName)) + " = " + (options.extend ? ((globalProp(options.moduleName)) + " || ") : '') + "{})") );
9078
9142
 
9079
9143
  args.unshift( 'exports' );
9080
9144
  }
@@ -9092,8 +9156,21 @@ function umd ( bundle, magicString, ref, options ) {
9092
9156
 
9093
9157
  var useStrict = options.useStrict !== false ? " 'use strict';" : "";
9094
9158
 
9095
- var globalExport = options.noConflict === true ?
9096
- ("(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 + "))");
9159
+ var globalExport;
9160
+
9161
+ if (options.noConflict === true) {
9162
+ var factory;
9163
+
9164
+ if ( exportMode === 'default' ) {
9165
+ factory = "var exports = factory(" + globalDeps + ");";
9166
+ } else if ( exportMode === 'named' ) {
9167
+ var module = globalDeps.shift();
9168
+ factory = "var exports = " + module + ";\n\t\t\t\tfactory(" + (['exports'].concat(globalDeps)) + ");";
9169
+ }
9170
+ 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})()";
9171
+ } else {
9172
+ globalExport = "(" + defaultExport + "factory(" + globalDeps + "))";
9173
+ }
9097
9174
 
9098
9175
  var wrapperIntro =
9099
9176
  ("(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' );
@@ -9348,39 +9425,40 @@ function transform ( bundle, source, id, plugins ) {
9348
9425
  }
9349
9426
 
9350
9427
  function transformBundle ( code, plugins, sourceMapChain, options ) {
9351
- return plugins.reduce( function ( code, plugin ) {
9352
- if ( !plugin.transformBundle ) { return code; }
9353
-
9354
- var result;
9355
-
9356
- try {
9357
- result = plugin.transformBundle( code, { format : options.format } );
9358
- } catch ( err ) {
9359
- error({
9360
- code: 'BAD_BUNDLE_TRANSFORMER',
9361
- message: ("Error transforming bundle" + (plugin.name ? (" with '" + (plugin.name) + "' plugin") : '') + ": " + (err.message)),
9362
- plugin: plugin.name
9363
- });
9364
- }
9365
-
9366
- if ( result == null ) { return code; }
9428
+ return plugins.reduce( function ( promise, plugin ) {
9429
+ if ( !plugin.transformBundle ) { return promise; }
9430
+
9431
+ return promise.then( function (code) {
9432
+ return Promise.resolve().then( function () {
9433
+ return plugin.transformBundle( code, { format : options.format } );
9434
+ }).then( function (result) {
9435
+ if ( result == null ) { return code; }
9436
+
9437
+ if ( typeof result === 'string' ) {
9438
+ result = {
9439
+ code: result,
9440
+ map: null
9441
+ };
9442
+ }
9367
9443
 
9368
- if ( typeof result === 'string' ) {
9369
- result = {
9370
- code: result,
9371
- map: null
9372
- };
9373
- }
9444
+ var map = typeof result.map === 'string' ? JSON.parse( result.map ) : result.map;
9445
+ if ( map && typeof map.mappings === 'string' ) {
9446
+ map.mappings = decode$$1( map.mappings );
9447
+ }
9374
9448
 
9375
- var map = typeof result.map === 'string' ? JSON.parse( result.map ) : result.map;
9376
- if ( map && typeof map.mappings === 'string' ) {
9377
- map.mappings = decode$$1( map.mappings );
9378
- }
9449
+ sourceMapChain.push( map );
9379
9450
 
9380
- sourceMapChain.push( map );
9451
+ return result.code;
9452
+ }).catch( function (err) {
9453
+ error({
9454
+ code: 'BAD_BUNDLE_TRANSFORMER',
9455
+ message: ("Error transforming bundle" + (plugin.name ? (" with '" + (plugin.name) + "' plugin") : '') + ": " + (err.message)),
9456
+ plugin: plugin.name
9457
+ });
9458
+ });
9459
+ });
9381
9460
 
9382
- return result.code;
9383
- }, code );
9461
+ }, Promise.resolve( code ) );
9384
9462
  }
9385
9463
 
9386
9464
  var Source = function Source ( filename, content ) {
@@ -9947,7 +10025,7 @@ Bundle.prototype.fetchModule = function fetchModule ( id, importer ) {
9947
10025
  }
9948
10026
  });
9949
10027
  module.exportAllSources.forEach( function (source) {
9950
- var id = module.resolvedIds[ source ];
10028
+ var id = module.resolvedIds[ source ] || module.resolvedExternalIds[ source ];
9951
10029
  var exportAllModule = this$1.moduleById.get( id );
9952
10030
  if ( exportAllModule.isExternal ) { return; }
9953
10031
 
@@ -9997,7 +10075,7 @@ Bundle.prototype.fetchAllDependencies = function fetchAllDependencies ( module )
9997
10075
  }
9998
10076
 
9999
10077
  if ( isExternal ) {
10000
- module.resolvedIds[ source ] = externalId;
10078
+ module.resolvedExternalIds[ source ] = externalId;
10001
10079
 
10002
10080
  if ( !this$1.moduleById.has( externalId ) ) {
10003
10081
  var module$1 = new ExternalModule( externalId, this$1.getPath( externalId ) );
@@ -10050,119 +10128,121 @@ Bundle.prototype.render = function render ( options ) {
10050
10128
  var this$1 = this;
10051
10129
  if ( options === void 0 ) options = {};
10052
10130
 
10053
- if ( options.format === 'es6' ) {
10054
- this.warn({
10055
- code: 'DEPRECATED_ES6',
10056
- message: 'The es6 format is deprecated – use `es` instead'
10057
- });
10058
-
10059
- options.format = 'es';
10060
- }
10131
+ return Promise.resolve().then( function () {
10132
+ if ( options.format === 'es6' ) {
10133
+ this$1.warn({
10134
+ code: 'DEPRECATED_ES6',
10135
+ message: 'The es6 format is deprecated – use `es` instead'
10136
+ });
10061
10137
 
10062
- // Determine export mode - 'default', 'named', 'none'
10063
- var exportMode = getExportMode( this, options );
10138
+ options.format = 'es';
10139
+ }
10064
10140
 
10065
- var magicString = new Bundle$2({ separator: '\n\n' });
10066
- var usedModules = [];
10141
+ // Determine export mode - 'default', 'named', 'none'
10142
+ var exportMode = getExportMode( this$1, options );
10067
10143
 
10068
- timeStart( 'render modules' );
10144
+ var magicString = new Bundle$2({ separator: '\n\n' });
10145
+ var usedModules = [];
10069
10146
 
10070
- this.orderedModules.forEach( function (module) {
10071
- var source = module.render( options.format === 'es', this$1.legacy );
10147
+ timeStart( 'render modules' );
10072
10148
 
10073
- if ( source.toString().length ) {
10074
- magicString.addSource( source );
10075
- usedModules.push( module );
10076
- }
10077
- });
10149
+ this$1.orderedModules.forEach( function (module) {
10150
+ var source = module.render( options.format === 'es', this$1.legacy );
10078
10151
 
10079
- if ( !magicString.toString().trim() && this.entryModule.getExports().length === 0 ) {
10080
- this.warn({
10081
- code: 'EMPTY_BUNDLE',
10082
- message: 'Generated an empty bundle'
10152
+ if ( source.toString().length ) {
10153
+ magicString.addSource( source );
10154
+ usedModules.push( module );
10155
+ }
10083
10156
  });
10084
- }
10085
10157
 
10086
- timeEnd( 'render modules' );
10158
+ if ( !magicString.toString().trim() && this$1.entryModule.getExports().length === 0 ) {
10159
+ this$1.warn({
10160
+ code: 'EMPTY_BUNDLE',
10161
+ message: 'Generated an empty bundle'
10162
+ });
10163
+ }
10087
10164
 
10088
- var intro = [ options.intro ]
10089
- .concat(
10090
- this.plugins.map( function (plugin) { return plugin.intro && plugin.intro(); } )
10091
- )
10092
- .filter( Boolean )
10093
- .join( '\n\n' );
10165
+ timeEnd( 'render modules' );
10094
10166
 
10095
- if ( intro ) { intro += '\n\n'; }
10167
+ var intro = [ options.intro ]
10168
+ .concat(
10169
+ this$1.plugins.map( function (plugin) { return plugin.intro && plugin.intro(); } )
10170
+ )
10171
+ .filter( Boolean )
10172
+ .join( '\n\n' );
10096
10173
 
10097
- var outro = [ options.outro ]
10098
- .concat(
10099
- this.plugins.map( function (plugin) { return plugin.outro && plugin.outro(); } )
10100
- )
10101
- .filter( Boolean )
10102
- .join( '\n\n' );
10174
+ if ( intro ) { intro += '\n\n'; }
10103
10175
 
10104
- if ( outro ) { outro = "\n\n" + outro; }
10176
+ var outro = [ options.outro ]
10177
+ .concat(
10178
+ this$1.plugins.map( function (plugin) { return plugin.outro && plugin.outro(); } )
10179
+ )
10180
+ .filter( Boolean )
10181
+ .join( '\n\n' );
10105
10182
 
10106
- var indentString = getIndentString( magicString, options );
10183
+ if ( outro ) { outro = "\n\n" + outro; }
10107
10184
 
10108
- var finalise = finalisers[ options.format ];
10109
- if ( !finalise ) {
10110
- error({
10111
- code: 'INVALID_OPTION',
10112
- message: ("You must specify an output type - valid options are " + (keys( finalisers ).join( ', ' )))
10113
- });
10114
- }
10185
+ var indentString = getIndentString( magicString, options );
10115
10186
 
10116
- timeStart( 'render format' );
10187
+ var finalise = finalisers[ options.format ];
10188
+ if ( !finalise ) {
10189
+ error({
10190
+ code: 'INVALID_OPTION',
10191
+ message: ("You must specify an output type - valid options are " + (keys( finalisers ).join( ', ' )))
10192
+ });
10193
+ }
10117
10194
 
10118
- magicString = finalise( this, magicString.trim(), { exportMode: exportMode, indentString: indentString, intro: intro, outro: outro }, options );
10195
+ timeStart( 'render format' );
10119
10196
 
10120
- timeEnd( 'render format' );
10197
+ magicString = finalise( this$1, magicString.trim(), { exportMode: exportMode, indentString: indentString, intro: intro, outro: outro }, options );
10121
10198
 
10122
- var banner = [ options.banner ]
10123
- .concat( this.plugins.map( function (plugin) { return plugin.banner; } ) )
10124
- .map( callIfFunction )
10125
- .filter( Boolean )
10126
- .join( '\n' );
10199
+ timeEnd( 'render format' );
10127
10200
 
10128
- var footer = [ options.footer ]
10129
- .concat( this.plugins.map( function (plugin) { return plugin.footer; } ) )
10130
- .map( callIfFunction )
10131
- .filter( Boolean )
10132
- .join( '\n' );
10201
+ var banner = [ options.banner ]
10202
+ .concat( this$1.plugins.map( function (plugin) { return plugin.banner; } ) )
10203
+ .map( callIfFunction )
10204
+ .filter( Boolean )
10205
+ .join( '\n' );
10133
10206
 
10134
- if ( banner ) { magicString.prepend( banner + '\n' ); }
10135
- if ( footer ) { magicString.append( '\n' + footer ); }
10207
+ var footer = [ options.footer ]
10208
+ .concat( this$1.plugins.map( function (plugin) { return plugin.footer; } ) )
10209
+ .map( callIfFunction )
10210
+ .filter( Boolean )
10211
+ .join( '\n' );
10136
10212
 
10137
- var code = magicString.toString();
10138
- var map = null;
10139
- var bundleSourcemapChain = [];
10213
+ if ( banner ) { magicString.prepend( banner + '\n' ); }
10214
+ if ( footer ) { magicString.append( '\n' + footer ); }
10140
10215
 
10141
- code = transformBundle( code, this.plugins, bundleSourcemapChain, options );
10216
+ var prevCode = magicString.toString();
10217
+ var map = null;
10218
+ var bundleSourcemapChain = [];
10142
10219
 
10143
- if ( options.sourceMap ) {
10144
- timeStart( 'sourceMap' );
10220
+ return transformBundle( prevCode, this$1.plugins, bundleSourcemapChain, options ).then( function (code) {
10221
+ if ( options.sourceMap ) {
10222
+ timeStart( 'sourceMap' );
10145
10223
 
10146
- var file = options.sourceMapFile || options.dest;
10147
- if ( file ) { file = resolve( typeof process !== 'undefined' ? process.cwd() : '', file ); }
10224
+ var file = options.sourceMapFile || options.dest;
10225
+ if ( file ) { file = resolve( typeof process !== 'undefined' ? process.cwd() : '', file ); }
10148
10226
 
10149
- if ( this.hasLoaders || find( this.plugins, function (plugin) { return plugin.transform || plugin.transformBundle; } ) ) {
10150
- map = magicString.generateMap({});
10151
- if ( typeof map.mappings === 'string' ) {
10152
- map.mappings = decode$$1( map.mappings );
10153
- }
10154
- map = collapseSourcemaps( this, file, map, usedModules, bundleSourcemapChain );
10155
- } else {
10156
- map = magicString.generateMap({ file: file, includeContent: true });
10157
- }
10227
+ if ( this$1.hasLoaders || find( this$1.plugins, function (plugin) { return plugin.transform || plugin.transformBundle; } ) ) {
10228
+ map = magicString.generateMap({});
10229
+ if ( typeof map.mappings === 'string' ) {
10230
+ map.mappings = decode$$1( map.mappings );
10231
+ }
10232
+ map = collapseSourcemaps( this$1, file, map, usedModules, bundleSourcemapChain );
10233
+ } else {
10234
+ map = magicString.generateMap({ file: file, includeContent: true });
10235
+ }
10158
10236
 
10159
- map.sources = map.sources.map( normalize );
10237
+ map.sources = map.sources.map( normalize );
10160
10238
 
10161
- timeEnd( 'sourceMap' );
10162
- }
10239
+ timeEnd( 'sourceMap' );
10240
+ }
10163
10241
 
10164
- if ( code[ code.length - 1 ] !== '\n' ) { code += '\n'; }
10165
- return { code: code, map: map };
10242
+ if ( code[ code.length - 1 ] !== '\n' ) { code += '\n'; }
10243
+ return { code: code, map: map };
10244
+ });
10245
+ });
10166
10246
  };
10167
10247
 
10168
10248
  Bundle.prototype.sort = function sort () {
@@ -10267,7 +10347,7 @@ Bundle.prototype.warn = function warn ( warning ) {
10267
10347
  this.onwarn( warning );
10268
10348
  };
10269
10349
 
10270
- var VERSION = '0.43.1';
10350
+ var VERSION = '0.45.2';
10271
10351
 
10272
10352
  var ALLOWED_KEYS = [
10273
10353
  'acorn',
@@ -10278,6 +10358,7 @@ var ALLOWED_KEYS = [
10278
10358
  'dest',
10279
10359
  'entry',
10280
10360
  'exports',
10361
+ 'extend',
10281
10362
  'external',
10282
10363
  'footer',
10283
10364
  'format',
@@ -10334,6 +10415,12 @@ function checkOptions ( options ) {
10334
10415
  if ( err ) { throw err; }
10335
10416
  }
10336
10417
 
10418
+ var throwAsyncGenerateError = {
10419
+ get: function get () {
10420
+ throw new Error( "bundle.generate(...) now returns a Promise instead of a { code, map } object" );
10421
+ }
10422
+ };
10423
+
10337
10424
  function rollup ( options ) {
10338
10425
  try {
10339
10426
  checkOptions( options );
@@ -10361,21 +10448,28 @@ function rollup ( options ) {
10361
10448
 
10362
10449
  timeStart( '--GENERATE--' );
10363
10450
 
10364
- var rendered = bundle.render( options );
10451
+ var promise = Promise.resolve()
10452
+ .then( function () { return bundle.render( options ); } )
10453
+ .then( function (rendered) {
10454
+ timeEnd( '--GENERATE--' );
10365
10455
 
10366
- timeEnd( '--GENERATE--' );
10456
+ bundle.plugins.forEach( function (plugin) {
10457
+ if ( plugin.ongenerate ) {
10458
+ plugin.ongenerate( assign({
10459
+ bundle: result
10460
+ }, options ), rendered);
10461
+ }
10462
+ });
10367
10463
 
10368
- bundle.plugins.forEach( function (plugin) {
10369
- if ( plugin.ongenerate ) {
10370
- plugin.ongenerate( assign({
10371
- bundle: result
10372
- }, options ), rendered);
10373
- }
10374
- });
10464
+ flushTime();
10375
10465
 
10376
- flushTime();
10466
+ return rendered;
10467
+ });
10468
+
10469
+ Object.defineProperty( promise, 'code', throwAsyncGenerateError );
10470
+ Object.defineProperty( promise, 'map', throwAsyncGenerateError );
10377
10471
 
10378
- return rendered;
10472
+ return promise;
10379
10473
  }
10380
10474
 
10381
10475
  var result = {
@@ -10393,31 +10487,32 @@ function rollup ( options ) {
10393
10487
  }
10394
10488
 
10395
10489
  var dest = options.dest;
10396
- var output = generate( options );
10397
- var code = output.code;
10398
- var map = output.map;
10490
+ return generate( options ).then( function (output) {
10491
+ var code = output.code;
10492
+ var map = output.map;
10399
10493
 
10400
- var promises = [];
10494
+ var promises = [];
10401
10495
 
10402
- if ( options.sourceMap ) {
10403
- var url;
10496
+ if ( options.sourceMap ) {
10497
+ var url;
10404
10498
 
10405
- if ( options.sourceMap === 'inline' ) {
10406
- url = map.toUrl();
10407
- } else {
10408
- url = (basename( dest )) + ".map";
10409
- promises.push( writeFile$1( dest + '.map', map.toString() ) );
10410
- }
10499
+ if ( options.sourceMap === 'inline' ) {
10500
+ url = map.toUrl();
10501
+ } else {
10502
+ url = (basename( dest )) + ".map";
10503
+ promises.push( writeFile$1( dest + '.map', map.toString() ) );
10504
+ }
10411
10505
 
10412
- code += "//# " + SOURCEMAPPING_URL + "=" + url + "\n";
10413
- }
10506
+ code += "//# " + SOURCEMAPPING_URL + "=" + url + "\n";
10507
+ }
10414
10508
 
10415
- promises.push( writeFile$1( dest, code ) );
10416
- return Promise.all( promises ).then( function () {
10417
- return mapSequence( bundle.plugins.filter( function (plugin) { return plugin.onwrite; } ), function (plugin) {
10418
- return Promise.resolve( plugin.onwrite( assign({
10419
- bundle: result
10420
- }, options ), output));
10509
+ promises.push( writeFile$1( dest, code ) );
10510
+ return Promise.all( promises ).then( function () {
10511
+ return mapSequence( bundle.plugins.filter( function (plugin) { return plugin.onwrite; } ), function (plugin) {
10512
+ return Promise.resolve( plugin.onwrite( assign({
10513
+ bundle: result
10514
+ }, options ), output));
10515
+ });
10421
10516
  });
10422
10517
  });
10423
10518
  }