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 +22 -0
- package/README.md +3 -1
- package/bin/rollup +1 -1
- package/dist/rollup.browser.js +151 -53
- package/dist/rollup.browser.js.map +1 -1
- package/dist/rollup.es.js +151 -53
- package/dist/rollup.es.js.map +1 -1
- package/dist/rollup.js +151 -53
- package/dist/rollup.js.map +1 -1
- package/package.json +1 -1
package/dist/rollup.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Rollup.js v0.36.
|
|
3
|
-
|
|
2
|
+
Rollup.js v0.36.4
|
|
3
|
+
Wed Nov 23 2016 09:01:35 GMT-0500 (EST) - commit fca14dbab102a9fa8efc7249287e2145583712ea
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
@@ -185,9 +185,7 @@ function mapSequence ( array, fn ) {
|
|
|
185
185
|
return promise.then( function () { return results; } );
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
function validateKeys (
|
|
189
|
-
var actualKeys = keys( object );
|
|
190
|
-
|
|
188
|
+
function validateKeys ( actualKeys, allowedKeys ) {
|
|
191
189
|
var i = actualKeys.length;
|
|
192
190
|
|
|
193
191
|
while ( i-- ) {
|
|
@@ -5010,6 +5008,11 @@ function makeLegalIdentifier ( str ) {
|
|
|
5010
5008
|
return str;
|
|
5011
5009
|
}
|
|
5012
5010
|
|
|
5011
|
+
function relativeId ( id ) {
|
|
5012
|
+
if ( typeof process === 'undefined' ) return id;
|
|
5013
|
+
return id.replace( process.cwd(), '' ).replace( /^[\/\\]/, '' );
|
|
5014
|
+
}
|
|
5015
|
+
|
|
5013
5016
|
// properties are for debugging purposes only
|
|
5014
5017
|
var ARRAY = { ARRAY: true, toString: function () { return '[[ARRAY]]'; } };
|
|
5015
5018
|
var NUMBER = { NUMBER: true, toString: function () { return '[[NUMBER]]'; } };
|
|
@@ -5054,7 +5057,7 @@ SyntheticNamespaceDeclaration.prototype.getName = function getName () {
|
|
|
5054
5057
|
return this.name;
|
|
5055
5058
|
};
|
|
5056
5059
|
|
|
5057
|
-
SyntheticNamespaceDeclaration.prototype.renderBlock = function renderBlock ( es, indentString ) {
|
|
5060
|
+
SyntheticNamespaceDeclaration.prototype.renderBlock = function renderBlock ( es, legacy, indentString ) {
|
|
5058
5061
|
var this$1 = this;
|
|
5059
5062
|
|
|
5060
5063
|
var members = keys( this.originals ).map( function (name) {
|
|
@@ -5067,7 +5070,8 @@ SyntheticNamespaceDeclaration.prototype.renderBlock = function renderBlock ( es,
|
|
|
5067
5070
|
return ("" + indentString + name + ": " + (original.getName( es )));
|
|
5068
5071
|
});
|
|
5069
5072
|
|
|
5070
|
-
|
|
5073
|
+
var callee = legacy ? "(Object.freeze || Object)" : "Object.freeze";
|
|
5074
|
+
return ((this.module.bundle.varOrConst) + " " + (this.getName( es )) + " = " + callee + "({\n" + (members.join( ',\n' )) + "\n});\n\n");
|
|
5071
5075
|
};
|
|
5072
5076
|
|
|
5073
5077
|
var ExternalDeclaration = function ExternalDeclaration ( module, name ) {
|
|
@@ -5217,6 +5221,12 @@ Node$1.prototype.initialise = function initialise ( scope ) {
|
|
|
5217
5221
|
this.eachChild( function (child) { return child.initialise( this$1.scope || scope ); } );
|
|
5218
5222
|
};
|
|
5219
5223
|
|
|
5224
|
+
Node$1.prototype.insertSemicolon = function insertSemicolon ( code ) {
|
|
5225
|
+
if ( code.original[ this.end - 1 ] !== ';' ) {
|
|
5226
|
+
code.insertLeft( this.end, ';' );
|
|
5227
|
+
}
|
|
5228
|
+
};
|
|
5229
|
+
|
|
5220
5230
|
Node$1.prototype.locate = function locate () {
|
|
5221
5231
|
// useful for debugging
|
|
5222
5232
|
var location = getLocation( this.module.code, this.start );
|
|
@@ -5285,7 +5295,7 @@ Parameter.prototype.getName = function getName () {
|
|
|
5285
5295
|
};
|
|
5286
5296
|
|
|
5287
5297
|
var Scope = function Scope ( options ) {
|
|
5288
|
-
options
|
|
5298
|
+
if ( options === void 0 ) options = {};
|
|
5289
5299
|
|
|
5290
5300
|
this.parent = options.parent;
|
|
5291
5301
|
this.isBlockScope = !!options.isBlockScope;
|
|
@@ -5660,6 +5670,16 @@ var BlockStatement = (function (Statement) {
|
|
|
5660
5670
|
}
|
|
5661
5671
|
};
|
|
5662
5672
|
|
|
5673
|
+
BlockStatement.prototype.render = function render ( code, es ) {
|
|
5674
|
+
if (this.body.length) {
|
|
5675
|
+
for ( var node of this.body ) {
|
|
5676
|
+
node.render( code, es );
|
|
5677
|
+
}
|
|
5678
|
+
} else {
|
|
5679
|
+
Statement.prototype.render.call(this, code, es);
|
|
5680
|
+
}
|
|
5681
|
+
};
|
|
5682
|
+
|
|
5663
5683
|
return BlockStatement;
|
|
5664
5684
|
}(Statement));
|
|
5665
5685
|
|
|
@@ -5847,7 +5867,9 @@ var CallExpression = (function (Node) {
|
|
|
5847
5867
|
};
|
|
5848
5868
|
|
|
5849
5869
|
CallExpression.prototype.initialise = function initialise ( scope ) {
|
|
5850
|
-
|
|
5870
|
+
if ( isProgramLevel( this ) ) {
|
|
5871
|
+
this.module.bundle.dependentExpressions.push( this );
|
|
5872
|
+
}
|
|
5851
5873
|
Node.prototype.initialise.call( this, scope );
|
|
5852
5874
|
};
|
|
5853
5875
|
|
|
@@ -5858,6 +5880,17 @@ var CallExpression = (function (Node) {
|
|
|
5858
5880
|
return CallExpression;
|
|
5859
5881
|
}(Node$1));
|
|
5860
5882
|
|
|
5883
|
+
function isProgramLevel ( node ) {
|
|
5884
|
+
do {
|
|
5885
|
+
if ( node.type === 'Program' ) {
|
|
5886
|
+
return true;
|
|
5887
|
+
}
|
|
5888
|
+
node = node.parent;
|
|
5889
|
+
} while ( node && !/Function/.test( node.type ) );
|
|
5890
|
+
|
|
5891
|
+
return false;
|
|
5892
|
+
}
|
|
5893
|
+
|
|
5861
5894
|
// TODO is this basically identical to FunctionDeclaration?
|
|
5862
5895
|
var ClassDeclaration = (function (Node) {
|
|
5863
5896
|
function ClassDeclaration () {
|
|
@@ -6114,7 +6147,7 @@ var ExportDefaultDeclaration = (function (Node) {
|
|
|
6114
6147
|
var treeshake = this.module.bundle.treeshake;
|
|
6115
6148
|
var name = this.getName( es );
|
|
6116
6149
|
|
|
6117
|
-
if ( this.shouldInclude ) {
|
|
6150
|
+
if ( this.shouldInclude || this.declaration.activated ) {
|
|
6118
6151
|
if ( this.activated ) {
|
|
6119
6152
|
if ( functionOrClassDeclaration.test( this.declaration.type ) ) {
|
|
6120
6153
|
if ( this.declaration.id ) {
|
|
@@ -6132,6 +6165,8 @@ var ExportDefaultDeclaration = (function (Node) {
|
|
|
6132
6165
|
} else {
|
|
6133
6166
|
code.overwrite( this.start, this.declaration.start, ((this.module.bundle.varOrConst) + " " + name + " = ") );
|
|
6134
6167
|
}
|
|
6168
|
+
|
|
6169
|
+
this.insertSemicolon( code );
|
|
6135
6170
|
}
|
|
6136
6171
|
} else {
|
|
6137
6172
|
// remove `var foo` from `var foo = bar()`, if `foo` is unused
|
|
@@ -6141,7 +6176,7 @@ var ExportDefaultDeclaration = (function (Node) {
|
|
|
6141
6176
|
Node.prototype.render.call( this, code, es );
|
|
6142
6177
|
} else {
|
|
6143
6178
|
if ( treeshake ) {
|
|
6144
|
-
if ( functionOrClassDeclaration.test( this.declaration.type )
|
|
6179
|
+
if ( functionOrClassDeclaration.test( this.declaration.type ) ) {
|
|
6145
6180
|
code.remove( this.leadingCommentStart || this.start, this.next || this.end );
|
|
6146
6181
|
} else {
|
|
6147
6182
|
var hasEffects = this.declaration.hasEffects( this.module.scope );
|
|
@@ -6251,11 +6286,16 @@ var ExportNamedDeclaration = (function (Node) {
|
|
|
6251
6286
|
var ExpressionStatement = (function (Statement) {
|
|
6252
6287
|
function ExpressionStatement () {
|
|
6253
6288
|
Statement.apply(this, arguments);
|
|
6254
|
-
}
|
|
6289
|
+
}
|
|
6290
|
+
|
|
6291
|
+
if ( Statement ) ExpressionStatement.__proto__ = Statement;
|
|
6255
6292
|
ExpressionStatement.prototype = Object.create( Statement && Statement.prototype );
|
|
6256
6293
|
ExpressionStatement.prototype.constructor = ExpressionStatement;
|
|
6257
6294
|
|
|
6258
|
-
|
|
6295
|
+
ExpressionStatement.prototype.render = function render ( code, es ) {
|
|
6296
|
+
Statement.prototype.render.call( this, code, es );
|
|
6297
|
+
if ( this.shouldInclude ) this.insertSemicolon( code );
|
|
6298
|
+
};
|
|
6259
6299
|
|
|
6260
6300
|
return ExpressionStatement;
|
|
6261
6301
|
}(Statement));
|
|
@@ -6518,6 +6558,16 @@ var Identifier = (function (Node) {
|
|
|
6518
6558
|
return Identifier;
|
|
6519
6559
|
}(Node$1));
|
|
6520
6560
|
|
|
6561
|
+
// Statement types which may contain if-statements as direct children.
|
|
6562
|
+
var statementsWithIfStatements = new Set([
|
|
6563
|
+
'DoWhileStatement',
|
|
6564
|
+
'ForInStatement',
|
|
6565
|
+
'ForOfStatement',
|
|
6566
|
+
'ForStatement',
|
|
6567
|
+
'IfStatement',
|
|
6568
|
+
'WhileStatement'
|
|
6569
|
+
]);
|
|
6570
|
+
|
|
6521
6571
|
// TODO DRY this out
|
|
6522
6572
|
var IfStatement = (function (Statement) {
|
|
6523
6573
|
function IfStatement () {
|
|
@@ -6539,7 +6589,9 @@ var IfStatement = (function (Statement) {
|
|
|
6539
6589
|
else if ( this.testValue ) {
|
|
6540
6590
|
this.consequent.initialise( scope );
|
|
6541
6591
|
this.alternate = null;
|
|
6542
|
-
}
|
|
6592
|
+
}
|
|
6593
|
+
|
|
6594
|
+
else {
|
|
6543
6595
|
if ( this.alternate ) this.alternate.initialise( scope );
|
|
6544
6596
|
this.consequent = null;
|
|
6545
6597
|
}
|
|
@@ -6566,9 +6618,18 @@ var IfStatement = (function (Statement) {
|
|
|
6566
6618
|
code.remove( this.start, this.consequent.start );
|
|
6567
6619
|
code.remove( this.consequent.end, this.end );
|
|
6568
6620
|
this.consequent.render( code, es );
|
|
6569
|
-
}
|
|
6621
|
+
}
|
|
6622
|
+
|
|
6623
|
+
else {
|
|
6570
6624
|
code.remove( this.start, this.alternate ? this.alternate.start : this.next || this.end );
|
|
6571
|
-
|
|
6625
|
+
|
|
6626
|
+
if ( this.alternate ) {
|
|
6627
|
+
this.alternate.render( code, es );
|
|
6628
|
+
}
|
|
6629
|
+
|
|
6630
|
+
else if ( statementsWithIfStatements.has( this.parent.type ) ) {
|
|
6631
|
+
code.insertRight( this.start, '{}' );
|
|
6632
|
+
}
|
|
6572
6633
|
}
|
|
6573
6634
|
}
|
|
6574
6635
|
}
|
|
@@ -6796,6 +6857,8 @@ var TemplateLiteral = (function (Node) {
|
|
|
6796
6857
|
return TemplateLiteral;
|
|
6797
6858
|
}(Node$1));
|
|
6798
6859
|
|
|
6860
|
+
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";
|
|
6861
|
+
|
|
6799
6862
|
var ThisExpression = (function (Node) {
|
|
6800
6863
|
function ThisExpression () {
|
|
6801
6864
|
Node.apply(this, arguments);
|
|
@@ -6809,9 +6872,13 @@ var ThisExpression = (function (Node) {
|
|
|
6809
6872
|
var lexicalBoundary = scope.findLexicalBoundary();
|
|
6810
6873
|
|
|
6811
6874
|
if ( lexicalBoundary.isModuleScope ) {
|
|
6812
|
-
this.alias = this.module.
|
|
6875
|
+
this.alias = this.module.context;
|
|
6813
6876
|
if ( this.alias === 'undefined' ) {
|
|
6814
|
-
|
|
6877
|
+
var ref = getLocation( this.module.code, this.start );
|
|
6878
|
+
var line = ref.line;
|
|
6879
|
+
var column = ref.column;
|
|
6880
|
+
var detail = (relativeId( this.module.id )) + " (" + line + ":" + (column + 1) + ")"; // use one-based column number convention
|
|
6881
|
+
this.module.bundle.onwarn( (detail + " " + warning) );
|
|
6815
6882
|
}
|
|
6816
6883
|
}
|
|
6817
6884
|
};
|
|
@@ -7042,7 +7109,7 @@ function getSeparator ( code, start ) {
|
|
|
7042
7109
|
return (";\n" + lineStart);
|
|
7043
7110
|
}
|
|
7044
7111
|
|
|
7045
|
-
var forStatement = /^For(?:Of|In)Statement/;
|
|
7112
|
+
var forStatement = /^For(?:Of|In)?Statement/;
|
|
7046
7113
|
|
|
7047
7114
|
var VariableDeclaration = (function (Node) {
|
|
7048
7115
|
function VariableDeclaration () {
|
|
@@ -7132,9 +7199,16 @@ var VariableDeclaration = (function (Node) {
|
|
|
7132
7199
|
|
|
7133
7200
|
if ( treeshake && empty ) {
|
|
7134
7201
|
code.remove( this.leadingCommentStart || this.start, this.next || this.end );
|
|
7135
|
-
} else
|
|
7136
|
-
|
|
7137
|
-
|
|
7202
|
+
} else {
|
|
7203
|
+
// always include a semi-colon (https://github.com/rollup/rollup/pull/1013),
|
|
7204
|
+
// unless it's a var declaration in a loop head
|
|
7205
|
+
var needsSemicolon = !forStatement.test( this.parent.type );
|
|
7206
|
+
|
|
7207
|
+
if ( this.end > c ) {
|
|
7208
|
+
code.overwrite( c, this.end, needsSemicolon ? ';' : '' );
|
|
7209
|
+
} else if ( needsSemicolon ) {
|
|
7210
|
+
this.insertSemicolon( code );
|
|
7211
|
+
}
|
|
7138
7212
|
}
|
|
7139
7213
|
};
|
|
7140
7214
|
|
|
@@ -7351,6 +7425,7 @@ var Module = function Module (ref) {
|
|
|
7351
7425
|
this.bundle = bundle;
|
|
7352
7426
|
this.id = id;
|
|
7353
7427
|
this.excludeFromSourcemap = /\0/.test( id );
|
|
7428
|
+
this.context = bundle.getModuleContext( id );
|
|
7354
7429
|
|
|
7355
7430
|
// all dependencies
|
|
7356
7431
|
this.sources = [];
|
|
@@ -7499,11 +7574,11 @@ Module.prototype.addImport = function addImport ( node ) {
|
|
|
7499
7574
|
if ( !~this.sources.indexOf( source ) ) this.sources.push( source );
|
|
7500
7575
|
|
|
7501
7576
|
node.specifiers.forEach( function (specifier) {
|
|
7502
|
-
|
|
7577
|
+
var localName = specifier.local.name;
|
|
7503
7578
|
|
|
7504
7579
|
if ( this$1.imports[ localName ] ) {
|
|
7505
7580
|
var err = new Error( ("Duplicated import '" + localName + "'") );
|
|
7506
|
-
|
|
7581
|
+
err.file = this$1.id;
|
|
7507
7582
|
err.loc = getLocation( this$1.code, specifier.start );
|
|
7508
7583
|
throw err;
|
|
7509
7584
|
}
|
|
@@ -7590,18 +7665,18 @@ Module.prototype.findParent = function findParent () {
|
|
|
7590
7665
|
|
|
7591
7666
|
Module.prototype.findScope = function findScope () {
|
|
7592
7667
|
return this.scope;
|
|
7593
|
-
|
|
7668
|
+
};
|
|
7594
7669
|
|
|
7595
|
-
|
|
7596
|
-
|
|
7670
|
+
Module.prototype.getExports = function getExports () {
|
|
7671
|
+
var exports = blank();
|
|
7597
7672
|
|
|
7598
|
-
|
|
7673
|
+
keys( this.exports ).forEach( function (name) {
|
|
7599
7674
|
exports[ name ] = true;
|
|
7600
7675
|
});
|
|
7601
7676
|
|
|
7602
7677
|
keys( this.reexports ).forEach( function (name) {
|
|
7603
|
-
|
|
7604
|
-
|
|
7678
|
+
exports[ name ] = true;
|
|
7679
|
+
});
|
|
7605
7680
|
|
|
7606
7681
|
this.exportAllModules.forEach( function (module) {
|
|
7607
7682
|
if ( module.isExternal ) return; // TODO
|
|
@@ -7622,7 +7697,7 @@ Module.prototype.namespace = function namespace () {
|
|
|
7622
7697
|
return this.declarations['*'];
|
|
7623
7698
|
};
|
|
7624
7699
|
|
|
7625
|
-
Module.prototype.render = function render ( es ) {
|
|
7700
|
+
Module.prototype.render = function render ( es, legacy ) {
|
|
7626
7701
|
var magicString = this.magicString.clone();
|
|
7627
7702
|
|
|
7628
7703
|
for ( var node of this.ast.body ) {
|
|
@@ -7630,7 +7705,7 @@ Module.prototype.render = function render ( es ) {
|
|
|
7630
7705
|
}
|
|
7631
7706
|
|
|
7632
7707
|
if ( this.namespace().needsNamespaceBlock ) {
|
|
7633
|
-
magicString.append( '\n\n' + this.namespace().renderBlock( es, '\t' ) ); // TODO use correct indentation
|
|
7708
|
+
magicString.append( '\n\n' + this.namespace().renderBlock( es, legacy, '\t' ) ); // TODO use correct indentation
|
|
7634
7709
|
}
|
|
7635
7710
|
|
|
7636
7711
|
return magicString.trim();
|
|
@@ -7674,7 +7749,7 @@ Module.prototype.trace = function trace ( name ) {
|
|
|
7674
7749
|
|
|
7675
7750
|
var declaration = otherModule.traceExport( importDeclaration.name );
|
|
7676
7751
|
|
|
7677
|
-
if ( !declaration ) throw new Error( ("
|
|
7752
|
+
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") );
|
|
7678
7753
|
return declaration;
|
|
7679
7754
|
}
|
|
7680
7755
|
|
|
@@ -8177,7 +8252,11 @@ function badExports ( option, keys ) {
|
|
|
8177
8252
|
throw new Error( ("'" + option + "' was specified for options.exports, but entry module has following exports: " + (keys.join(', '))) );
|
|
8178
8253
|
}
|
|
8179
8254
|
|
|
8180
|
-
function getExportMode ( bundle,
|
|
8255
|
+
function getExportMode ( bundle, ref ) {
|
|
8256
|
+
var exportMode = ref.exports;
|
|
8257
|
+
var moduleName = ref.moduleName;
|
|
8258
|
+
var format = ref.format;
|
|
8259
|
+
|
|
8181
8260
|
var exportKeys = keys( bundle.entryModule.exports )
|
|
8182
8261
|
.concat( keys( bundle.entryModule.reexports ) )
|
|
8183
8262
|
.concat( bundle.entryModule.exportAllSources ); // not keys, but makes our job easier this way
|
|
@@ -8196,7 +8275,7 @@ function getExportMode ( bundle, exportMode, moduleName ) {
|
|
|
8196
8275
|
} else if ( exportKeys.length === 1 && exportKeys[0] === 'default' ) {
|
|
8197
8276
|
exportMode = 'default';
|
|
8198
8277
|
} else {
|
|
8199
|
-
if ( bundle.entryModule.exports.default ) {
|
|
8278
|
+
if ( bundle.entryModule.exports.default && format !== 'es') {
|
|
8200
8279
|
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") );
|
|
8201
8280
|
}
|
|
8202
8281
|
exportMode = 'named';
|
|
@@ -8534,11 +8613,10 @@ var Bundle = function Bundle ( options ) {
|
|
|
8534
8613
|
|
|
8535
8614
|
this.plugins = ensureArray( options.plugins );
|
|
8536
8615
|
|
|
8537
|
-
this.plugins.
|
|
8538
|
-
if ( plugin.options )
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
});
|
|
8616
|
+
options = this.plugins.reduce( function ( acc, plugin ) {
|
|
8617
|
+
if ( plugin.options ) return plugin.options( acc ) || acc;
|
|
8618
|
+
return acc;
|
|
8619
|
+
}, options);
|
|
8542
8620
|
|
|
8543
8621
|
this.entry = options.entry;
|
|
8544
8622
|
this.entryId = null;
|
|
@@ -8576,6 +8654,18 @@ var Bundle = function Bundle ( options ) {
|
|
|
8576
8654
|
|
|
8577
8655
|
this.context = String( options.context );
|
|
8578
8656
|
|
|
8657
|
+
if ( typeof options.moduleContext === 'function' ) {
|
|
8658
|
+
this.getModuleContext = function (id) { return options.moduleContext( id ) || this$1.context; };
|
|
8659
|
+
} else if ( typeof options.moduleContext === 'object' ) {
|
|
8660
|
+
var moduleContext = new Map();
|
|
8661
|
+
Object.keys( options.moduleContext ).forEach( function (key) {
|
|
8662
|
+
moduleContext.set( path.resolve( key ), options.moduleContext[ key ] );
|
|
8663
|
+
});
|
|
8664
|
+
this.getModuleContext = function (id) { return moduleContext.get( id ) || this$1.context; };
|
|
8665
|
+
} else {
|
|
8666
|
+
this.getModuleContext = function () { return this$1.context; };
|
|
8667
|
+
}
|
|
8668
|
+
|
|
8579
8669
|
if ( typeof options.external === 'function' ) {
|
|
8580
8670
|
this.isExternal = options.external;
|
|
8581
8671
|
} else {
|
|
@@ -8586,6 +8676,7 @@ var Bundle = function Bundle ( options ) {
|
|
|
8586
8676
|
this.onwarn = options.onwarn || makeOnwarn();
|
|
8587
8677
|
|
|
8588
8678
|
this.varOrConst = options.preferConst ? 'const' : 'var';
|
|
8679
|
+
this.legacy = options.legacy;
|
|
8589
8680
|
this.acornOptions = options.acorn || {};
|
|
8590
8681
|
|
|
8591
8682
|
this.dependentExpressions = [];
|
|
@@ -8781,7 +8872,7 @@ Bundle.prototype.fetchModule = function fetchModule ( id, importer ) {
|
|
|
8781
8872
|
});
|
|
8782
8873
|
|
|
8783
8874
|
this$1.modules.push( module );
|
|
8784
|
-
|
|
8875
|
+
this$1.moduleById.set( id, module );
|
|
8785
8876
|
|
|
8786
8877
|
return this$1.fetchAllDependencies( module ).then( function () {
|
|
8787
8878
|
keys( module.exports ).forEach( function (name) {
|
|
@@ -8856,6 +8947,7 @@ Bundle.prototype.getPathRelativeToEntryDirname = function getPathRelativeToEntry
|
|
|
8856
8947
|
};
|
|
8857
8948
|
|
|
8858
8949
|
Bundle.prototype.render = function render ( options ) {
|
|
8950
|
+
var this$1 = this;
|
|
8859
8951
|
if ( options === void 0 ) options = {};
|
|
8860
8952
|
|
|
8861
8953
|
if ( options.format === 'es6' ) {
|
|
@@ -8866,7 +8958,7 @@ Bundle.prototype.render = function render ( options ) {
|
|
|
8866
8958
|
var format = options.format || 'es';
|
|
8867
8959
|
|
|
8868
8960
|
// Determine export mode - 'default', 'named', 'none'
|
|
8869
|
-
var exportMode = getExportMode( this, options
|
|
8961
|
+
var exportMode = getExportMode( this, options );
|
|
8870
8962
|
|
|
8871
8963
|
var magicString = new Bundle$1({ separator: '\n\n' });
|
|
8872
8964
|
var usedModules = [];
|
|
@@ -8874,7 +8966,7 @@ Bundle.prototype.render = function render ( options ) {
|
|
|
8874
8966
|
timeStart( 'render modules' );
|
|
8875
8967
|
|
|
8876
8968
|
this.orderedModules.forEach( function (module) {
|
|
8877
|
-
var source = module.render( format === 'es' );
|
|
8969
|
+
var source = module.render( format === 'es', this$1.legacy );
|
|
8878
8970
|
|
|
8879
8971
|
if ( source.toString().length ) {
|
|
8880
8972
|
magicString.addSource( source );
|
|
@@ -8951,7 +9043,7 @@ Bundle.prototype.render = function render ( options ) {
|
|
|
8951
9043
|
return { code: code, map: map };
|
|
8952
9044
|
};
|
|
8953
9045
|
|
|
8954
|
-
Bundle.prototype.sort = function sort () {
|
|
9046
|
+
Bundle.prototype.sort = function sort () {
|
|
8955
9047
|
var this$1 = this;
|
|
8956
9048
|
|
|
8957
9049
|
var hasCycles;
|
|
@@ -9019,7 +9111,7 @@ Bundle.prototype.sort = function sort () {
|
|
|
9019
9111
|
visited[ module.id ] = true;
|
|
9020
9112
|
for ( var i = 0; i < module.dependencies.length; i += 1 ) {
|
|
9021
9113
|
var dependency = module.dependencies[i];
|
|
9022
|
-
|
|
9114
|
+
if ( !visited[ dependency.id ] && findParent( dependency ) ) return true;
|
|
9023
9115
|
}
|
|
9024
9116
|
};
|
|
9025
9117
|
|
|
@@ -9038,7 +9130,7 @@ Bundle.prototype.sort = function sort () {
|
|
|
9038
9130
|
return ordered;
|
|
9039
9131
|
};
|
|
9040
9132
|
|
|
9041
|
-
var VERSION = '0.36.
|
|
9133
|
+
var VERSION = '0.36.4';
|
|
9042
9134
|
|
|
9043
9135
|
var ALLOWED_KEYS = [
|
|
9044
9136
|
'acorn',
|
|
@@ -9055,6 +9147,8 @@ var ALLOWED_KEYS = [
|
|
|
9055
9147
|
'indent',
|
|
9056
9148
|
'interop',
|
|
9057
9149
|
'intro',
|
|
9150
|
+
'legacy',
|
|
9151
|
+
'moduleContext',
|
|
9058
9152
|
'moduleId',
|
|
9059
9153
|
'moduleName',
|
|
9060
9154
|
'noConflict',
|
|
@@ -9070,20 +9164,24 @@ var ALLOWED_KEYS = [
|
|
|
9070
9164
|
'useStrict'
|
|
9071
9165
|
];
|
|
9072
9166
|
|
|
9073
|
-
function
|
|
9167
|
+
function checkOptions ( options ) {
|
|
9074
9168
|
if ( !options || !options.entry ) {
|
|
9075
|
-
return
|
|
9169
|
+
return new Error( 'You must supply options.entry to rollup' );
|
|
9076
9170
|
}
|
|
9077
9171
|
|
|
9078
9172
|
if ( options.transform || options.load || options.resolveId || options.resolveExternal ) {
|
|
9079
|
-
return
|
|
9173
|
+
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' );
|
|
9080
9174
|
}
|
|
9081
9175
|
|
|
9082
|
-
var error = validateKeys( options, ALLOWED_KEYS );
|
|
9176
|
+
var error = validateKeys( keys(options), ALLOWED_KEYS );
|
|
9177
|
+
if ( error ) return error;
|
|
9083
9178
|
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9179
|
+
return null;
|
|
9180
|
+
}
|
|
9181
|
+
|
|
9182
|
+
function rollup ( options ) {
|
|
9183
|
+
var error = checkOptions ( options );
|
|
9184
|
+
if ( error ) return Promise.reject( error );
|
|
9087
9185
|
|
|
9088
9186
|
var bundle = new Bundle( options );
|
|
9089
9187
|
|