rollup 0.49.3 → 0.50.0

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.49.3
3
- Thu Sep 07 2017 21:02:36 GMT-0400 (EDT) - commit 0d20ed12e069b4fc445faecf221ffe5b40fbf90a
2
+ Rollup.js v0.50.0
3
+ Sat Sep 16 2017 09:48:09 GMT-0400 (EDT) - commit b949eb08169115ff66648838cbc4833379bf9440
4
4
 
5
5
 
6
6
  https://github.com/rollup/rollup
@@ -1938,15 +1938,15 @@ var types = {
1938
1938
  eq: new TokenType("=", {beforeExpr: true, isAssign: true}),
1939
1939
  assign: new TokenType("_=", {beforeExpr: true, isAssign: true}),
1940
1940
  incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}),
1941
- prefix: new TokenType("prefix", {beforeExpr: true, prefix: true, startsExpr: true}),
1941
+ prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}),
1942
1942
  logicalOR: binop("||", 1),
1943
1943
  logicalAND: binop("&&", 2),
1944
1944
  bitwiseOR: binop("|", 3),
1945
1945
  bitwiseXOR: binop("^", 4),
1946
1946
  bitwiseAND: binop("&", 5),
1947
- equality: binop("==/!=", 6),
1948
- relational: binop("</>", 7),
1949
- bitShift: binop("<</>>", 8),
1947
+ equality: binop("==/!=/===/!==", 6),
1948
+ relational: binop("</>/<=/>=", 7),
1949
+ bitShift: binop("<</>>/>>>", 8),
1950
1950
  plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),
1951
1951
  modulo: binop("%", 10),
1952
1952
  star: binop("*", 10),
@@ -2296,7 +2296,7 @@ var pp = Parser.prototype;
2296
2296
 
2297
2297
  // ## Parser utilities
2298
2298
 
2299
- var literal = /^(?:'((?:[^']|\.)*)'|"((?:[^"]|\.)*)"|;)/;
2299
+ var literal = /^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;
2300
2300
  pp.strictDirective = function(start) {
2301
2301
  var this$1 = this;
2302
2302
 
@@ -4010,7 +4010,7 @@ pp$3.parseTemplate = function(ref) {
4010
4010
 
4011
4011
  pp$3.isAsyncProp = function(prop) {
4012
4012
  return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
4013
- (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL) &&
4013
+ (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword) &&
4014
4014
  !lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
4015
4015
  };
4016
4016
 
@@ -4886,7 +4886,7 @@ pp$8.readToken_caret = function() { // '^'
4886
4886
  pp$8.readToken_plus_min = function(code) { // '+-'
4887
4887
  var next = this.input.charCodeAt(this.pos + 1);
4888
4888
  if (next === code) {
4889
- if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 &&
4889
+ if (next == 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) == 62 &&
4890
4890
  (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
4891
4891
  // A `-->` line comment
4892
4892
  this.skipLineComment(3);
@@ -4907,9 +4907,8 @@ pp$8.readToken_lt_gt = function(code) { // '<>'
4907
4907
  if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types.assign, size + 1) }
4908
4908
  return this.finishOp(types.bitShift, size)
4909
4909
  }
4910
- if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 &&
4910
+ if (next == 33 && code == 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) == 45 &&
4911
4911
  this.input.charCodeAt(this.pos + 3) == 45) {
4912
- if (this.inModule) { this.unexpected(); }
4913
4912
  // `<!--`, an XML-style comment that should be interpreted as a line comment
4914
4913
  this.skipLineComment(4);
4915
4914
  this.skipSpace();
@@ -5515,19 +5514,39 @@ function relativeId ( id ) {
5515
5514
  return relative( process.cwd(), id );
5516
5515
  }
5517
5516
 
5518
- const UNKNOWN_VALUE = { toString: () => '[[UNKNOWN]]' };
5517
+ class Variable {
5518
+ constructor ( name ) {
5519
+ this.name = name;
5520
+ }
5519
5521
 
5520
- const UNKNOWN_ASSIGNMENT = {
5521
- type: 'UNKNOWN',
5522
- hasEffectsWhenMutated: () => true,
5523
- };
5522
+ addCall () {}
5523
+
5524
+ getName () {
5525
+ return this.name;
5526
+ }
5527
+
5528
+ hasEffectsWhenCalled () {
5529
+ return true;
5530
+ }
5531
+
5532
+ hasEffectsWhenMutated () {
5533
+ return true;
5534
+ }
5535
+
5536
+ includeVariable () {
5537
+ if ( this.included ) {
5538
+ return false;
5539
+ }
5540
+ this.included = true;
5541
+ return true;
5542
+ }
5543
+ }
5524
5544
 
5525
- class SyntheticNamespaceDeclaration {
5545
+ class NamespaceVariable extends Variable {
5526
5546
  constructor ( module ) {
5547
+ super( module.basename() );
5527
5548
  this.isNamespace = true;
5528
5549
  this.module = module;
5529
- this.name = module.basename();
5530
-
5531
5550
  this.needsNamespaceBlock = false;
5532
5551
 
5533
5552
  this.originals = blank();
@@ -5540,26 +5559,15 @@ class SyntheticNamespaceDeclaration {
5540
5559
  this.name = node.name;
5541
5560
  }
5542
5561
 
5543
- assignExpression () {
5544
- // This should probably not happen, but not defining this might prevent a more meaningful error message
5545
- }
5546
-
5547
- gatherPossibleValues ( values ) {
5548
- values.add( UNKNOWN_ASSIGNMENT );
5549
- }
5550
-
5551
- getName () {
5552
- return this.name;
5553
- }
5562
+ assignExpression () {}
5554
5563
 
5555
- includeDeclaration () {
5556
- if ( this.included ) {
5557
- return false;
5564
+ includeVariable () {
5565
+ const hasBeenIncluded = super.includeVariable();
5566
+ if ( hasBeenIncluded ) {
5567
+ this.needsNamespaceBlock = true;
5568
+ forOwn( this.originals, original => original.includeVariable() );
5558
5569
  }
5559
- this.included = true;
5560
- this.needsNamespaceBlock = true;
5561
- forOwn( this.originals, original => original.includeDeclaration() );
5562
- return true;
5570
+ return hasBeenIncluded;
5563
5571
  }
5564
5572
 
5565
5573
  renderBlock ( es, legacy, indentString ) {
@@ -5579,55 +5587,6 @@ class SyntheticNamespaceDeclaration {
5579
5587
  }
5580
5588
  }
5581
5589
 
5582
- class ExternalDeclaration {
5583
- constructor ( module, name ) {
5584
- this.module = module;
5585
- this.name = name;
5586
- this.safeName = null;
5587
- this.isExternal = true;
5588
- this.isNamespace = name === '*';
5589
- }
5590
-
5591
- addReference ( reference ) {
5592
- reference.declaration = this;
5593
-
5594
- if ( this.name === 'default' || this.name === '*' ) {
5595
- this.module.suggestName( reference.name );
5596
- }
5597
- }
5598
-
5599
- gatherPossibleValues ( values ) {
5600
- values.add( UNKNOWN_ASSIGNMENT );
5601
- }
5602
-
5603
- getName ( es ) {
5604
- if ( this.name === '*' ) {
5605
- return this.module.name;
5606
- }
5607
-
5608
- if ( this.name === 'default' ) {
5609
- return this.module.exportsNamespace || ( !es && this.module.exportsNames ) ?
5610
- `${this.module.name}__default` :
5611
- this.module.name;
5612
- }
5613
-
5614
- return es ? this.safeName : `${this.module.name}.${this.name}`;
5615
- }
5616
-
5617
- includeDeclaration () {
5618
- if ( this.included ) {
5619
- return false;
5620
- }
5621
- this.included = true;
5622
- this.module.used = true;
5623
- return true;
5624
- }
5625
-
5626
- setSafeName ( name ) {
5627
- this.safeName = name;
5628
- }
5629
- }
5630
-
5631
5590
  function extractNames ( param ) {
5632
5591
  const names = [];
5633
5592
  extractors[ param.type ]( names, param );
@@ -5660,13 +5619,216 @@ const extractors = {
5660
5619
  }
5661
5620
  };
5662
5621
 
5663
- class Node$1 {
5664
- assignExpression () {}
5622
+ const UNKNOWN_VALUE = { toString: () => '[[UNKNOWN]]' };
5623
+
5624
+ const UNKNOWN_ASSIGNMENT = {
5625
+ type: 'UNKNOWN',
5626
+ bindCall: () => {},
5627
+ hasEffectsWhenCalled: () => true,
5628
+ hasEffectsWhenMutated: () => true,
5629
+ };
5630
+
5631
+ const UNDEFINED_ASSIGNMENT = {
5632
+ type: 'UNDEFINED',
5633
+ bindCall: () => {},
5634
+ hasEffectsWhenCalled: () => true,
5635
+ hasEffectsWhenMutated: () => true,
5636
+ };
5637
+
5638
+ const UNKNOWN_OBJECT_LITERAL = {
5639
+ type: 'UNKNOWN_OBJECT_LITERAL',
5640
+ bindCall: () => {},
5641
+ hasEffectsWhenCalled: () => true,
5642
+ hasEffectsWhenMutated: () => false,
5643
+ };
5644
+
5645
+ const OPTION_IGNORE_BREAK_STATEMENTS = 'IGNORE_BREAK_STATEMENTS';
5646
+ const OPTION_IGNORE_RETURN_AWAIT_YIELD = 'IGNORE_RETURN_AWAIT_YIELD';
5647
+ const OPTION_IGNORE_SAFE_THIS_MUTATIONS = 'IGNORE_SAFE_THIS_MUTATIONS';
5648
+ const OPTION_CALLED_NODES = 'CALLED_NODES';
5649
+ const OPTION_MUTATED_NODES = 'MUTATED_NODES';
5650
+ const IGNORED_LABELS = 'IGNORED_LABELS';
5651
+
5652
+ /** Wrapper to ensure immutability */
5653
+ class ExecutionPathOptions {
5654
+ /**
5655
+ * @returns {ExecutionPathOptions}
5656
+ */
5657
+ static create () {
5658
+ return new this( {} );
5659
+ }
5660
+
5661
+ constructor ( optionValues ) {
5662
+ this._optionValues = optionValues;
5663
+ }
5664
+
5665
+ /**
5666
+ * Returns a new ExecutionPathOptions instance with the given option set to a new value.
5667
+ * Does not mutate the current instance. Also works in sub-classes.
5668
+ * @param {string} option - The name of an option
5669
+ * @param {*} value - The new value of the option
5670
+ * @returns {ExecutionPathOptions} A new options instance
5671
+ */
5672
+ set ( option, value ) {
5673
+ return new this.constructor( Object.assign( {}, this._optionValues, { [option]: value } ) );
5674
+ }
5675
+
5676
+ /**
5677
+ * @param {string} option - The name of an option
5678
+ * @returns {*} Its value
5679
+ */
5680
+ get ( option ) {
5681
+ return this._optionValues[ option ];
5682
+ }
5665
5683
 
5684
+ /**
5685
+ * @return {boolean}
5686
+ */
5687
+ ignoreBreakStatements () {
5688
+ return this.get( OPTION_IGNORE_BREAK_STATEMENTS );
5689
+ }
5690
+
5691
+ /**
5692
+ * @param {boolean} [value=true]
5693
+ * @return {ExecutionPathOptions}
5694
+ */
5695
+ setIgnoreBreakStatements ( value ) {
5696
+ if ( value === void 0 ) value = true;
5697
+
5698
+ return this.set( OPTION_IGNORE_BREAK_STATEMENTS, value );
5699
+ }
5700
+
5701
+ /**
5702
+ * @param {string} labelName
5703
+ * @return {boolean}
5704
+ */
5705
+ ignoreLabel ( labelName ) {
5706
+ const ignoredLabels = this.get( IGNORED_LABELS );
5707
+ return ignoredLabels && ignoredLabels.has( labelName );
5708
+ }
5709
+
5710
+ /**
5711
+ * @param {string} labelName
5712
+ * @return {ExecutionPathOptions}
5713
+ */
5714
+ setIgnoreLabel ( labelName ) {
5715
+ return this.set( IGNORED_LABELS, new Set( this.get( IGNORED_LABELS ) ).add( labelName ) );
5716
+ }
5717
+
5718
+ /**
5719
+ * @return {ExecutionPathOptions}
5720
+ */
5721
+ setIgnoreNoLabels () {
5722
+ return this.set( IGNORED_LABELS, null );
5723
+ }
5724
+
5725
+ /**
5726
+ * @return {boolean}
5727
+ */
5728
+ ignoreReturnAwaitYield () {
5729
+ return this.get( OPTION_IGNORE_RETURN_AWAIT_YIELD );
5730
+ }
5731
+
5732
+ /**
5733
+ * @param {boolean} [value=true]
5734
+ * @return {ExecutionPathOptions}
5735
+ */
5736
+ setIgnoreReturnAwaitYield ( value ) {
5737
+ if ( value === void 0 ) value = true;
5738
+
5739
+ return this.set( OPTION_IGNORE_RETURN_AWAIT_YIELD, value );
5740
+ }
5741
+
5742
+ /**
5743
+ * @return {boolean}
5744
+ */
5745
+ ignoreSafeThisMutations () {
5746
+ return this.get( OPTION_IGNORE_SAFE_THIS_MUTATIONS );
5747
+ }
5748
+
5749
+ /**
5750
+ * @param {boolean} [value=true]
5751
+ * @return {ExecutionPathOptions}
5752
+ */
5753
+ setIgnoreSafeThisMutations ( value ) {
5754
+ if ( value === void 0 ) value = true;
5755
+
5756
+ return this.set( OPTION_IGNORE_SAFE_THIS_MUTATIONS, value );
5757
+ }
5758
+
5759
+ /**
5760
+ * @param {Node} node
5761
+ * @return {ExecutionPathOptions}
5762
+ */
5763
+ addMutatedNode ( node ) {
5764
+ return this.set( OPTION_MUTATED_NODES, new Set( this.get( OPTION_MUTATED_NODES ) ).add( node ) );
5765
+ }
5766
+
5767
+ /**
5768
+ * @param {Node} node
5769
+ * @return {boolean}
5770
+ */
5771
+ hasNodeBeenMutated ( node ) {
5772
+ const mutatedNodes = this.get( OPTION_MUTATED_NODES );
5773
+ return mutatedNodes && mutatedNodes.has( node );
5774
+ }
5775
+
5776
+ /**
5777
+ * @param {Node} node
5778
+ * @return {ExecutionPathOptions}
5779
+ */
5780
+ addCalledNode ( node ) {
5781
+ return this.set( OPTION_CALLED_NODES, new Set( this.get( OPTION_CALLED_NODES ) ).add( node ) );
5782
+ }
5783
+
5784
+ /**
5785
+ * @param {Node} node
5786
+ * @return {boolean}
5787
+ */
5788
+ hasNodeBeenCalled ( node ) {
5789
+ const calledNodes = this.get( OPTION_CALLED_NODES );
5790
+ return calledNodes && calledNodes.has( node );
5791
+ }
5792
+
5793
+ /**
5794
+ * @param {Node} calledNode
5795
+ * @return {ExecutionPathOptions}
5796
+ */
5797
+ getHasEffectsWhenCalledOptions ( calledNode ) {
5798
+ return this
5799
+ .addCalledNode( calledNode )
5800
+ .setIgnoreReturnAwaitYield()
5801
+ .setIgnoreBreakStatements( false )
5802
+ .setIgnoreNoLabels();
5803
+ }
5804
+ }
5805
+
5806
+ class Node$1 {
5807
+ /**
5808
+ * Called once all nodes have been initialised and the scopes have been populated.
5809
+ * Use this to bind assignments and calls to variables.
5810
+ */
5666
5811
  bind () {
5667
5812
  this.eachChild( child => child.bind() );
5668
5813
  }
5669
5814
 
5815
+ /**
5816
+ * Bind an expression as an assignment to a node.
5817
+ * The default noop implementation is ok as long as hasEffectsWhenAssigned
5818
+ * always returns true for this node. Otherwise it should be overridden.
5819
+ * @param {Node} expression
5820
+ */
5821
+ bindAssignment () {}
5822
+
5823
+ /**
5824
+ * Binds ways a node is called to a node. Current options are:
5825
+ * - withNew: boolean - Did this call use the "new" operator
5826
+ * The default noop implementation is ok as long as hasEffectsWhenCalled
5827
+ * always returns true for this node. Otherwise it should be overridden.
5828
+ * @param callOptions
5829
+ */
5830
+ bindCall () {}
5831
+
5670
5832
  eachChild ( callback ) {
5671
5833
  this.keys.forEach( key => {
5672
5834
  const value = this[ key ];
@@ -5680,34 +5842,65 @@ class Node$1 {
5680
5842
  } );
5681
5843
  }
5682
5844
 
5683
- gatherPossibleValues ( values ) {
5684
- values.add( UNKNOWN_ASSIGNMENT );
5685
- }
5686
-
5687
5845
  getValue () {
5688
5846
  return UNKNOWN_VALUE;
5689
5847
  }
5690
5848
 
5849
+ /**
5850
+ * Determine if this Node would have an effect on the bundle.
5851
+ * This is usually true for already included nodes. Exceptions are e.g. break statements
5852
+ * which only have an effect if their surrounding loop or switch statement is included.
5853
+ * The options pass on information like this about the current execution path.
5854
+ * @param {ExecutionPathOptions} options
5855
+ * @return {boolean}
5856
+ */
5691
5857
  hasEffects ( options ) {
5692
5858
  return this.included || this.someChild( child => child.hasEffects( options ) );
5693
5859
  }
5694
5860
 
5861
+ /**
5862
+ * Special make-shift logic to treat cases where apparently side-effect free statements
5863
+ * are executed for side-effects. The most important case are getters with side-effects.
5864
+ * Once we can reliably handle this case in member expressions, this function should
5865
+ * probably be removed again.
5866
+ * @param {ExecutionPathOptions} options
5867
+ * @return {boolean}
5868
+ */
5695
5869
  hasEffectsAsExpressionStatement () {
5696
5870
  return true;
5697
5871
  }
5698
5872
 
5873
+ /**
5874
+ * @param {ExecutionPathOptions} options
5875
+ * @return {boolean}
5876
+ */
5699
5877
  hasEffectsWhenAssigned () {
5700
5878
  return true;
5701
5879
  }
5702
5880
 
5703
- hasEffectsWhenMutated () {
5881
+ /**
5882
+ * @param {ExecutionPathOptions} options
5883
+ * @return {boolean}
5884
+ */
5885
+ hasEffectsWhenCalled () {
5704
5886
  return true;
5705
5887
  }
5706
5888
 
5707
- includeDeclaration () {
5708
- return this.includeInBundle();
5889
+ /**
5890
+ * @param {ExecutionPathOptions} options
5891
+ * @return {boolean}
5892
+ */
5893
+ hasEffectsWhenMutated () {
5894
+ return true;
5709
5895
  }
5710
5896
 
5897
+ /**
5898
+ * Includes the node in the bundle. Children are usually included if they are
5899
+ * necessary for this node (e.g. a function body) or if they have effects.
5900
+ * Necessary variables should be included as well. Should return true if any
5901
+ * nodes or variables have been added that were missing before.
5902
+ * @return {boolean}
5903
+ */
5711
5904
  includeInBundle () {
5712
5905
  if ( this.isFullyIncluded() ) { return false; }
5713
5906
  let addedNewNodes = false;
@@ -5723,21 +5916,49 @@ class Node$1 {
5723
5916
  return true;
5724
5917
  }
5725
5918
 
5919
+ /**
5920
+ * Alternative version of includeInBundle to override the default behaviour of
5921
+ * declarations to only include nodes for declarators that have an effect. Necessary
5922
+ * for for-loops that do not use a declared loop variable.
5923
+ * @return {boolean}
5924
+ */
5925
+ includeWithAllDeclarations () {
5926
+ return this.includeInBundle();
5927
+ }
5928
+
5929
+ /**
5930
+ * Assign a scope to this node and make sure all children have the right scopes.
5931
+ * Perform any additional initialisation that does not depend on the scope being
5932
+ * populated with variables.
5933
+ * Usually one should not override this function but override initialiseScope,
5934
+ * initialiseNode and/or initialiseChildren instead. BlockScopes have a special
5935
+ * alternative initialisation initialiseAndReplaceScope.
5936
+ * @param {Scope} parentScope
5937
+ */
5726
5938
  initialise ( parentScope ) {
5727
5939
  this.initialiseScope( parentScope );
5728
5940
  this.initialiseNode( parentScope );
5729
5941
  this.initialiseChildren( parentScope );
5730
5942
  }
5731
5943
 
5732
- // Override if e.g. some children need to be initialised with the parent scope
5944
+ /**
5945
+ * Override to change how and with what scopes children are initialised
5946
+ * @param {Scope} parentScope
5947
+ */
5733
5948
  initialiseChildren () {
5734
5949
  this.eachChild( child => child.initialise( this.scope ) );
5735
5950
  }
5736
5951
 
5737
- // Override to perform special initialisation steps after the scope is initialised
5952
+ /**
5953
+ * Override to perform special initialisation steps after the scope is initialised
5954
+ * @param {Scope} parentScope
5955
+ */
5738
5956
  initialiseNode () {}
5739
5957
 
5740
- // Overwrite to create a new scope
5958
+ /**
5959
+ * Override if this scope should receive a different scope than the parent scope.
5960
+ * @param {Scope} parentScope
5961
+ */
5741
5962
  initialiseScope ( parentScope ) {
5742
5963
  this.scope = parentScope;
5743
5964
  }
@@ -5748,6 +5969,11 @@ class Node$1 {
5748
5969
  }
5749
5970
  }
5750
5971
 
5972
+ /**
5973
+ * Shortcut to skip checking this node for effects when all children have already
5974
+ * been included.
5975
+ * @param {Scope} parentScope
5976
+ */
5751
5977
  isFullyIncluded () {
5752
5978
  if ( this._fullyIncluded ) {
5753
5979
  return true;
@@ -5768,8 +5994,15 @@ class Node$1 {
5768
5994
  this.eachChild( child => child.render( code, es ) );
5769
5995
  }
5770
5996
 
5997
+ /**
5998
+ * Start a new execution path to determine if this node has an effect on the bundle and
5999
+ * should therefore be included. Unless they are fully included, included nodes should
6000
+ * always be included again in subsequent visits as the inclusion of additional variables
6001
+ * may require the inclusion of more child nodes in e.g. block statements.
6002
+ * @return {boolean}
6003
+ */
5771
6004
  shouldBeIncluded () {
5772
- return this.hasEffects( {} );
6005
+ return this.hasEffects( ExecutionPathOptions.create() );
5773
6006
  }
5774
6007
 
5775
6008
  someChild ( callback ) {
@@ -5790,45 +6023,91 @@ class Node$1 {
5790
6023
  }
5791
6024
 
5792
6025
  class ArrayPattern extends Node$1 {
5793
- assignExpression () {
5794
- this.eachChild( child => child.assignExpression( UNKNOWN_ASSIGNMENT ) );
6026
+ bindAssignment () {
6027
+ this.eachChild( child => child.bindAssignment( UNKNOWN_ASSIGNMENT ) );
5795
6028
  }
5796
6029
 
5797
6030
  hasEffectsWhenAssigned ( options ) {
5798
6031
  return this.someChild( child => child.hasEffectsWhenAssigned( options ) );
5799
6032
  }
6033
+
6034
+ initialiseAndDeclare ( parentScope, kind ) {
6035
+ this.initialiseScope( parentScope );
6036
+ this.eachChild( child => child.initialiseAndDeclare( parentScope, kind, UNKNOWN_ASSIGNMENT ) );
6037
+ }
5800
6038
  }
5801
6039
 
5802
- class Parameter {
5803
- constructor ( name ) {
5804
- this.name = name;
5805
- this.isParam = true;
5806
- this.assignedExpressions = new Set( [ UNKNOWN_ASSIGNMENT ] );
6040
+ class LocalVariable extends Variable {
6041
+ constructor ( name, declarator, init ) {
6042
+ super( name );
6043
+ this.isReassigned = false;
6044
+ this.exportName = null;
6045
+ this.declarations = new Set( declarator ? [ declarator ] : null );
6046
+ this.assignedExpressions = new Set( init ? [ init ] : null );
6047
+ this.calls = new Set();
6048
+ }
6049
+
6050
+ addDeclaration ( identifier ) {
6051
+ this.declarations.add( identifier );
5807
6052
  }
5808
6053
 
5809
- addReference () {
5810
- // noop?
6054
+ addCall ( callOptions ) {
6055
+ // To prevent infinite loops
6056
+ if ( this.calls.has( callOptions ) ) { return; }
6057
+ this.calls.add( callOptions );
6058
+ Array.from( this.assignedExpressions ).forEach( expression => expression.bindCall( callOptions ) );
5811
6059
  }
5812
6060
 
6061
+ addReference () {}
6062
+
5813
6063
  assignExpression ( expression ) {
5814
6064
  this.assignedExpressions.add( expression );
5815
6065
  this.isReassigned = true;
6066
+ Array.from( this.calls ).forEach( callOptions => expression.bindCall( callOptions ) );
5816
6067
  }
5817
6068
 
5818
- gatherPossibleValues ( values ) {
5819
- values.add( UNKNOWN_ASSIGNMENT ); // TODO populate this at call time
6069
+ getName ( es ) {
6070
+ if ( es ) { return this.name; }
6071
+ if ( !this.isReassigned || !this.exportName ) { return this.name; }
6072
+
6073
+ return `exports.${this.exportName}`;
5820
6074
  }
5821
6075
 
5822
- getName () {
5823
- return this.name;
6076
+ hasEffectsWhenCalled ( options ) {
6077
+ return Array.from( this.assignedExpressions ).some( node =>
6078
+ !options.hasNodeBeenCalled( node )
6079
+ && node.hasEffectsWhenCalled( options.getHasEffectsWhenCalledOptions( node ) )
6080
+ );
5824
6081
  }
5825
6082
 
5826
- includeDeclaration () {
5827
- if ( this.included ) {
5828
- return false;
6083
+ hasEffectsWhenMutated ( options ) {
6084
+ return this.included
6085
+ || Array.from( this.assignedExpressions ).some( node =>
6086
+ !options.hasNodeBeenMutated( node ) &&
6087
+ node.hasEffectsWhenMutated( options.addMutatedNode( node ) )
6088
+ );
6089
+ }
6090
+
6091
+ includeVariable () {
6092
+ const hasBeenIncluded = super.includeVariable();
6093
+ if ( hasBeenIncluded ) {
6094
+ this.declarations.forEach( identifier => identifier.includeInBundle() );
5829
6095
  }
5830
- this.included = true;
5831
- return true;
6096
+ return hasBeenIncluded;
6097
+ }
6098
+
6099
+ toString () {
6100
+ return this.name;
6101
+ }
6102
+ }
6103
+
6104
+ class ParameterVariable extends LocalVariable {
6105
+ constructor ( name, declarator ) {
6106
+ super( name, declarator, UNKNOWN_ASSIGNMENT );
6107
+ }
6108
+
6109
+ getName () {
6110
+ return this.name;
5832
6111
  }
5833
6112
  }
5834
6113
 
@@ -5837,43 +6116,38 @@ class Scope {
5837
6116
  if ( options === void 0 ) options = {};
5838
6117
 
5839
6118
  this.parent = options.parent;
5840
- this.isBlockScope = !!options.isBlockScope;
5841
- this.isLexicalBoundary = !!options.isLexicalBoundary;
5842
6119
  this.isModuleScope = !!options.isModuleScope;
5843
6120
 
5844
6121
  this.children = [];
5845
6122
  if ( this.parent ) { this.parent.children.push( this ); }
5846
6123
 
5847
- this.declarations = blank();
5848
-
5849
- if ( this.isLexicalBoundary && !this.isModuleScope ) {
5850
- this.declarations.arguments = new Parameter( 'arguments' );
5851
- }
6124
+ this.variables = blank();
5852
6125
  }
5853
6126
 
5854
- addDeclaration ( name, declaration, isVar, isParam ) {
5855
- if ( isVar && this.isBlockScope ) {
5856
- this.parent.addDeclaration( name, declaration, isVar, isParam );
6127
+ addDeclaration ( identifier, isHoisted, init ) {
6128
+ const name = identifier.name;
6129
+ if ( this.variables[ name ] ) {
6130
+ const variable = this.variables[ name ];
6131
+ variable.addDeclaration( identifier );
6132
+ init && variable.assignExpression( init );
5857
6133
  } else {
5858
- const existingDeclaration = this.declarations[ name ];
5859
-
5860
- if ( existingDeclaration && existingDeclaration.duplicates ) {
5861
- // TODO warn/throw on duplicates?
5862
- existingDeclaration.duplicates.push( declaration );
5863
- } else {
5864
- this.declarations[ name ] = isParam ? new Parameter( name ) : declaration;
5865
- }
6134
+ this.variables[ name ] = new LocalVariable( identifier.name, identifier, init );
5866
6135
  }
5867
6136
  }
5868
6137
 
6138
+ addParameterDeclaration ( identifier ) {
6139
+ const name = identifier.name;
6140
+ this.variables[ name ] = new ParameterVariable( name, identifier );
6141
+ }
6142
+
5869
6143
  contains ( name ) {
5870
- return !!this.declarations[ name ] ||
6144
+ return !!this.variables[ name ] ||
5871
6145
  ( this.parent ? this.parent.contains( name ) : false );
5872
6146
  }
5873
6147
 
5874
6148
  deshadow ( names ) {
5875
- keys( this.declarations ).forEach( key => {
5876
- const declaration = this.declarations[ key ];
6149
+ keys( this.variables ).forEach( key => {
6150
+ const declaration = this.variables[ key ];
5877
6151
 
5878
6152
  // we can disregard exports.foo etc
5879
6153
  if ( declaration.exportName && declaration.isReassigned ) { return; }
@@ -5893,61 +6167,52 @@ class Scope {
5893
6167
  this.children.forEach( scope => scope.deshadow( names ) );
5894
6168
  }
5895
6169
 
5896
- findDeclaration ( name ) {
5897
- return this.declarations[ name ] ||
5898
- ( this.parent && this.parent.findDeclaration( name ) );
6170
+ findLexicalBoundary () {
6171
+ return this.parent.findLexicalBoundary();
5899
6172
  }
5900
6173
 
5901
- findLexicalBoundary () {
5902
- return this.isLexicalBoundary ? this : this.parent.findLexicalBoundary();
6174
+ findVariable ( name ) {
6175
+ return this.variables[ name ] ||
6176
+ ( this.parent && this.parent.findVariable( name ) );
5903
6177
  }
5904
6178
  }
5905
6179
 
5906
- class Function$1 extends Node$1 {
5907
- bind () {
5908
- if ( this.id ) { this.id.bind(); }
5909
- this.params.forEach( param => param.bind() );
5910
- this.body.bind();
5911
- }
6180
+ class ArrowFunctionExpression extends Node$1 {
6181
+ // Should receive an implementation once we start tracking parameter values
6182
+ bindCall () {}
5912
6183
 
5913
6184
  hasEffects () {
5914
6185
  return this.included;
5915
6186
  }
5916
6187
 
5917
- initialiseChildren () {
5918
- this.params.forEach( param => {
5919
- param.initialise( this.scope );
5920
- extractNames( param ).forEach( name => this.scope.addDeclaration( name, null, false, true ) );
5921
- } );
5922
- this.body.initialiseAndReplaceScope ?
5923
- this.body.initialiseAndReplaceScope( this.scope ) :
5924
- this.body.initialise( this.scope );
6188
+ hasEffectsWhenCalled ( options ) {
6189
+ return this.params.some( param => param.hasEffects( options ) )
6190
+ || this.body.hasEffects( options );
5925
6191
  }
5926
6192
 
5927
- initialiseScope ( parentScope ) {
5928
- this.scope = new Scope( {
5929
- parent: parentScope,
5930
- isBlockScope: false,
5931
- isLexicalBoundary: true
5932
- } );
6193
+ hasEffectsWhenMutated () {
6194
+ return this.included;
6195
+ }
6196
+
6197
+ initialiseChildren () {
6198
+ this.params.forEach( param => param.initialiseAndDeclare( this.scope, 'parameter' ) );
6199
+ if ( this.body.initialiseAndReplaceScope ) {
6200
+ this.body.initialiseAndReplaceScope( new Scope( { parent: this.scope } ) );
6201
+ } else {
6202
+ this.body.initialise( this.scope );
6203
+ }
5933
6204
  }
5934
- }
5935
6205
 
5936
- class ArrowFunctionExpression extends Function$1 {
5937
6206
  initialiseScope ( parentScope ) {
5938
- this.scope = new Scope( {
5939
- parent: parentScope,
5940
- isBlockScope: false,
5941
- isLexicalBoundary: false
5942
- } );
6207
+ this.scope = new Scope( { parent: parentScope } );
5943
6208
  }
5944
6209
  }
5945
6210
 
5946
6211
  // TODO tidy this up a bit (e.g. they can both use node.module.imports)
5947
6212
  function disallowIllegalReassignment ( scope, node ) {
5948
6213
  if ( node.type === 'MemberExpression' && node.object.type === 'Identifier' ) {
5949
- const declaration = scope.findDeclaration( node.object.name );
5950
- if ( declaration.isNamespace ) {
6214
+ const variable = scope.findVariable( node.object.name );
6215
+ if ( variable.isNamespace ) {
5951
6216
  node.module.error({
5952
6217
  code: 'ILLEGAL_NAMESPACE_REASSIGNMENT',
5953
6218
  message: `Illegal reassignment to import '${node.object.name}'`
@@ -5969,7 +6234,7 @@ class AssignmentExpression extends Node$1 {
5969
6234
  bind () {
5970
6235
  super.bind();
5971
6236
  disallowIllegalReassignment( this.scope, this.left );
5972
- this.left.assignExpression( this.right );
6237
+ this.left.bindAssignment( this.right );
5973
6238
  }
5974
6239
 
5975
6240
  hasEffects ( options ) {
@@ -5982,345 +6247,175 @@ class AssignmentExpression extends Node$1 {
5982
6247
  }
5983
6248
 
5984
6249
  class AssignmentPattern extends Node$1 {
5985
- hasEffectsWhenAssigned ( options ) {
5986
- return this.left.hasEffectsWhenAssigned( options );
5987
- }
5988
- }
5989
-
5990
- class AwaitExpression extends Node$1 {
5991
- hasEffects ( options ) {
5992
- return super.hasEffects( options )
5993
- || !options.inNestedFunctionCall;
5994
- }
5995
-
5996
- hasEffectsAsExpressionStatement ( options ) {
5997
- return this.hasEffects( options );
5998
- }
5999
- }
6000
-
6001
- const operators = {
6002
- '==': ( left, right ) => left == right,
6003
- '!=': ( left, right ) => left != right,
6004
- '===': ( left, right ) => left === right,
6005
- '!==': ( left, right ) => left !== right,
6006
- '<': ( left, right ) => left < right,
6007
- '<=': ( left, right ) => left <= right,
6008
- '>': ( left, right ) => left > right,
6009
- '>=': ( left, right ) => left >= right,
6010
- '<<': ( left, right ) => left << right,
6011
- '>>': ( left, right ) => left >> right,
6012
- '>>>': ( left, right ) => left >>> right,
6013
- '+': ( left, right ) => left + right,
6014
- '-': ( left, right ) => left - right,
6015
- '*': ( left, right ) => left * right,
6016
- '/': ( left, right ) => left / right,
6017
- '%': ( left, right ) => left % right,
6018
- '|': ( left, right ) => left | right,
6019
- '^': ( left, right ) => left ^ right,
6020
- '&': ( left, right ) => left & right,
6021
- '**': ( left, right ) => Math.pow( left, right ),
6022
- in: ( left, right ) => left in right,
6023
- instanceof: ( left, right ) => left instanceof right
6024
- };
6025
-
6026
- class BinaryExpression extends Node$1 {
6027
- getValue () {
6028
- const leftValue = this.left.getValue();
6029
- if ( leftValue === UNKNOWN_VALUE ) { return UNKNOWN_VALUE; }
6030
-
6031
- const rightValue = this.right.getValue();
6032
- if ( rightValue === UNKNOWN_VALUE ) { return UNKNOWN_VALUE; }
6033
-
6034
- if ( !operators[ this.operator ] ) { return UNKNOWN_VALUE; }
6035
-
6036
- return operators[ this.operator ]( leftValue, rightValue );
6037
- }
6038
- }
6039
-
6040
- class Statement extends Node$1 {
6041
- render ( code, es ) {
6042
- if ( !this.module.bundle.treeshake || this.included ) {
6043
- super.render( code, es );
6044
- } else {
6045
- code.remove( this.leadingCommentStart || this.start, this.next || this.end );
6046
- }
6047
- }
6048
- }
6049
-
6050
- class BlockStatement extends Statement {
6051
6250
  bind () {
6052
- this.body.forEach( node => node.bind() );
6053
- }
6054
-
6055
- includeInBundle () {
6056
- if ( this.isFullyIncluded() ) { return false; }
6057
- let addedNewNodes = false;
6058
- this.body.forEach( node => {
6059
- if ( node.shouldBeIncluded() ) {
6060
- if ( node.includeInBundle() ) {
6061
- addedNewNodes = true;
6062
- }
6063
- }
6064
- } );
6065
- if ( !this.included || addedNewNodes ) {
6066
- this.included = true;
6067
- return true;
6068
- }
6069
- return false;
6070
- }
6071
-
6072
- initialiseAndReplaceScope ( scope ) {
6073
- this.scope = scope;
6074
- this.initialiseNode();
6075
- this.initialiseChildren( scope );
6251
+ super.bind();
6252
+ this.left.bindAssignment( this.right );
6076
6253
  }
6077
6254
 
6078
- initialiseChildren () {
6079
- let lastNode;
6080
- for ( const node of this.body ) {
6081
- node.initialise( this.scope );
6082
-
6083
- if ( lastNode ) { lastNode.next = node.start; }
6084
- lastNode = node;
6085
- }
6255
+ bindAssignment ( expression ) {
6256
+ this.left.bindAssignment( expression );
6086
6257
  }
6087
6258
 
6088
- initialiseScope ( parentScope ) {
6089
- this.scope = new Scope( {
6090
- parent: parentScope,
6091
- isBlockScope: true,
6092
- isLexicalBoundary: false
6093
- } );
6259
+ hasEffectsWhenAssigned ( options ) {
6260
+ return this.left.hasEffectsWhenAssigned( options );
6094
6261
  }
6095
6262
 
6096
- render ( code, es ) {
6097
- if ( this.body.length ) {
6098
- for ( const node of this.body ) {
6099
- node.render( code, es );
6100
- }
6101
- } else {
6102
- Statement.prototype.render.call( this, code, es );
6103
- }
6263
+ initialiseAndDeclare ( parentScope, kind, init ) {
6264
+ this.initialiseScope( parentScope );
6265
+ this.right.initialise( parentScope );
6266
+ this.left.initialiseAndDeclare( parentScope, kind, init );
6104
6267
  }
6105
6268
  }
6106
6269
 
6107
- class BreakStatement extends Node$1 {
6270
+ class AwaitExpression extends Node$1 {
6108
6271
  hasEffects ( options ) {
6109
6272
  return super.hasEffects( options )
6110
- || !options.inNestedBreakableStatement;
6111
- }
6112
-
6113
- shouldBeIncluded () {
6114
- return true;
6115
- }
6116
- }
6117
-
6118
- function isReference (node, parent) {
6119
- if (node.type === 'MemberExpression') {
6120
- return !node.computed && isReference(node.object, node);
6121
- }
6122
-
6123
- if (node.type === 'Identifier') {
6124
- // the only time we could have an identifier node without a parent is
6125
- // if it's the entire body of a function without a block statement –
6126
- // i.e. an arrow function expression like `a => a`
6127
- if (!parent) return true;
6128
-
6129
- // TODO is this right?
6130
- if (parent.type === 'MemberExpression' || parent.type === 'MethodDefinition') {
6131
- return parent.computed || node === parent.object;
6132
- }
6133
-
6134
- // disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
6135
- if (parent.type === 'Property') return parent.computed || node === parent.value;
6136
-
6137
- // disregard the `bar` in `class Foo { bar () {...} }`
6138
- if (parent.type === 'MethodDefinition') return false;
6139
-
6140
- // disregard the `bar` in `export { foo as bar }`
6141
- if (parent.type === 'ExportSpecifier' && node !== parent.local) return false;
6142
-
6143
- return true;
6144
- }
6145
-
6146
- return false;
6147
- }
6148
-
6149
- function flatten ( node ) {
6150
- const parts = [];
6151
- while ( node.type === 'MemberExpression' ) {
6152
- if ( node.computed ) { return null; }
6153
- parts.unshift( node.property.name );
6154
-
6155
- node = node.object;
6273
+ || !options.ignoreReturnAwaitYield();
6156
6274
  }
6157
6275
 
6158
- if ( node.type !== 'Identifier' ) { return null; }
6159
-
6160
- const name = node.name;
6161
- parts.unshift( name );
6162
-
6163
- return { name, keypath: parts.join( '.' ) };
6164
- }
6165
-
6166
- const pureFunctions = {};
6167
-
6168
- const arrayTypes = 'Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split( ' ' );
6169
- const simdTypes = 'Int8x16 Int16x8 Int32x4 Float32x4 Float64x2'.split( ' ' );
6170
- const simdMethods = 'abs add and bool check div equal extractLane fromFloat32x4 fromFloat32x4Bits fromFloat64x2 fromFloat64x2Bits fromInt16x8Bits fromInt32x4 fromInt32x4Bits fromInt8x16Bits greaterThan greaterThanOrEqual lessThan lessThanOrEqual load max maxNum min minNum mul neg not notEqual or reciprocalApproximation reciprocalSqrtApproximation replaceLane select selectBits shiftLeftByScalar shiftRightArithmeticByScalar shiftRightLogicalByScalar shuffle splat sqrt store sub swizzle xor'.split( ' ' );
6171
- const allSimdMethods = [];
6172
- simdTypes.forEach( t => {
6173
- simdMethods.forEach( m => {
6174
- allSimdMethods.push( `SIMD.${t}.${m}` );
6175
- });
6176
- });
6177
-
6178
- [
6179
- 'Array.isArray',
6180
- 'Error', 'EvalError', 'InternalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError',
6181
- 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape', 'unescape',
6182
- 'Object', 'Object.create', 'Object.getNotifier', 'Object.getOwn', 'Object.getOwnPropertyDescriptor', 'Object.getOwnPropertyNames', 'Object.getOwnPropertySymbols', 'Object.getPrototypeOf', 'Object.is', 'Object.isExtensible', 'Object.isFrozen', 'Object.isSealed', 'Object.keys',
6183
- 'Function', 'Boolean',
6184
- 'Number', 'Number.isFinite', 'Number.isInteger', 'Number.isNaN', 'Number.isSafeInteger', 'Number.parseFloat', 'Number.parseInt',
6185
- 'Symbol', 'Symbol.for', 'Symbol.keyFor',
6186
- 'Math.abs', 'Math.acos', 'Math.acosh', 'Math.asin', 'Math.asinh', 'Math.atan', 'Math.atan2', 'Math.atanh', 'Math.cbrt', 'Math.ceil', 'Math.clz32', 'Math.cos', 'Math.cosh', 'Math.exp', 'Math.expm1', 'Math.floor', 'Math.fround', 'Math.hypot', 'Math.imul', 'Math.log', 'Math.log10', 'Math.log1p', 'Math.log2', 'Math.max', 'Math.min', 'Math.pow', 'Math.random', 'Math.round', 'Math.sign', 'Math.sin', 'Math.sinh', 'Math.sqrt', 'Math.tan', 'Math.tanh', 'Math.trunc',
6187
- 'Date', 'Date.UTC', 'Date.now', 'Date.parse',
6188
- 'String', 'String.fromCharCode', 'String.fromCodePoint', 'String.raw',
6189
- 'RegExp',
6190
- 'Map', 'Set', 'WeakMap', 'WeakSet',
6191
- 'ArrayBuffer', 'ArrayBuffer.isView',
6192
- 'DataView',
6193
- 'JSON.parse', 'JSON.stringify',
6194
- 'Promise.all', 'Promise.race', 'Promise.resolve',
6195
- 'Intl.Collator', 'Intl.Collator.supportedLocalesOf', 'Intl.DateTimeFormat', 'Intl.DateTimeFormat.supportedLocalesOf', 'Intl.NumberFormat', 'Intl.NumberFormat.supportedLocalesOf'
6196
-
6197
- // TODO properties of e.g. window...
6198
- ].concat(
6199
- arrayTypes,
6200
- arrayTypes.map( t => `${t}.from` ),
6201
- arrayTypes.map( t => `${t}.of` ),
6202
- simdTypes.map( t => `SIMD.${t}` ),
6203
- allSimdMethods
6204
- ).forEach( name => pureFunctions[ name ] = true );
6205
-
6206
- const currentlyCalling = new Set();
6207
-
6208
- function isES5Function ( node ) {
6209
- return node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration';
6276
+ hasEffectsAsExpressionStatement ( options ) {
6277
+ return this.hasEffects( options );
6278
+ }
6210
6279
  }
6211
6280
 
6212
- function hasEffectsNew ( node ) {
6213
- let inner = node;
6214
-
6215
- if ( inner.type === 'ExpressionStatement' ) {
6216
- inner = inner.expression;
6281
+ const operators = {
6282
+ '==': ( left, right ) => left == right,
6283
+ '!=': ( left, right ) => left != right,
6284
+ '===': ( left, right ) => left === right,
6285
+ '!==': ( left, right ) => left !== right,
6286
+ '<': ( left, right ) => left < right,
6287
+ '<=': ( left, right ) => left <= right,
6288
+ '>': ( left, right ) => left > right,
6289
+ '>=': ( left, right ) => left >= right,
6290
+ '<<': ( left, right ) => left << right,
6291
+ '>>': ( left, right ) => left >> right,
6292
+ '>>>': ( left, right ) => left >>> right,
6293
+ '+': ( left, right ) => left + right,
6294
+ '-': ( left, right ) => left - right,
6295
+ '*': ( left, right ) => left * right,
6296
+ '/': ( left, right ) => left / right,
6297
+ '%': ( left, right ) => left % right,
6298
+ '|': ( left, right ) => left | right,
6299
+ '^': ( left, right ) => left ^ right,
6300
+ '&': ( left, right ) => left & right,
6301
+ '**': ( left, right ) => Math.pow( left, right ),
6302
+ in: ( left, right ) => left in right,
6303
+ instanceof: ( left, right ) => left instanceof right
6304
+ };
6217
6305
 
6218
- if ( inner.type === 'AssignmentExpression' ) {
6219
- if ( inner.right.hasEffects( { inNestedFunctionCall: true } ) ) {
6220
- return true;
6306
+ class BinaryExpression extends Node$1 {
6307
+ getValue () {
6308
+ const leftValue = this.left.getValue();
6309
+ if ( leftValue === UNKNOWN_VALUE ) { return UNKNOWN_VALUE; }
6221
6310
 
6222
- } else {
6223
- inner = inner.left;
6311
+ const rightValue = this.right.getValue();
6312
+ if ( rightValue === UNKNOWN_VALUE ) { return UNKNOWN_VALUE; }
6224
6313
 
6225
- if ( inner.type === 'MemberExpression' ) {
6226
- if ( inner.computed && inner.property.hasEffects( { inNestedFunctionCall: true } ) ) {
6227
- return true;
6314
+ if ( !operators[ this.operator ] ) { return UNKNOWN_VALUE; }
6228
6315
 
6229
- } else {
6230
- inner = inner.object;
6316
+ return operators[ this.operator ]( leftValue, rightValue );
6317
+ }
6318
+ }
6231
6319
 
6232
- if ( inner.type === 'ThisExpression' ) {
6233
- return false;
6234
- }
6235
- }
6236
- }
6237
- }
6320
+ class Statement extends Node$1 {
6321
+ render ( code, es ) {
6322
+ if ( !this.module.bundle.treeshake || this.included ) {
6323
+ super.render( code, es );
6324
+ } else {
6325
+ code.remove( this.leadingCommentStart || this.start, this.next || this.end );
6238
6326
  }
6239
6327
  }
6240
-
6241
- return node.hasEffects( { inNestedFunctionCall: true } );
6242
6328
  }
6243
6329
 
6244
- function fnHasEffects ( fn, isNew ) {
6245
- if ( currentlyCalling.has( fn ) ) { return false; } // prevent infinite loops... TODO there must be a better way
6246
- currentlyCalling.add( fn );
6247
-
6248
- // handle body-less arrow functions
6249
- const body = fn.body.type === 'BlockStatement' ? fn.body.body : [ fn.body ];
6250
-
6251
- for ( const node of body ) {
6252
- if ( isNew ? hasEffectsNew( node ) : node.hasEffects( { inNestedFunctionCall: true } ) ) {
6253
- currentlyCalling.delete( fn );
6254
- return true;
6330
+ class BlockScope extends Scope {
6331
+ addDeclaration ( identifier, isHoisted, init ) {
6332
+ if ( isHoisted ) {
6333
+ this.parent.addDeclaration( identifier, isHoisted, init );
6334
+ } else {
6335
+ super.addDeclaration( identifier, false, init );
6255
6336
  }
6256
6337
  }
6257
-
6258
- currentlyCalling.delete( fn );
6259
- return false;
6260
6338
  }
6261
6339
 
6262
- function callHasEffects ( scope, callee, isNew ) {
6263
- const values = new Set( [ callee ] );
6264
-
6265
- for ( const node of values ) {
6266
- if ( node.type === 'UNKNOWN' ) { return true; } // err on side of caution
6340
+ class BlockStatement extends Statement {
6341
+ bind () {
6342
+ this.body.forEach( node => node.bind() );
6343
+ }
6267
6344
 
6268
- if ( /Function/.test( node.type ) ) {
6269
- if ( fnHasEffects( node, isNew && isES5Function( node ) ) ) { return true; }
6270
- }
6345
+ hasEffects ( options ) {
6346
+ // Empty block statements do not have effects even though they may be included as e.g. function body
6347
+ return this.body.some( child => child.hasEffects( options ) );
6348
+ }
6271
6349
 
6272
- else if ( /Class/.test( node.type ) ) {
6273
- // TODO find constructor (may belong to a superclass)
6350
+ includeInBundle () {
6351
+ if ( this.isFullyIncluded() ) { return false; }
6352
+ let addedNewNodes = false;
6353
+ this.body.forEach( node => {
6354
+ if ( node.shouldBeIncluded() ) {
6355
+ if ( node.includeInBundle() ) {
6356
+ addedNewNodes = true;
6357
+ }
6358
+ }
6359
+ } );
6360
+ if ( !this.included || addedNewNodes ) {
6361
+ this.included = true;
6274
6362
  return true;
6275
6363
  }
6364
+ return false;
6365
+ }
6276
6366
 
6277
- else if ( isReference( node ) ) {
6278
- const flattened = flatten( node );
6279
- const declaration = scope.findDeclaration( flattened.name );
6280
-
6281
- if ( declaration.isGlobal ) {
6282
- if ( !pureFunctions[ flattened.keypath ] ) { return true; }
6283
- }
6367
+ initialiseAndReplaceScope ( scope ) {
6368
+ this.scope = scope;
6369
+ this.initialiseNode();
6370
+ this.initialiseChildren( scope );
6371
+ }
6284
6372
 
6285
- else if ( declaration.isExternal ) {
6286
- return true; // TODO make this configurable? e.g. `path.[whatever]`
6287
- }
6373
+ initialiseChildren () {
6374
+ let lastNode;
6375
+ for ( const node of this.body ) {
6376
+ node.initialise( this.scope );
6288
6377
 
6289
- else {
6290
- if ( node.declaration ) {
6291
- node.declaration.gatherPossibleValues( values );
6292
- } else {
6293
- return true;
6294
- }
6295
- }
6378
+ if ( lastNode ) { lastNode.next = node.start; }
6379
+ lastNode = node;
6296
6380
  }
6381
+ }
6297
6382
 
6298
- else if ( node.gatherPossibleValues ) {
6299
- node.gatherPossibleValues( values );
6300
- }
6383
+ initialiseScope ( parentScope ) {
6384
+ this.scope = new BlockScope( { parent: parentScope } );
6385
+ }
6301
6386
 
6302
- else {
6303
- // probably an error in the user's code — err on side of caution
6304
- return true;
6387
+ render ( code, es ) {
6388
+ if ( this.body.length ) {
6389
+ for ( const node of this.body ) {
6390
+ node.render( code, es );
6391
+ }
6392
+ } else {
6393
+ Statement.prototype.render.call( this, code, es );
6305
6394
  }
6306
6395
  }
6396
+ }
6307
6397
 
6308
- return false;
6398
+ class BreakStatement extends Node$1 {
6399
+ hasEffects ( options ) {
6400
+ return super.hasEffects( options )
6401
+ || !options.ignoreBreakStatements()
6402
+ || (this.label && !options.ignoreLabel( this.label.name ));
6403
+ }
6309
6404
  }
6310
6405
 
6311
6406
  class CallExpression extends Node$1 {
6312
6407
  bind () {
6313
6408
  if ( this.callee.type === 'Identifier' ) {
6314
- const declaration = this.scope.findDeclaration( this.callee.name );
6409
+ const variable = this.scope.findVariable( this.callee.name );
6315
6410
 
6316
- if ( declaration.isNamespace ) {
6411
+ if ( variable.isNamespace ) {
6317
6412
  this.module.error( {
6318
6413
  code: 'CANNOT_CALL_NAMESPACE',
6319
6414
  message: `Cannot call a namespace ('${this.callee.name}')`
6320
6415
  }, this.start );
6321
6416
  }
6322
6417
 
6323
- if ( this.callee.name === 'eval' && declaration.isGlobal ) {
6418
+ if ( this.callee.name === 'eval' && variable.isGlobal ) {
6324
6419
  this.module.warn( {
6325
6420
  code: 'EVAL',
6326
6421
  message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`,
@@ -6330,12 +6425,13 @@ class CallExpression extends Node$1 {
6330
6425
  }
6331
6426
 
6332
6427
  super.bind();
6428
+ this.callee.bindCall( { withNew: false } );
6333
6429
  }
6334
6430
 
6335
6431
  hasEffects ( options ) {
6336
6432
  return this.included
6337
6433
  || this.arguments.some( child => child.hasEffects( options ) )
6338
- || callHasEffects( this.scope, this.callee, false );
6434
+ || this.callee.hasEffectsWhenCalled( options.getHasEffectsWhenCalledOptions( this.callee ) );
6339
6435
  }
6340
6436
 
6341
6437
  hasEffectsAsExpressionStatement ( options ) {
@@ -6345,27 +6441,49 @@ class CallExpression extends Node$1 {
6345
6441
 
6346
6442
  class CatchClause extends Node$1 {
6347
6443
  initialiseChildren () {
6348
- if ( this.param ) {
6349
- this.param.initialise( this.scope );
6350
- extractNames( this.param ).forEach( name => this.scope.addDeclaration( name, null, false, true ) );
6351
- }
6444
+ this.param && this.param.initialiseAndDeclare( this.scope, 'parameter' );
6352
6445
  this.body.initialiseAndReplaceScope( this.scope );
6353
6446
  }
6354
6447
 
6355
6448
  initialiseScope ( parentScope ) {
6356
- this.scope = new Scope( {
6357
- parent: parentScope,
6358
- isBlockScope: true,
6359
- isLexicalBoundary: false
6360
- } );
6449
+ this.scope = new BlockScope( { parent: parentScope } );
6361
6450
  }
6362
6451
  }
6363
6452
 
6364
- class Class extends Node$1 {
6365
- addReference () {}
6453
+ class ClassBody extends Node$1 {
6454
+ bindCall ( callOptions ) {
6455
+ if ( this.classConstructor ) {
6456
+ this.classConstructor.bindCall( callOptions );
6457
+ }
6458
+ }
6366
6459
 
6367
- getName () {
6368
- return this.name;
6460
+ hasEffectsWhenCalled ( options ) {
6461
+ if ( this.classConstructor ) {
6462
+ return this.classConstructor.hasEffectsWhenCalled( options );
6463
+ }
6464
+ return false;
6465
+ }
6466
+
6467
+ initialiseNode () {
6468
+ this.classConstructor = this.body.find( method => method.kind === 'constructor' );
6469
+ }
6470
+ }
6471
+
6472
+ class ClassNode extends Node$1 {
6473
+ bindCall ( callOptions ) {
6474
+ if ( this.superClass ) {
6475
+ this.superClass.bindCall( callOptions );
6476
+ }
6477
+ this.body.bindCall( callOptions );
6478
+ }
6479
+
6480
+ hasEffectsAsExpressionStatement ( options ) {
6481
+ return this.hasEffects( options );
6482
+ }
6483
+
6484
+ hasEffectsWhenCalled ( options ) {
6485
+ return this.body.hasEffectsWhenCalled( options )
6486
+ || ( this.superClass && this.superClass.hasEffectsWhenCalled( options ) );
6369
6487
  }
6370
6488
 
6371
6489
  initialiseChildren () {
@@ -6376,28 +6494,14 @@ class Class extends Node$1 {
6376
6494
  }
6377
6495
 
6378
6496
  initialiseScope ( parentScope ) {
6379
- this.scope = new Scope( {
6380
- parent: parentScope,
6381
- isBlockScope: true
6382
- } );
6497
+ this.scope = new Scope( { parent: parentScope } );
6383
6498
  }
6384
6499
  }
6385
6500
 
6386
- class ClassDeclaration extends Class {
6387
- gatherPossibleValues ( values ) {
6388
- values.add( this );
6389
- }
6390
-
6391
- hasEffects () {
6392
- return this.included;
6393
- }
6394
-
6501
+ class ClassDeclaration extends ClassNode {
6395
6502
  initialiseChildren ( parentScope ) {
6396
- if ( this.id ) {
6397
- this.name = this.id.name;
6398
- parentScope.addDeclaration( this.name, this, false, false );
6399
- this.id.initialise( parentScope );
6400
- }
6503
+ // Class declarations are like let declarations: Not hoisted, can be reassigned, cannot be redeclared
6504
+ this.id && this.id.initialiseAndDeclare( parentScope, 'class', this );
6401
6505
  super.initialiseChildren( parentScope );
6402
6506
  }
6403
6507
 
@@ -6410,14 +6514,10 @@ class ClassDeclaration extends Class {
6410
6514
  }
6411
6515
  }
6412
6516
 
6413
- class ClassExpression extends Class {
6414
- initialiseChildren (parentScope) {
6415
- if ( this.id ) {
6416
- this.name = this.id.name;
6417
- this.scope.addDeclaration( this.name, this, false, false );
6418
- this.id.initialise( this.scope );
6419
- }
6420
- super.initialiseChildren(parentScope);
6517
+ class ClassExpression extends ClassNode {
6518
+ initialiseChildren ( parentScope ) {
6519
+ this.id && this.id.initialiseAndDeclare( this.scope, 'class', this );
6520
+ super.initialiseChildren( parentScope );
6421
6521
  }
6422
6522
  }
6423
6523
 
@@ -6440,16 +6540,6 @@ class ConditionalExpression extends Node$1 {
6440
6540
  }
6441
6541
  }
6442
6542
 
6443
- gatherPossibleValues ( values ) {
6444
- const testValue = this.test.getValue();
6445
-
6446
- if ( testValue === UNKNOWN_VALUE ) {
6447
- values.add( this.consequent ).add( this.alternate );
6448
- } else {
6449
- values.add( testValue ? this.consequent : this.alternate );
6450
- }
6451
- }
6452
-
6453
6543
  getValue () {
6454
6544
  const testValue = this.test.getValue();
6455
6545
  if ( testValue === UNKNOWN_VALUE ) { return UNKNOWN_VALUE; }
@@ -6493,7 +6583,7 @@ class DoWhileStatement extends Statement {
6493
6583
  return (
6494
6584
  this.included
6495
6585
  || this.test.hasEffects( options )
6496
- || this.body.hasEffects( Object.assign( {}, options, { inNestedBreakableStatement: true } ) )
6586
+ || this.body.hasEffects( options.setIgnoreBreakStatements() )
6497
6587
  );
6498
6588
  }
6499
6589
  }
@@ -6519,6 +6609,10 @@ class ExportAllDeclaration extends Node$1 {
6519
6609
  const functionOrClassDeclaration = /^(?:Function|Class)Declaration/;
6520
6610
 
6521
6611
  class ExportDefaultDeclaration extends Node$1 {
6612
+ addCall ( options ) {
6613
+ this.declaration.bindCall( options );
6614
+ }
6615
+
6522
6616
  addReference ( reference ) {
6523
6617
  this.name = reference.name;
6524
6618
  if ( this.original ) { this.original.addReference( reference ); }
@@ -6526,15 +6620,11 @@ class ExportDefaultDeclaration extends Node$1 {
6526
6620
 
6527
6621
  bind () {
6528
6622
  const name = ( this.declaration.id && this.declaration.id.name ) || this.declaration.name;
6529
- if ( name ) { this.original = this.scope.findDeclaration( name ); }
6623
+ if ( name ) { this.original = this.scope.findVariable( name ); }
6530
6624
 
6531
6625
  this.declaration.bind();
6532
6626
  }
6533
6627
 
6534
- gatherPossibleValues ( values ) {
6535
- this.declaration.gatherPossibleValues( values );
6536
- }
6537
-
6538
6628
  getName ( es ) {
6539
6629
  if ( this.original && !this.original.isReassigned ) {
6540
6630
  return this.original.getName( es );
@@ -6543,7 +6633,11 @@ class ExportDefaultDeclaration extends Node$1 {
6543
6633
  return this.name;
6544
6634
  }
6545
6635
 
6546
- includeDeclaration () {
6636
+ hasEffectsWhenCalled ( options ) {
6637
+ return this.declaration.hasEffectsWhenCalled( options );
6638
+ }
6639
+
6640
+ includeVariable () {
6547
6641
  if ( this.included ) {
6548
6642
  return false;
6549
6643
  }
@@ -6564,7 +6658,7 @@ class ExportDefaultDeclaration extends Node$1 {
6564
6658
  this.isDefault = true;
6565
6659
 
6566
6660
  this.name = ( this.declaration.id && this.declaration.id.name ) || this.declaration.name || this.module.basename();
6567
- this.scope.declarations.default = this;
6661
+ this.scope.variables.default = this;
6568
6662
  }
6569
6663
 
6570
6664
  // TODO this is total chaos, tidy it up
@@ -6612,7 +6706,7 @@ class ExportDefaultDeclaration extends Node$1 {
6612
6706
  if ( functionOrClassDeclaration.test( this.declaration.type ) ) {
6613
6707
  code.remove( this.leadingCommentStart || this.start, this.next || this.end );
6614
6708
  } else {
6615
- const hasEffects = this.declaration.hasEffects( {} );
6709
+ const hasEffects = this.declaration.hasEffects( ExecutionPathOptions.create() );
6616
6710
  code.remove( this.start, hasEffects ? declaration_start : this.next || this.end );
6617
6711
  }
6618
6712
  } else if ( name === this.declaration.name ) {
@@ -6627,11 +6721,12 @@ class ExportDefaultDeclaration extends Node$1 {
6627
6721
 
6628
6722
  class ExportNamedDeclaration extends Node$1 {
6629
6723
  bind () {
6724
+ // Do not bind specifiers
6630
6725
  if ( this.declaration ) { this.declaration.bind(); }
6631
6726
  }
6632
6727
 
6633
- hasEffects () {
6634
- return this.included || (this.declaration && this.declaration.hasEffects());
6728
+ hasEffects ( options ) {
6729
+ return this.included || (this.declaration && this.declaration.hasEffects( options ));
6635
6730
  }
6636
6731
 
6637
6732
  initialiseNode () {
@@ -6679,7 +6774,7 @@ class ForStatement extends Statement {
6679
6774
  || this.init && this.init.hasEffects( options )
6680
6775
  || this.test && this.test.hasEffects( options )
6681
6776
  || this.update && this.update.hasEffects( options )
6682
- || this.body.hasEffects( Object.assign( {}, options, { inNestedBreakableStatement: true } ) )
6777
+ || this.body.hasEffects( options.setIgnoreBreakStatements() )
6683
6778
  );
6684
6779
  }
6685
6780
 
@@ -6697,11 +6792,7 @@ class ForStatement extends Statement {
6697
6792
  }
6698
6793
 
6699
6794
  initialiseScope ( parentScope ) {
6700
- this.scope = new Scope( {
6701
- parent: parentScope,
6702
- isBlockScope: true,
6703
- isLexicalBoundary: false
6704
- } );
6795
+ this.scope = new BlockScope( { parent: parentScope } );
6705
6796
  }
6706
6797
  }
6707
6798
 
@@ -6709,9 +6800,9 @@ class ForInStatement extends Statement {
6709
6800
  hasEffects ( options ) {
6710
6801
  return (
6711
6802
  this.included
6712
- || this.left && this.left.hasEffects( options )
6803
+ || this.left && (this.left.hasEffects( options ) || this.left.hasEffectsWhenAssigned( options ))
6713
6804
  || this.right && this.right.hasEffects( options )
6714
- || this.body.hasEffects( Object.assign( {}, options, { inNestedBreakableStatement: true } ) )
6805
+ || this.body.hasEffects( options.setIgnoreBreakStatements() )
6715
6806
  );
6716
6807
  }
6717
6808
 
@@ -6725,39 +6816,35 @@ class ForInStatement extends Statement {
6725
6816
 
6726
6817
  includeInBundle () {
6727
6818
  let addedNewNodes = super.includeInBundle();
6728
- if ( this.left.includeDeclaration() ) {
6819
+ if ( this.left.includeWithAllDeclarations() ) {
6729
6820
  addedNewNodes = true;
6730
6821
  }
6731
6822
  return addedNewNodes;
6732
6823
  }
6733
6824
 
6734
6825
  initialiseScope ( parentScope ) {
6735
- this.scope = new Scope( {
6736
- parent: parentScope,
6737
- isBlockScope: true,
6738
- isLexicalBoundary: false
6739
- } );
6826
+ this.scope = new BlockScope( { parent: parentScope } );
6740
6827
  }
6741
6828
  }
6742
6829
 
6743
6830
  class ForOfStatement extends Statement {
6744
6831
  bind () {
6745
6832
  super.bind();
6746
- this.left.assignExpression( UNKNOWN_ASSIGNMENT );
6833
+ this.left.bindAssignment( UNKNOWN_ASSIGNMENT );
6747
6834
  }
6748
6835
 
6749
6836
  hasEffects ( options ) {
6750
6837
  return (
6751
6838
  this.included
6752
- || this.left && this.left.hasEffects( options )
6839
+ || this.left && (this.left.hasEffects( options ) || this.left.hasEffectsWhenAssigned( options ))
6753
6840
  || this.right && this.right.hasEffects( options )
6754
- || this.body.hasEffects( Object.assign( {}, options, { inNestedBreakableStatement: true } ) )
6841
+ || this.body.hasEffects( options.setIgnoreBreakStatements() )
6755
6842
  );
6756
6843
  }
6757
6844
 
6758
6845
  includeInBundle () {
6759
6846
  let addedNewNodes = super.includeInBundle();
6760
- if ( this.left.includeDeclaration() ) {
6847
+ if ( this.left.includeWithAllDeclarations() ) {
6761
6848
  addedNewNodes = true;
6762
6849
  }
6763
6850
  return addedNewNodes;
@@ -6772,45 +6859,65 @@ class ForOfStatement extends Statement {
6772
6859
  }
6773
6860
 
6774
6861
  initialiseScope ( parentScope ) {
6775
- this.scope = new Scope( {
6776
- parent: parentScope,
6777
- isBlockScope: true,
6778
- isLexicalBoundary: false
6779
- } );
6862
+ this.scope = new BlockScope( { parent: parentScope } );
6780
6863
  }
6781
6864
  }
6782
6865
 
6783
- class FunctionDeclaration extends Function$1 {
6784
- addReference () {}
6866
+ class FunctionScope extends Scope {
6867
+ constructor ( options ) {
6868
+ if ( options === void 0 ) options = {};
6785
6869
 
6786
- assignExpression ( expression ) {
6787
- this.assignedExpressions.add( expression );
6788
- this.isReassigned = true;
6870
+ super( options );
6871
+ this.variables.arguments = new ParameterVariable( 'arguments' );
6872
+ this.variables.this = new LocalVariable( 'this', null, null );
6789
6873
  }
6790
6874
 
6791
- gatherPossibleValues ( values ) {
6792
- values.add( this );
6875
+ findLexicalBoundary () {
6876
+ return this;
6793
6877
  }
6878
+ }
6794
6879
 
6795
- getName () {
6796
- return this.name;
6797
- }
6880
+ class FunctionNode extends Node$1 {
6881
+ bindCall ( ref ) {
6882
+ var withNew = ref.withNew;
6798
6883
 
6799
- initialiseChildren ( parentScope ) {
6800
- if ( this.id ) {
6801
- this.name = this.id.name; // may be overridden by bundle.deconflict
6802
- parentScope.addDeclaration( this.name, this, false, false );
6803
- this.id.initialise( parentScope );
6884
+ const thisVariable = this.scope.findVariable( 'this' );
6885
+
6886
+ if ( withNew ) {
6887
+ thisVariable.assignExpression( UNKNOWN_OBJECT_LITERAL );
6888
+ } else {
6889
+ thisVariable.assignExpression( UNKNOWN_ASSIGNMENT );
6804
6890
  }
6805
- super.initialiseChildren( parentScope );
6891
+ }
6892
+
6893
+ hasEffects ( options ) {
6894
+ return this.included || (this.id && this.id.hasEffects( options ));
6895
+ }
6896
+
6897
+ hasEffectsAsExpressionStatement ( options ) {
6898
+ return this.hasEffects( options );
6899
+ }
6900
+
6901
+ hasEffectsWhenCalled ( options ) {
6902
+ const innerOptions = options.setIgnoreSafeThisMutations();
6903
+ return this.params.some( param => param.hasEffects( innerOptions ) )
6904
+ || this.body.hasEffects( innerOptions );
6806
6905
  }
6807
6906
 
6808
6907
  hasEffectsWhenMutated () {
6809
6908
  return this.included;
6810
6909
  }
6811
6910
 
6812
- initialiseNode () {
6813
- this.assignedExpressions = new Set( [ this ] );
6911
+ initialiseScope ( parentScope ) {
6912
+ this.scope = new FunctionScope( { parent: parentScope } );
6913
+ }
6914
+ }
6915
+
6916
+ class FunctionDeclaration extends FunctionNode {
6917
+ initialiseChildren ( parentScope ) {
6918
+ this.id && this.id.initialiseAndDeclare( parentScope, 'function', this );
6919
+ this.params.forEach( param => param.initialiseAndDeclare( this.scope, 'parameter' ) );
6920
+ this.body.initialiseAndReplaceScope( new Scope( { parent: this.scope } ) );
6814
6921
  }
6815
6922
 
6816
6923
  render ( code, es ) {
@@ -6822,21 +6929,43 @@ class FunctionDeclaration extends Function$1 {
6822
6929
  }
6823
6930
  }
6824
6931
 
6825
- class FunctionExpression extends Function$1 {
6826
- addReference () {}
6932
+ class FunctionExpression extends FunctionNode {
6933
+ initialiseChildren () {
6934
+ this.id && this.id.initialiseAndDeclare( this.scope, 'function', this );
6935
+ this.params.forEach( param => param.initialiseAndDeclare( this.scope, 'parameter' ) );
6936
+ this.body.initialiseAndReplaceScope( new Scope( { parent: this.scope } ) );
6937
+ }
6938
+ }
6827
6939
 
6828
- getName () {
6829
- return this.name;
6940
+ function isReference (node, parent) {
6941
+ if (node.type === 'MemberExpression') {
6942
+ return !node.computed && isReference(node.object, node);
6830
6943
  }
6831
6944
 
6832
- initialiseChildren ( parentScope ) {
6833
- if ( this.id ) {
6834
- this.name = this.id.name; // may be overridden by bundle.deconflict
6835
- this.scope.addDeclaration( this.name, this, false, false );
6836
- this.id.initialise( this.scope );
6945
+ if (node.type === 'Identifier') {
6946
+ // the only time we could have an identifier node without a parent is
6947
+ // if it's the entire body of a function without a block statement –
6948
+ // i.e. an arrow function expression like `a => a`
6949
+ if (!parent) return true;
6950
+
6951
+ // TODO is this right?
6952
+ if (parent.type === 'MemberExpression' || parent.type === 'MethodDefinition') {
6953
+ return parent.computed || node === parent.object;
6837
6954
  }
6838
- super.initialiseChildren( parentScope );
6955
+
6956
+ // disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
6957
+ if (parent.type === 'Property') return parent.computed || node === parent.value;
6958
+
6959
+ // disregard the `bar` in `class Foo { bar () {...} }`
6960
+ if (parent.type === 'MethodDefinition') return false;
6961
+
6962
+ // disregard the `bar` in `export { foo as bar }`
6963
+ if (parent.type === 'ExportSpecifier' && node !== parent.local) return false;
6964
+
6965
+ return true;
6839
6966
  }
6967
+
6968
+ return false;
6840
6969
  }
6841
6970
 
6842
6971
  function isAssignmentPatternLhs ( node, parent ) {
@@ -6855,54 +6984,74 @@ function isAssignmentPatternLhs ( node, parent ) {
6855
6984
  }
6856
6985
 
6857
6986
  class Identifier extends Node$1 {
6858
- assignExpression ( expression ) {
6859
- if ( this.declaration ) {
6860
- this.declaration.assignExpression( expression );
6987
+ bind () {
6988
+ if ( isReference( this, this.parent ) || isAssignmentPatternLhs( this, this.parent ) ) {
6989
+ this.variable = this.scope.findVariable( this.name );
6990
+ this.variable.addReference( this );
6861
6991
  }
6862
6992
  }
6863
6993
 
6864
- bind () {
6865
- if ( isReference( this, this.parent ) || isAssignmentPatternLhs( this, this.parent ) ) {
6866
- this.declaration = this.scope.findDeclaration( this.name );
6867
- this.declaration.addReference( this ); // TODO necessary?
6994
+ bindAssignment ( expression ) {
6995
+ if ( this.variable ) {
6996
+ this.variable.assignExpression( expression );
6868
6997
  }
6869
6998
  }
6870
6999
 
6871
- gatherPossibleValues ( values ) {
6872
- if ( isReference( this, this.parent ) ) {
6873
- values.add( this );
7000
+ bindCall ( callOptions ) {
7001
+ if ( this.variable ) {
7002
+ this.variable.addCall( callOptions );
6874
7003
  }
6875
7004
  }
6876
7005
 
6877
7006
  hasEffectsAsExpressionStatement ( options ) {
6878
- return this.hasEffects( options ) || this.declaration.isGlobal;
7007
+ return this.hasEffects( options ) || this.variable.isGlobal;
6879
7008
  }
6880
7009
 
6881
7010
  hasEffectsWhenAssigned () {
6882
- return this.declaration && this.declaration.included;
7011
+ return this.variable && this.variable.included;
7012
+ }
7013
+
7014
+ hasEffectsWhenCalled ( options ) {
7015
+ if ( !this.variable ) {
7016
+ return true;
7017
+ }
7018
+ return this.variable.hasEffectsWhenCalled( options );
6883
7019
  }
6884
7020
 
6885
7021
  hasEffectsWhenMutated ( options ) {
6886
- return this.declaration &&
6887
- (this.declaration.included ||
6888
- this.declaration.isParam ||
6889
- this.declaration.isGlobal ||
6890
- this.declaration.isExternal ||
6891
- this.declaration.isNamespace ||
6892
- !this.declaration.assignedExpressions ||
6893
- Array.from( this.declaration.assignedExpressions ).some( node => node.hasEffectsWhenMutated( options ) ));
7022
+ return this.variable && this.variable.hasEffectsWhenMutated( options );
6894
7023
  }
6895
7024
 
6896
7025
  includeInBundle () {
6897
7026
  if ( this.included ) { return false; }
6898
7027
  this.included = true;
6899
- this.declaration && this.declaration.includeDeclaration();
7028
+ this.variable && this.variable.includeVariable();
6900
7029
  return true;
6901
7030
  }
6902
7031
 
7032
+ initialiseAndDeclare ( parentScope, kind, init ) {
7033
+ this.initialiseScope( parentScope );
7034
+ switch ( kind ) {
7035
+ case 'var':
7036
+ case 'function':
7037
+ this.scope.addDeclaration( this, true, init );
7038
+ break;
7039
+ case 'let':
7040
+ case 'const':
7041
+ case 'class':
7042
+ this.scope.addDeclaration( this, false, init );
7043
+ break;
7044
+ case 'parameter':
7045
+ this.scope.addParameterDeclaration( this );
7046
+ break;
7047
+ default:
7048
+ throw new Error( 'Unexpected identifier kind', kind );
7049
+ }
7050
+ }
7051
+
6903
7052
  render ( code, es ) {
6904
- if ( this.declaration ) {
6905
- const name = this.declaration.getName( es );
7053
+ if ( this.variable ) {
7054
+ const name = this.variable.getName( es );
6906
7055
  if ( name !== this.name ) {
6907
7056
  code.overwrite( this.start, this.end, name, { storeName: true, contentOnly: false } );
6908
7057
 
@@ -6925,7 +7074,7 @@ const statementsWithIfStatements = new Set( [
6925
7074
  'WhileStatement'
6926
7075
  ] );
6927
7076
 
6928
- function handleVarDeclarations ( node, scope ) {
7077
+ function getHoistedVars ( node, scope ) {
6929
7078
  const hoistedVars = [];
6930
7079
 
6931
7080
  function visit ( node ) {
@@ -6935,7 +7084,7 @@ function handleVarDeclarations ( node, scope ) {
6935
7084
  declarator.initialise( scope );
6936
7085
 
6937
7086
  extractNames( declarator.id ).forEach( name => {
6938
- if ( !~hoistedVars.indexOf( name ) ) { hoistedVars.push( name ); }
7087
+ if ( hoistedVars.indexOf( name ) < 0 ) { hoistedVars.push( name ); }
6939
7088
  } );
6940
7089
  } );
6941
7090
  }
@@ -6950,29 +7099,24 @@ function handleVarDeclarations ( node, scope ) {
6950
7099
  return hoistedVars;
6951
7100
  }
6952
7101
 
6953
- // TODO DRY this out
6954
7102
  class IfStatement extends Statement {
6955
7103
  initialiseChildren ( parentScope ) {
7104
+ super.initialiseChildren( parentScope );
6956
7105
  if ( this.module.bundle.treeshake ) {
6957
7106
  this.testValue = this.test.getValue();
6958
7107
 
6959
7108
  if ( this.testValue === UNKNOWN_VALUE ) {
6960
- super.initialiseChildren( parentScope );
6961
- } else if ( this.testValue ) {
6962
- this.consequent.initialise( this.scope );
7109
+ return;
7110
+ }
7111
+ if ( this.testValue ) {
6963
7112
  if ( this.alternate ) {
6964
- this.hoistedVars = handleVarDeclarations( this.alternate, this.scope );
7113
+ this.hoistedVars = getHoistedVars( this.alternate, this.scope );
6965
7114
  this.alternate = null;
6966
7115
  }
6967
7116
  } else {
6968
- if ( this.alternate ) {
6969
- this.alternate.initialise( this.scope );
6970
- }
6971
- this.hoistedVars = handleVarDeclarations( this.consequent, this.scope );
7117
+ this.hoistedVars = getHoistedVars( this.consequent, this.scope );
6972
7118
  this.consequent = null;
6973
7119
  }
6974
- } else {
6975
- super.initialiseChildren( parentScope );
6976
7120
  }
6977
7121
  }
6978
7122
 
@@ -6991,8 +7135,8 @@ class IfStatement extends Statement {
6991
7135
  if ( this.hoistedVars ) {
6992
7136
  const names = this.hoistedVars
6993
7137
  .map( name => {
6994
- const declaration = this.scope.findDeclaration( name );
6995
- return declaration.included ? declaration.getName() : null;
7138
+ const variable = this.scope.findVariable( name );
7139
+ return variable.included ? variable.getName() : null;
6996
7140
  } )
6997
7141
  .filter( Boolean );
6998
7142
 
@@ -7042,15 +7186,21 @@ class ImportDeclaration extends Node$1 {
7042
7186
  }
7043
7187
  }
7044
7188
 
7189
+ class LabeledStatement extends Statement {
7190
+ hasEffects ( options ) {
7191
+ return this.body.hasEffects(
7192
+ options
7193
+ .setIgnoreLabel( this.label.name )
7194
+ .setIgnoreBreakStatements()
7195
+ );
7196
+ }
7197
+ }
7198
+
7045
7199
  class Literal extends Node$1 {
7046
7200
  getValue () {
7047
7201
  return this.value;
7048
7202
  }
7049
7203
 
7050
- gatherPossibleValues ( values ) {
7051
- values.add( this );
7052
- }
7053
-
7054
7204
  hasEffectsWhenMutated () {
7055
7205
  return false;
7056
7206
  }
@@ -7090,6 +7240,63 @@ class LogicalExpression extends Node$1 {
7090
7240
  }
7091
7241
  }
7092
7242
 
7243
+ function flatten ( node ) {
7244
+ const parts = [];
7245
+ while ( node.type === 'MemberExpression' ) {
7246
+ if ( node.computed ) { return null; }
7247
+ parts.unshift( node.property.name );
7248
+
7249
+ node = node.object;
7250
+ }
7251
+
7252
+ if ( node.type !== 'Identifier' ) { return null; }
7253
+
7254
+ const name = node.name;
7255
+ parts.unshift( name );
7256
+
7257
+ return { name, keypath: parts.join( '.' ) };
7258
+ }
7259
+
7260
+ const pureFunctions = {};
7261
+
7262
+ const arrayTypes = 'Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split( ' ' );
7263
+ const simdTypes = 'Int8x16 Int16x8 Int32x4 Float32x4 Float64x2'.split( ' ' );
7264
+ const simdMethods = 'abs add and bool check div equal extractLane fromFloat32x4 fromFloat32x4Bits fromFloat64x2 fromFloat64x2Bits fromInt16x8Bits fromInt32x4 fromInt32x4Bits fromInt8x16Bits greaterThan greaterThanOrEqual lessThan lessThanOrEqual load max maxNum min minNum mul neg not notEqual or reciprocalApproximation reciprocalSqrtApproximation replaceLane select selectBits shiftLeftByScalar shiftRightArithmeticByScalar shiftRightLogicalByScalar shuffle splat sqrt store sub swizzle xor'.split( ' ' );
7265
+ const allSimdMethods = [];
7266
+ simdTypes.forEach( t => {
7267
+ simdMethods.forEach( m => {
7268
+ allSimdMethods.push( `SIMD.${t}.${m}` );
7269
+ });
7270
+ });
7271
+
7272
+ [
7273
+ 'Array.isArray',
7274
+ 'Error', 'EvalError', 'InternalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError',
7275
+ 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape', 'unescape',
7276
+ 'Object', 'Object.create', 'Object.getNotifier', 'Object.getOwn', 'Object.getOwnPropertyDescriptor', 'Object.getOwnPropertyNames', 'Object.getOwnPropertySymbols', 'Object.getPrototypeOf', 'Object.is', 'Object.isExtensible', 'Object.isFrozen', 'Object.isSealed', 'Object.keys',
7277
+ 'Function', 'Boolean',
7278
+ 'Number', 'Number.isFinite', 'Number.isInteger', 'Number.isNaN', 'Number.isSafeInteger', 'Number.parseFloat', 'Number.parseInt',
7279
+ 'Symbol', 'Symbol.for', 'Symbol.keyFor',
7280
+ 'Math.abs', 'Math.acos', 'Math.acosh', 'Math.asin', 'Math.asinh', 'Math.atan', 'Math.atan2', 'Math.atanh', 'Math.cbrt', 'Math.ceil', 'Math.clz32', 'Math.cos', 'Math.cosh', 'Math.exp', 'Math.expm1', 'Math.floor', 'Math.fround', 'Math.hypot', 'Math.imul', 'Math.log', 'Math.log10', 'Math.log1p', 'Math.log2', 'Math.max', 'Math.min', 'Math.pow', 'Math.random', 'Math.round', 'Math.sign', 'Math.sin', 'Math.sinh', 'Math.sqrt', 'Math.tan', 'Math.tanh', 'Math.trunc',
7281
+ 'Date', 'Date.UTC', 'Date.now', 'Date.parse',
7282
+ 'String', 'String.fromCharCode', 'String.fromCodePoint', 'String.raw',
7283
+ 'RegExp',
7284
+ 'Map', 'Set', 'WeakMap', 'WeakSet',
7285
+ 'ArrayBuffer', 'ArrayBuffer.isView',
7286
+ 'DataView',
7287
+ 'JSON.parse', 'JSON.stringify',
7288
+ 'Promise.all', 'Promise.race', 'Promise.resolve',
7289
+ 'Intl.Collator', 'Intl.Collator.supportedLocalesOf', 'Intl.DateTimeFormat', 'Intl.DateTimeFormat.supportedLocalesOf', 'Intl.NumberFormat', 'Intl.NumberFormat.supportedLocalesOf'
7290
+
7291
+ // TODO properties of e.g. window...
7292
+ ].concat(
7293
+ arrayTypes,
7294
+ arrayTypes.map( t => `${t}.from` ),
7295
+ arrayTypes.map( t => `${t}.of` ),
7296
+ simdTypes.map( t => `SIMD.${t}` ),
7297
+ allSimdMethods
7298
+ ).forEach( name => pureFunctions[ name ] = true );
7299
+
7093
7300
  const validProp = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
7094
7301
 
7095
7302
  class Keypath {
@@ -7122,15 +7329,15 @@ class MemberExpression extends Node$1 {
7122
7329
  const keypath = new Keypath( this );
7123
7330
 
7124
7331
  if ( !keypath.computed && keypath.root.type === 'Identifier' ) {
7125
- let declaration = this.scope.findDeclaration( keypath.root.name );
7332
+ let variable = this.scope.findVariable( keypath.root.name );
7126
7333
 
7127
- while ( declaration.isNamespace && keypath.parts.length ) {
7128
- const exporterId = declaration.module.id;
7334
+ while ( variable.isNamespace && keypath.parts.length ) {
7335
+ const exporterId = variable.module.id;
7129
7336
 
7130
7337
  const part = keypath.parts[ 0 ];
7131
- declaration = declaration.module.traceExport( part.name || part.value );
7338
+ variable = variable.module.traceExport( part.name || part.value );
7132
7339
 
7133
- if ( !declaration ) {
7340
+ if ( !variable ) {
7134
7341
  this.module.warn( {
7135
7342
  code: 'MISSING_EXPORT',
7136
7343
  missing: part.name || part.value,
@@ -7151,10 +7358,10 @@ class MemberExpression extends Node$1 {
7151
7358
  return; // not a namespaced declaration
7152
7359
  }
7153
7360
 
7154
- this.declaration = declaration;
7361
+ this.variable = variable;
7155
7362
 
7156
- if ( declaration.isExternal ) {
7157
- declaration.module.suggestName( keypath.root.name );
7363
+ if ( variable.isExternal ) {
7364
+ variable.module.suggestName( keypath.root.name );
7158
7365
  }
7159
7366
  }
7160
7367
 
@@ -7163,8 +7370,10 @@ class MemberExpression extends Node$1 {
7163
7370
  }
7164
7371
  }
7165
7372
 
7166
- gatherPossibleValues ( values ) {
7167
- values.add( UNKNOWN_ASSIGNMENT ); // TODO
7373
+ bindCall ( callOptions ) {
7374
+ if ( this.variable ) {
7375
+ this.variable.addCall( callOptions );
7376
+ }
7168
7377
  }
7169
7378
 
7170
7379
  hasEffectsWhenAssigned ( options ) {
@@ -7173,16 +7382,27 @@ class MemberExpression extends Node$1 {
7173
7382
 
7174
7383
  includeInBundle () {
7175
7384
  let addedNewNodes = super.includeInBundle();
7176
- if ( this.declaration && !this.declaration.included ) {
7177
- this.declaration.includeDeclaration();
7385
+ if ( this.variable && !this.variable.included ) {
7386
+ this.variable.includeVariable();
7178
7387
  addedNewNodes = true;
7179
7388
  }
7180
7389
  return addedNewNodes;
7181
7390
  }
7182
7391
 
7392
+ hasEffectsWhenCalled ( options ) {
7393
+ if ( this.variable ) {
7394
+ return this.variable.hasEffectsWhenCalled( options );
7395
+ }
7396
+ if ( !isReference( this ) ) {
7397
+ return true;
7398
+ }
7399
+ const flattenedNode = flatten( this );
7400
+ return !(this.scope.findVariable( flattenedNode.name ).isGlobal && pureFunctions[ flattenedNode.keypath ]);
7401
+ }
7402
+
7183
7403
  render ( code, es ) {
7184
- if ( this.declaration ) {
7185
- const name = this.declaration.getName( es );
7404
+ if ( this.variable ) {
7405
+ const name = this.variable.getName( es );
7186
7406
  if ( name !== this.name ) { code.overwrite( this.start, this.end, name, { storeName: true, contentOnly: false } ); }
7187
7407
  }
7188
7408
 
@@ -7194,9 +7414,30 @@ class MemberExpression extends Node$1 {
7194
7414
  }
7195
7415
  }
7196
7416
 
7417
+ class MethodDefinition extends Node$1 {
7418
+ bindCall ( callOptions ) {
7419
+ this.value.bindCall( callOptions );
7420
+ }
7421
+
7422
+ hasEffects ( options ) {
7423
+ return this.key.hasEffects( options );
7424
+ }
7425
+
7426
+ hasEffectsWhenCalled ( options ) {
7427
+ return this.value.hasEffectsWhenCalled( options );
7428
+ }
7429
+ }
7430
+
7197
7431
  class NewExpression extends Node$1 {
7198
- hasEffects () {
7199
- return this.included || callHasEffects( this.scope, this.callee, true );
7432
+ bind () {
7433
+ super.bind();
7434
+ this.callee.bindCall( { withNew: true } );
7435
+ }
7436
+
7437
+ hasEffects ( options ) {
7438
+ return this.included
7439
+ || this.arguments.some( child => child.hasEffects( options ) )
7440
+ || this.callee.hasEffectsWhenCalled( options.getHasEffectsWhenCalledOptions( this.callee ) );
7200
7441
  }
7201
7442
  }
7202
7443
 
@@ -7207,24 +7448,35 @@ class ObjectExpression extends Node$1 {
7207
7448
  }
7208
7449
 
7209
7450
  class ObjectPattern extends Node$1 {
7210
- assignExpression () {
7211
- this.eachChild( child => child.assignExpression( UNKNOWN_ASSIGNMENT ) );
7451
+ bindAssignment ( expression ) {
7452
+ this.properties.forEach( child => child.bindAssignment( expression ) );
7212
7453
  }
7213
7454
 
7214
7455
  hasEffectsWhenAssigned ( options ) {
7215
7456
  return this.someChild( child => child.hasEffectsWhenAssigned( options ) );
7216
7457
  }
7458
+
7459
+ initialiseAndDeclare ( parentScope, kind, init ) {
7460
+ this.initialiseScope( parentScope );
7461
+ this.properties.forEach( child => child.initialiseAndDeclare( parentScope, kind, init ) );
7462
+ }
7217
7463
  }
7218
7464
 
7219
7465
  class Property extends Node$1 {
7220
- assignExpression ( expression ) {
7221
- this.value.assignExpression( expression );
7466
+ bindAssignment () {
7467
+ this.value.bindAssignment( UNKNOWN_ASSIGNMENT );
7222
7468
  }
7223
7469
 
7224
7470
  hasEffectsWhenAssigned ( options ) {
7225
7471
  return this.value.hasEffectsWhenAssigned( options );
7226
7472
  }
7227
7473
 
7474
+ initialiseAndDeclare ( parentScope, kind, init ) {
7475
+ this.initialiseScope( parentScope );
7476
+ this.key.initialise( parentScope );
7477
+ this.value.initialiseAndDeclare( parentScope, kind, init && UNKNOWN_ASSIGNMENT );
7478
+ }
7479
+
7228
7480
  render ( code, es ) {
7229
7481
  if ( !this.shorthand ) {
7230
7482
  this.key.render( code, es );
@@ -7234,23 +7486,24 @@ class Property extends Node$1 {
7234
7486
  }
7235
7487
 
7236
7488
  class RestElement extends Node$1 {
7237
- assignExpression () {
7238
- this.argument.assignExpression( UNKNOWN_ASSIGNMENT );
7489
+ bindAssignment () {
7490
+ this.argument.bindAssignment( UNKNOWN_ASSIGNMENT );
7239
7491
  }
7240
7492
 
7241
7493
  hasEffectsWhenAssigned ( options ) {
7242
7494
  return this.argument.hasEffectsWhenAssigned( options );
7243
7495
  }
7496
+
7497
+ initialiseAndDeclare ( parentScope, kind ) {
7498
+ this.initialiseScope( parentScope );
7499
+ this.argument.initialiseAndDeclare( parentScope, kind, UNKNOWN_ASSIGNMENT );
7500
+ }
7244
7501
  }
7245
7502
 
7246
7503
  class ReturnStatement extends Statement {
7247
7504
  hasEffects ( options ) {
7248
7505
  return super.hasEffects( options )
7249
- || !options.inNestedFunctionCall;
7250
- }
7251
-
7252
- shouldBeIncluded () {
7253
- return true;
7506
+ || !options.ignoreReturnAwaitYield();
7254
7507
  }
7255
7508
  }
7256
7509
 
@@ -7277,32 +7530,28 @@ class SwitchCase extends Node$1 {
7277
7530
  }
7278
7531
 
7279
7532
  class SwitchStatement extends Statement {
7280
- hasEffects(options) {
7281
- return super.hasEffects(Object.assign({}, options, {inNestedBreakableStatement: true}));
7533
+ hasEffects ( options ) {
7534
+ return super.hasEffects( options.setIgnoreBreakStatements() );
7282
7535
  }
7283
7536
 
7284
7537
  initialiseScope ( parentScope ) {
7285
- this.scope = new Scope( {
7286
- parent: parentScope,
7287
- isBlockScope: true,
7288
- isLexicalBoundary: false
7289
- } );
7538
+ this.scope = new BlockScope( { parent: parentScope } );
7290
7539
  }
7291
7540
  }
7292
7541
 
7293
7542
  class TaggedTemplateExpression extends Node$1 {
7294
7543
  bind () {
7295
7544
  if ( this.tag.type === 'Identifier' ) {
7296
- const declaration = this.scope.findDeclaration( this.tag.name );
7545
+ const variable = this.scope.findVariable( this.tag.name );
7297
7546
 
7298
- if ( declaration.isNamespace ) {
7547
+ if ( variable.isNamespace ) {
7299
7548
  this.module.error( {
7300
7549
  code: 'CANNOT_CALL_NAMESPACE',
7301
7550
  message: `Cannot call a namespace ('${this.tag.name}')`
7302
7551
  }, this.start );
7303
7552
  }
7304
7553
 
7305
- if ( this.tag.name === 'eval' && declaration.isGlobal ) {
7554
+ if ( this.tag.name === 'eval' && variable.isGlobal ) {
7306
7555
  this.module.warn( {
7307
7556
  code: 'EVAL',
7308
7557
  message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`,
@@ -7312,10 +7561,12 @@ class TaggedTemplateExpression extends Node$1 {
7312
7561
  }
7313
7562
 
7314
7563
  super.bind();
7564
+ this.tag.bindCall( { withNew: false } );
7315
7565
  }
7316
7566
 
7317
7567
  hasEffects ( options ) {
7318
- return this.quasi.hasEffects( options ) || callHasEffects( this.scope, this.tag, false );
7568
+ return super.hasEffects( options )
7569
+ || this.tag.hasEffectsWhenCalled( options.getHasEffectsWhenCalledOptions( this.tag ) );
7319
7570
  }
7320
7571
  }
7321
7572
 
@@ -7348,6 +7599,14 @@ class ThisExpression extends Node$1 {
7348
7599
  }
7349
7600
  }
7350
7601
 
7602
+ bind () {
7603
+ this.variable = this.scope.findVariable( 'this' );
7604
+ }
7605
+
7606
+ hasEffectsWhenMutated ( options ) {
7607
+ return !options.ignoreSafeThisMutations() || this.variable.hasEffectsWhenMutated( options );
7608
+ }
7609
+
7351
7610
  render ( code ) {
7352
7611
  if ( this.alias ) {
7353
7612
  code.overwrite( this.start, this.end, this.alias, { storeName: true, contentOnly: false } );
@@ -7405,8 +7664,8 @@ class UpdateExpression extends Node$1 {
7405
7664
  bind () {
7406
7665
  disallowIllegalReassignment( this.scope, this.argument );
7407
7666
  if ( this.argument.type === 'Identifier' ) {
7408
- const declaration = this.scope.findDeclaration( this.argument.name );
7409
- declaration.isReassigned = true;
7667
+ const variable = this.scope.findVariable( this.argument.name );
7668
+ variable.isReassigned = true;
7410
7669
  }
7411
7670
  super.bind();
7412
7671
  }
@@ -7420,88 +7679,25 @@ class UpdateExpression extends Node$1 {
7420
7679
  }
7421
7680
  }
7422
7681
 
7423
- class DeclaratorProxy {
7424
- constructor ( name, declarator, isTopLevel, init ) {
7425
- this.name = name;
7426
- this.declarator = declarator;
7427
-
7428
- this.isReassigned = false;
7429
- this.exportName = null;
7430
-
7431
- this.duplicates = [];
7432
- this.assignedExpressions = new Set( init ? [ init ] : null );
7433
- }
7434
-
7435
- addReference () {
7436
- /* noop? */
7437
- }
7438
-
7439
- assignExpression ( expression ) {
7440
- this.assignedExpressions.add( expression );
7441
- this.isReassigned = true;
7442
- }
7443
-
7444
- gatherPossibleValues ( values ) {
7445
- this.assignedExpressions.forEach( value => values.add( value ) );
7446
- }
7447
-
7448
- getName ( es ) {
7449
- // TODO destructuring...
7450
- if ( es ) { return this.name; }
7451
- if ( !this.isReassigned || !this.exportName ) { return this.name; }
7452
-
7453
- return `exports.${this.exportName}`;
7454
- }
7455
-
7456
- includeDeclaration () {
7457
- if ( this.included ) {
7458
- return false;
7459
- }
7460
- this.included = true;
7461
- this.declarator.includeDeclaration();
7462
- this.duplicates.forEach( duplicate => duplicate.includeDeclaration() );
7463
- return true;
7464
- }
7465
-
7466
- toString () {
7467
- return this.name;
7468
- }
7469
- }
7470
-
7471
7682
  class VariableDeclarator extends Node$1 {
7472
- assignExpression () {
7473
- for ( const proxy of this.proxies.values() ) {
7474
- proxy.assignExpression( UNKNOWN_ASSIGNMENT );
7475
- }
7683
+ bindAssignment ( expression ) {
7684
+ this.id.bindAssignment( expression );
7476
7685
  }
7477
7686
 
7478
- hasEffects ( options ) {
7479
- return super.hasEffects( options )
7480
- || extractNames( this.id ).some( name => this.proxies.get( name ).included );
7481
- }
7482
-
7483
- initialiseNode () {
7484
- this.proxies = new Map();
7485
- const lexicalBoundary = this.scope.findLexicalBoundary();
7486
- const init = this.init
7487
- ? ( this.id.type === 'Identifier' ? this.init : UNKNOWN_ASSIGNMENT )
7488
- : null;
7489
-
7490
- extractNames( this.id ).forEach( name => {
7491
- const proxy = new DeclaratorProxy( name, this, lexicalBoundary.isModuleScope, init );
7492
-
7493
- this.proxies.set( name, proxy );
7494
- this.scope.addDeclaration( name, proxy, this.parent.kind === 'var' );
7495
- } );
7687
+ initialiseDeclarator ( parentScope, kind ) {
7688
+ this.initialiseScope( parentScope );
7689
+ this.init && this.init.initialise( this.scope );
7690
+ this.id.initialiseAndDeclare( this.scope, kind, this.init );
7496
7691
  }
7497
7692
 
7693
+ // TODO Deleting this does not break any tests. Find meaningful test or delete.
7498
7694
  render ( code, es ) {
7499
7695
  extractNames( this.id ).forEach( name => {
7500
- const declaration = this.proxies.get( name );
7696
+ const variable = this.scope.findVariable( name );
7501
7697
 
7502
- if ( !es && declaration.exportName && declaration.isReassigned ) {
7698
+ if ( !es && variable.exportName && variable.isReassigned ) {
7503
7699
  if ( this.init ) {
7504
- code.overwrite( this.start, this.id.end, declaration.getName( es ) );
7700
+ code.overwrite( this.start, this.id.end, variable.getName( es ) );
7505
7701
  } else if ( this.module.bundle.treeshake ) {
7506
7702
  code.remove( this.start, this.end );
7507
7703
  }
@@ -7528,15 +7724,19 @@ function getSeparator ( code, start ) {
7528
7724
  const forStatement = /^For(?:Of|In)?Statement/;
7529
7725
 
7530
7726
  class VariableDeclaration extends Node$1 {
7531
- assignExpression () {
7532
- this.eachChild( child => child.assignExpression( UNKNOWN_ASSIGNMENT ) );
7727
+ bindAssignment () {
7728
+ this.eachChild( child => child.bindAssignment( UNKNOWN_ASSIGNMENT ) );
7533
7729
  }
7534
7730
 
7535
- includeDeclaration () {
7731
+ hasEffectsWhenAssigned () {
7732
+ return false;
7733
+ }
7734
+
7735
+ includeWithAllDeclarations () {
7536
7736
  if ( this.isFullyIncluded() ) { return false; }
7537
7737
  let addedNewNodes = false;
7538
7738
  this.declarations.forEach( declarator => {
7539
- if ( declarator.includeDeclaration() ) {
7739
+ if ( declarator.includeInBundle() ) {
7540
7740
  addedNewNodes = true;
7541
7741
  }
7542
7742
  } );
@@ -7564,6 +7764,10 @@ class VariableDeclaration extends Node$1 {
7564
7764
  return false;
7565
7765
  }
7566
7766
 
7767
+ initialiseChildren () {
7768
+ this.declarations.forEach( child => child.initialiseDeclarator( this.scope, this.kind ) );
7769
+ }
7770
+
7567
7771
  render ( code, es ) {
7568
7772
  const treeshake = this.module.bundle.treeshake;
7569
7773
 
@@ -7584,8 +7788,8 @@ class VariableDeclaration extends Node$1 {
7584
7788
  const prefix = empty ? '' : separator; // TODO indentation
7585
7789
 
7586
7790
  if ( declarator.id.type === 'Identifier' ) {
7587
- const proxy = declarator.proxies.get( declarator.id.name );
7588
- const isExportedAndReassigned = !es && proxy.exportName && proxy.isReassigned;
7791
+ const variable = this.scope.findVariable( declarator.id.name );
7792
+ const isExportedAndReassigned = !es && variable.exportName && variable.isReassigned;
7589
7793
 
7590
7794
  if ( isExportedAndReassigned ) {
7591
7795
  if ( declarator.init ) {
@@ -7593,7 +7797,7 @@ class VariableDeclaration extends Node$1 {
7593
7797
  c = declarator.end;
7594
7798
  empty = false;
7595
7799
  }
7596
- } else if ( !treeshake || proxy.included ) {
7800
+ } else if ( !treeshake || variable.included ) {
7597
7801
  if ( shouldSeparate ) { code.overwrite( c, declarator.start, `${prefix}${this.kind} ` ); } // TODO indentation
7598
7802
  c = declarator.end;
7599
7803
  empty = false;
@@ -7603,8 +7807,8 @@ class VariableDeclaration extends Node$1 {
7603
7807
  let isIncluded = false;
7604
7808
 
7605
7809
  extractNames( declarator.id ).forEach( name => {
7606
- const proxy = declarator.proxies.get( name );
7607
- const isExportedAndReassigned = !es && proxy.exportName && proxy.isReassigned;
7810
+ const variable = this.scope.findVariable( name );
7811
+ const isExportedAndReassigned = !es && variable.exportName && variable.isReassigned;
7608
7812
 
7609
7813
  if ( isExportedAndReassigned ) {
7610
7814
  // code.overwrite( c, declarator.start, prefix );
@@ -7651,11 +7855,22 @@ class WhileStatement extends Statement {
7651
7855
  return (
7652
7856
  this.included
7653
7857
  || this.test.hasEffects( options )
7654
- || this.body.hasEffects( Object.assign( {}, options, { inNestedBreakableStatement: true } ) )
7858
+ || this.body.hasEffects( options.setIgnoreBreakStatements() )
7655
7859
  );
7656
7860
  }
7657
7861
  }
7658
7862
 
7863
+ class YieldExpression extends Node$1 {
7864
+ hasEffects ( options ) {
7865
+ return super.hasEffects( options )
7866
+ || !options.ignoreReturnAwaitYield();
7867
+ }
7868
+
7869
+ hasEffectsAsExpressionStatement ( options ) {
7870
+ return this.hasEffects( options );
7871
+ }
7872
+ }
7873
+
7659
7874
  var nodes = {
7660
7875
  ArrayExpression: Node$1,
7661
7876
  ArrayPattern,
@@ -7668,6 +7883,7 @@ var nodes = {
7668
7883
  BreakStatement,
7669
7884
  CallExpression,
7670
7885
  CatchClause,
7886
+ ClassBody,
7671
7887
  ClassDeclaration,
7672
7888
  ClassExpression,
7673
7889
  ConditionalExpression,
@@ -7685,9 +7901,11 @@ var nodes = {
7685
7901
  Identifier,
7686
7902
  IfStatement,
7687
7903
  ImportDeclaration,
7904
+ LabeledStatement,
7688
7905
  Literal,
7689
7906
  LogicalExpression,
7690
7907
  MemberExpression,
7908
+ MethodDefinition,
7691
7909
  NewExpression,
7692
7910
  ObjectExpression,
7693
7911
  ObjectPattern,
@@ -7706,7 +7924,8 @@ var nodes = {
7706
7924
  UpdateExpression,
7707
7925
  VariableDeclarator,
7708
7926
  VariableDeclaration,
7709
- WhileStatement
7927
+ WhileStatement,
7928
+ YieldExpression
7710
7929
  };
7711
7930
 
7712
7931
  class UnknownNode extends Node$1 {
@@ -7800,14 +8019,13 @@ function clone ( node ) {
7800
8019
 
7801
8020
  class ModuleScope extends Scope {
7802
8021
  constructor ( module ) {
7803
- super({
7804
- isBlockScope: false,
7805
- isLexicalBoundary: true,
8022
+ super( {
7806
8023
  isModuleScope: true,
7807
8024
  parent: module.bundle.scope
7808
- });
8025
+ } );
7809
8026
 
7810
8027
  this.module = module;
8028
+ this.variables.this = new LocalVariable( 'this', null, UNDEFINED_ASSIGNMENT );
7811
8029
  }
7812
8030
 
7813
8031
  deshadow ( names ) {
@@ -7819,21 +8037,21 @@ class ModuleScope extends Scope {
7819
8037
  const addDeclaration = declaration => {
7820
8038
  if ( declaration.isNamespace && !declaration.isExternal ) {
7821
8039
  declaration.module.getExports().forEach( name => {
7822
- addDeclaration( declaration.module.traceExport(name) );
7823
- });
8040
+ addDeclaration( declaration.module.traceExport( name ) );
8041
+ } );
7824
8042
  }
7825
8043
 
7826
8044
  names.add( declaration.name );
7827
8045
  };
7828
8046
 
7829
8047
  specifier.module.getExports().forEach( name => {
7830
- addDeclaration( specifier.module.traceExport(name) );
7831
- });
8048
+ addDeclaration( specifier.module.traceExport( name ) );
8049
+ } );
7832
8050
 
7833
8051
  if ( specifier.name !== '*' ) {
7834
8052
  const declaration = specifier.module.traceExport( specifier.name );
7835
8053
  if ( !declaration ) {
7836
- this.module.warn({
8054
+ this.module.warn( {
7837
8055
  code: 'NON_EXISTENT_EXPORT',
7838
8056
  name: specifier.name,
7839
8057
  source: specifier.module.id,
@@ -7851,22 +8069,22 @@ class ModuleScope extends Scope {
7851
8069
  names.add( specifier.specifier.imported.name );
7852
8070
  }
7853
8071
  }
7854
- });
8072
+ } );
7855
8073
 
7856
8074
  super.deshadow( names );
7857
8075
  }
7858
8076
 
7859
- findDeclaration ( name ) {
7860
- if ( this.declarations[ name ] ) {
7861
- return this.declarations[ name ];
7862
- }
7863
-
7864
- return this.module.trace( name ) || this.parent.findDeclaration( name );
7865
- }
7866
-
7867
8077
  findLexicalBoundary () {
7868
8078
  return this;
7869
8079
  }
8080
+
8081
+ findVariable ( name ) {
8082
+ if ( this.variables[ name ] ) {
8083
+ return this.variables[ name ];
8084
+ }
8085
+
8086
+ return this.module.trace( name ) || this.parent.findVariable( name );
8087
+ }
7870
8088
  }
7871
8089
 
7872
8090
  function tryParse ( module, acornOptions ) {
@@ -7885,6 +8103,11 @@ function tryParse ( module, acornOptions ) {
7885
8103
  }
7886
8104
  }
7887
8105
 
8106
+ function includeFully ( node ) {
8107
+ node.includeInBundle();
8108
+ node.eachChild( includeFully );
8109
+ }
8110
+
7888
8111
  class Module {
7889
8112
  constructor ( ref ) {
7890
8113
  var id = ref.id;
@@ -8019,9 +8242,6 @@ class Module {
8019
8242
  localName: 'default',
8020
8243
  identifier
8021
8244
  };
8022
-
8023
- // create a synthetic declaration
8024
- //this.declarations.default = new SyntheticDefaultDeclaration( node, identifier || this.basename() );
8025
8245
  }
8026
8246
 
8027
8247
  // export var { foo, bar } = ...
@@ -8188,6 +8408,10 @@ class Module {
8188
8408
  return keys( reexports );
8189
8409
  }
8190
8410
 
8411
+ includeAllInBundle () {
8412
+ this.ast.body.forEach( includeFully );
8413
+ }
8414
+
8191
8415
  includeInBundle () {
8192
8416
  let addedNewNodes = false;
8193
8417
  this.ast.body.forEach( node => {
@@ -8202,7 +8426,7 @@ class Module {
8202
8426
 
8203
8427
  namespace () {
8204
8428
  if ( !this.declarations[ '*' ] ) {
8205
- this.declarations[ '*' ] = new SyntheticNamespaceDeclaration( this );
8429
+ this.declarations[ '*' ] = new NamespaceVariable( this );
8206
8430
  }
8207
8431
 
8208
8432
  return this.declarations[ '*' ];
@@ -8238,8 +8462,8 @@ class Module {
8238
8462
 
8239
8463
  trace ( name ) {
8240
8464
  // TODO this is slightly circular
8241
- if ( name in this.scope.declarations ) {
8242
- return this.scope.declarations[ name ];
8465
+ if ( name in this.scope.variables ) {
8466
+ return this.scope.variables[ name ];
8243
8467
  }
8244
8468
 
8245
8469
  if ( name in this.imports ) {
@@ -8294,7 +8518,7 @@ class Module {
8294
8518
  const name = exportDeclaration.localName;
8295
8519
  const declaration = this.trace( name );
8296
8520
 
8297
- return declaration || this.bundle.scope.findDeclaration( name );
8521
+ return declaration || this.bundle.scope.findVariable( name );
8298
8522
  }
8299
8523
 
8300
8524
  if ( name === 'default' ) { return; }
@@ -8324,11 +8548,54 @@ class Module {
8324
8548
  }
8325
8549
  }
8326
8550
 
8551
+ class ExternalVariable extends Variable {
8552
+ constructor ( module, name ) {
8553
+ super( name );
8554
+ this.module = module;
8555
+ this.safeName = null;
8556
+ this.isExternal = true;
8557
+ this.isNamespace = name === '*';
8558
+ }
8559
+
8560
+ addReference ( reference ) {
8561
+ if ( this.name === 'default' || this.name === '*' ) {
8562
+ this.module.suggestName( reference.name );
8563
+ }
8564
+ }
8565
+
8566
+ getName ( es ) {
8567
+ if ( this.name === '*' ) {
8568
+ return this.module.name;
8569
+ }
8570
+
8571
+ if ( this.name === 'default' ) {
8572
+ return this.module.exportsNamespace || ( !es && this.module.exportsNames ) ?
8573
+ `${this.module.name}__default` :
8574
+ this.module.name;
8575
+ }
8576
+
8577
+ return es ? this.safeName : `${this.module.name}.${this.name}`;
8578
+ }
8579
+
8580
+ includeDeclaration () {
8581
+ if ( this.included ) {
8582
+ return false;
8583
+ }
8584
+ this.included = true;
8585
+ this.module.used = true;
8586
+ return true;
8587
+ }
8588
+
8589
+ setSafeName ( name ) {
8590
+ this.safeName = name;
8591
+ }
8592
+ }
8593
+
8327
8594
  class ExternalModule {
8328
8595
  constructor ( id ) {
8329
8596
  this.id = id;
8330
8597
 
8331
- const parts = id.split(/[\\/]/);
8598
+ const parts = id.split( /[\\/]/ );
8332
8599
  this.name = makeLegal( parts.pop() );
8333
8600
 
8334
8601
  this.nameSuggestions = blank();
@@ -8355,9 +8622,8 @@ class ExternalModule {
8355
8622
  if ( name !== 'default' && name !== '*' ) { this.exportsNames = true; }
8356
8623
  if ( name === '*' ) { this.exportsNamespace = true; }
8357
8624
 
8358
- return this.declarations[ name ] || (
8359
- this.declarations[ name ] = new ExternalDeclaration( this, name )
8360
- );
8625
+ return this.declarations[ name ]
8626
+ || (this.declarations[ name ] = new ExternalVariable( this, name ));
8361
8627
  }
8362
8628
  }
8363
8629
 
@@ -9399,9 +9665,9 @@ function callIfFunction ( thing ) {
9399
9665
  return typeof thing === 'function' ? thing() : thing;
9400
9666
  }
9401
9667
 
9402
- class SyntheticGlobalDeclaration {
9668
+ class GlobalVariable extends Variable {
9403
9669
  constructor ( name ) {
9404
- this.name = name;
9670
+ super( name );
9405
9671
  this.isExternal = true;
9406
9672
  this.isGlobal = true;
9407
9673
  this.isReassigned = false;
@@ -9409,33 +9675,23 @@ class SyntheticGlobalDeclaration {
9409
9675
  }
9410
9676
 
9411
9677
  addReference ( reference ) {
9412
- reference.declaration = this;
9413
9678
  if ( reference.isReassignment ) { this.isReassigned = true; }
9414
9679
  }
9415
9680
 
9416
9681
  assignExpression () {}
9417
9682
 
9418
- gatherPossibleValues ( values ) {
9419
- values.add( UNKNOWN_ASSIGNMENT );
9420
- }
9421
-
9422
- getName () {
9423
- return this.name;
9424
- }
9425
-
9426
- includeDeclaration () {
9427
- this.included = true;
9428
- return false;
9683
+ hasEffectsWhenCalled () {
9684
+ return !pureFunctions[ this.name ];
9429
9685
  }
9430
9686
  }
9431
9687
 
9432
9688
  class BundleScope extends Scope {
9433
- findDeclaration ( name ) {
9434
- if ( !this.declarations[ name ] ) {
9435
- this.declarations[ name ] = new SyntheticGlobalDeclaration( name );
9689
+ findVariable ( name ) {
9690
+ if ( !this.variables[ name ] ) {
9691
+ this.variables[ name ] = new GlobalVariable( name );
9436
9692
  }
9437
9693
 
9438
- return this.declarations[ name ];
9694
+ return this.variables[ name ];
9439
9695
  }
9440
9696
  }
9441
9697
 
@@ -9491,7 +9747,7 @@ class Bundle$$1 {
9491
9747
  this.scope = new BundleScope();
9492
9748
  // TODO strictly speaking, this only applies with non-ES6, non-default-only bundles
9493
9749
  [ 'module', 'exports', '_interopDefault' ].forEach( name => {
9494
- this.scope.findDeclaration( name ); // creates global declaration as side-effect
9750
+ this.scope.findVariable( name ); // creates global variable as side-effect
9495
9751
  } );
9496
9752
 
9497
9753
  this.moduleById = new Map();
@@ -9553,7 +9809,7 @@ class Bundle$$1 {
9553
9809
  .then( entryModule => {
9554
9810
  this.entryModule = entryModule;
9555
9811
 
9556
- // Phase 2 – binding. We link references to their declarations
9812
+ // Phase 2 – binding. We link references to their variables
9557
9813
  // to generate a complete picture of the bundle
9558
9814
 
9559
9815
  timeStart( 'phase 2' );
@@ -9563,31 +9819,30 @@ class Bundle$$1 {
9563
9819
 
9564
9820
  timeEnd( 'phase 2' );
9565
9821
 
9566
- // Phase 3 – marking. We 'run' each statement to see which ones
9567
- // need to be included in the generated bundle
9822
+ // Phase 3 – marking. We include all statements that should be included
9568
9823
 
9569
9824
  timeStart( 'phase 3' );
9570
9825
 
9571
9826
  // mark all export statements
9572
9827
  entryModule.getExports().forEach( name => {
9573
- const declaration = entryModule.traceExport( name );
9828
+ const variable = entryModule.traceExport( name );
9574
9829
 
9575
- declaration.exportName = name;
9576
- declaration.includeDeclaration();
9830
+ variable.exportName = name;
9831
+ variable.includeVariable();
9577
9832
 
9578
- if ( declaration.isNamespace ) {
9579
- declaration.needsNamespaceBlock = true;
9833
+ if ( variable.isNamespace ) {
9834
+ variable.needsNamespaceBlock = true;
9580
9835
  }
9581
9836
  } );
9582
9837
 
9583
9838
  entryModule.getReexports().forEach( name => {
9584
- const declaration = entryModule.traceExport( name );
9839
+ const variable = entryModule.traceExport( name );
9585
9840
 
9586
- if ( declaration.isExternal ) {
9587
- declaration.reexported = declaration.module.reexported = true;
9841
+ if ( variable.isExternal ) {
9842
+ variable.reexported = variable.module.reexported = true;
9588
9843
  } else {
9589
- declaration.exportName = name;
9590
- declaration.includeDeclaration();
9844
+ variable.exportName = name;
9845
+ variable.includeVariable();
9591
9846
  }
9592
9847
  } );
9593
9848
 
@@ -9602,6 +9857,9 @@ class Bundle$$1 {
9602
9857
  }
9603
9858
  } );
9604
9859
  } while ( addedNewNodes );
9860
+ } else {
9861
+ // Necessary to properly replace namespace imports
9862
+ this.modules.forEach( module => module.includeAllInBundle() );
9605
9863
  }
9606
9864
 
9607
9865
  timeEnd( 'phase 3' );
@@ -9648,7 +9906,7 @@ class Bundle$$1 {
9648
9906
  const used = blank();
9649
9907
 
9650
9908
  // ensure no conflicts with globals
9651
- keys( this.scope.declarations ).forEach( name => used[ name ] = 1 );
9909
+ keys( this.scope.variables ).forEach( name => used[ name ] = 1 );
9652
9910
 
9653
9911
  function getSafeName ( name ) {
9654
9912
  while ( used[ name ] ) {
@@ -9676,12 +9934,12 @@ class Bundle$$1 {
9676
9934
  } );
9677
9935
 
9678
9936
  this.modules.forEach( module => {
9679
- forOwn( module.scope.declarations, ( declaration ) => {
9680
- if ( declaration.isDefault && declaration.declaration.id ) {
9937
+ forOwn( module.scope.variables, variable => {
9938
+ if ( variable.isDefault && variable.declaration.id ) {
9681
9939
  return;
9682
9940
  }
9683
9941
 
9684
- declaration.name = getSafeName( declaration.name );
9942
+ variable.name = getSafeName( variable.name );
9685
9943
  } );
9686
9944
 
9687
9945
  // deconflict reified namespaces
@@ -9834,12 +10092,12 @@ class Bundle$$1 {
9834
10092
  // need to find the actual import declaration, so we can provide
9835
10093
  // a useful error message. Bit hoop-jumpy but what can you do
9836
10094
  const declaration = module.ast.body.find( node => {
9837
- return node.isImportDeclaration && node.source.value === source;
10095
+ return ( node.isImportDeclaration || node.isExportDeclaration ) && node.source.value === source;
9838
10096
  } );
9839
-
10097
+ const declarationType = /Export/.test( declaration.type ) ? 'export' : 'import';
9840
10098
  module.error( {
9841
10099
  code: 'CANNOT_IMPORT_SELF',
9842
- message: `A module cannot import itself`
10100
+ message: `A module cannot ${declarationType} itself`
9843
10101
  }, declaration.start );
9844
10102
  }
9845
10103
 
@@ -10320,7 +10578,7 @@ function createCommonjsModule(fn, module) {
10320
10578
  * Licensed under the MIT license.
10321
10579
  */
10322
10580
 
10323
- var index$2 = function filenameRegex() {
10581
+ var filenameRegex = function filenameRegex() {
10324
10582
  return /([^\\\/]+)$/;
10325
10583
  };
10326
10584
 
@@ -10331,7 +10589,7 @@ var index$2 = function filenameRegex() {
10331
10589
  * Released under the MIT License.
10332
10590
  */
10333
10591
 
10334
- var index$6 = function (arr) {
10592
+ var arrFlatten = function (arr) {
10335
10593
  return flat(arr, []);
10336
10594
  };
10337
10595
 
@@ -10377,7 +10635,7 @@ function diff(arr, arrays) {
10377
10635
  }
10378
10636
 
10379
10637
  if (argsLen > 2) {
10380
- arrays = index$6(slice.call(arguments, 1));
10638
+ arrays = arrFlatten(slice.call(arguments, 1));
10381
10639
  }
10382
10640
 
10383
10641
  while (++i < len) {
@@ -10392,7 +10650,7 @@ function diff(arr, arrays) {
10392
10650
  * Expose `diff`
10393
10651
  */
10394
10652
 
10395
- var index$4 = diff;
10653
+ var arrDiff = diff;
10396
10654
 
10397
10655
  /*!
10398
10656
  * array-unique <https://github.com/jonschlinkert/array-unique>
@@ -10401,7 +10659,7 @@ var index$4 = diff;
10401
10659
  * Licensed under the MIT License.
10402
10660
  */
10403
10661
 
10404
- var index$8 = function unique(arr) {
10662
+ var arrayUnique = function unique(arr) {
10405
10663
  if (!Array.isArray(arr)) {
10406
10664
  throw new TypeError('array-unique expects an array.');
10407
10665
  }
@@ -10423,12 +10681,12 @@ var index$8 = function unique(arr) {
10423
10681
 
10424
10682
  var toString$1$1 = {}.toString;
10425
10683
 
10426
- var index$18 = Array.isArray || function (arr) {
10684
+ var isarray = Array.isArray || function (arr) {
10427
10685
  return toString$1$1.call(arr) == '[object Array]';
10428
10686
  };
10429
10687
 
10430
- var index$16 = function isObject(val) {
10431
- return val != null && typeof val === 'object' && index$18(val) === false;
10688
+ var isobject = function isObject(val) {
10689
+ return val != null && typeof val === 'object' && isarray(val) === false;
10432
10690
  };
10433
10691
 
10434
10692
  /*!
@@ -10440,7 +10698,7 @@ var index$16 = function isObject(val) {
10440
10698
 
10441
10699
  // The _isBuffer check is for Safari 5-7 support, because it's missing
10442
10700
  // Object.prototype.constructor. Remove this eventually
10443
- var index$24 = function (obj) {
10701
+ var isBuffer_1 = function (obj) {
10444
10702
  return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
10445
10703
  };
10446
10704
 
@@ -10462,7 +10720,7 @@ var toString$2 = Object.prototype.toString;
10462
10720
  * @return {*} Native javascript type
10463
10721
  */
10464
10722
 
10465
- var index$22 = function kindOf(val) {
10723
+ var kindOf = function kindOf(val) {
10466
10724
  // primitivies
10467
10725
  if (typeof val === 'undefined') {
10468
10726
  return 'undefined';
@@ -10515,7 +10773,7 @@ var index$22 = function kindOf(val) {
10515
10773
  }
10516
10774
 
10517
10775
  // buffer
10518
- if (index$24(val)) {
10776
+ if (isBuffer_1(val)) {
10519
10777
  return 'buffer';
10520
10778
  }
10521
10779
 
@@ -10569,8 +10827,8 @@ var index$22 = function kindOf(val) {
10569
10827
  return 'object';
10570
10828
  };
10571
10829
 
10572
- var index$20 = function isNumber(num) {
10573
- var type = index$22(num);
10830
+ var isNumber = function isNumber(num) {
10831
+ var type = kindOf(num);
10574
10832
  if (type !== 'number' && type !== 'string') {
10575
10833
  return false;
10576
10834
  }
@@ -10587,7 +10845,7 @@ var toString$3 = Object.prototype.toString;
10587
10845
  * @return {*} Native javascript type
10588
10846
  */
10589
10847
 
10590
- var index$30 = function kindOf(val) {
10848
+ var kindOf$2 = function kindOf(val) {
10591
10849
  // primitivies
10592
10850
  if (typeof val === 'undefined') {
10593
10851
  return 'undefined';
@@ -10640,7 +10898,7 @@ var index$30 = function kindOf(val) {
10640
10898
  }
10641
10899
 
10642
10900
  // buffer
10643
- if (index$24(val)) {
10901
+ if (isBuffer_1(val)) {
10644
10902
  return 'buffer';
10645
10903
  }
10646
10904
 
@@ -10694,8 +10952,8 @@ var index$30 = function kindOf(val) {
10694
10952
  return 'object';
10695
10953
  };
10696
10954
 
10697
- var index$28 = function isNumber(num) {
10698
- var type = index$30(num);
10955
+ var isNumber$2 = function isNumber(num) {
10956
+ var type = kindOf$2(num);
10699
10957
 
10700
10958
  if (type === 'string') {
10701
10959
  if (!num.trim()) return false;
@@ -10715,7 +10973,7 @@ var toString$4 = Object.prototype.toString;
10715
10973
  * @return {*} Native javascript type
10716
10974
  */
10717
10975
 
10718
- var index$32 = function kindOf(val) {
10976
+ var kindOf$4 = function kindOf(val) {
10719
10977
  // primitivies
10720
10978
  if (typeof val === 'undefined') {
10721
10979
  return 'undefined';
@@ -10771,7 +11029,7 @@ var index$32 = function kindOf(val) {
10771
11029
  }
10772
11030
 
10773
11031
  // buffer
10774
- if (index$24(val)) {
11032
+ if (isBuffer_1(val)) {
10775
11033
  return 'buffer';
10776
11034
  }
10777
11035
 
@@ -10829,7 +11087,7 @@ var index$32 = function kindOf(val) {
10829
11087
  * Expose `randomatic`
10830
11088
  */
10831
11089
 
10832
- var index$26 = randomatic;
11090
+ var randomatic_1 = randomatic;
10833
11091
 
10834
11092
  /**
10835
11093
  * Available mask characters
@@ -10865,12 +11123,12 @@ function randomatic(pattern, length, options) {
10865
11123
  if (typeof pattern === 'string') {
10866
11124
  length = pattern.length;
10867
11125
 
10868
- } else if (index$28(pattern)) {
11126
+ } else if (isNumber$2(pattern)) {
10869
11127
  options = {}; length = pattern; pattern = '*';
10870
11128
  }
10871
11129
  }
10872
11130
 
10873
- if (index$32(length) === 'object' && length.hasOwnProperty('chars')) {
11131
+ if (kindOf$4(length) === 'object' && length.hasOwnProperty('chars')) {
10874
11132
  options = length;
10875
11133
  pattern = options.chars;
10876
11134
  length = pattern.length;
@@ -10914,7 +11172,7 @@ var cache;
10914
11172
  * Expose `repeat`
10915
11173
  */
10916
11174
 
10917
- var index$34 = repeat;
11175
+ var repeatString = repeat;
10918
11176
 
10919
11177
  /**
10920
11178
  * Repeat the given `string` the specified `number`
@@ -10972,7 +11230,7 @@ function repeat(str, num) {
10972
11230
  * Licensed under the MIT license.
10973
11231
  */
10974
11232
 
10975
- var index$36 = function repeat(ele, num) {
11233
+ var repeatElement = function repeat(ele, num) {
10976
11234
  var arr = new Array(num);
10977
11235
 
10978
11236
  for (var i = 0; i < num; i++) {
@@ -10986,7 +11244,7 @@ var index$36 = function repeat(ele, num) {
10986
11244
  * Expose `fillRange`
10987
11245
  */
10988
11246
 
10989
- var index$14 = fillRange;
11247
+ var fillRange_1 = fillRange;
10990
11248
 
10991
11249
  /**
10992
11250
  * Return a range of numbers or letters.
@@ -11011,7 +11269,7 @@ function fillRange(a, b, step, options, fn) {
11011
11269
  fn = options; options = {};
11012
11270
  }
11013
11271
 
11014
- if (index$16(step)) {
11272
+ if (isobject(step)) {
11015
11273
  options = step; step = '';
11016
11274
  }
11017
11275
 
@@ -11046,11 +11304,11 @@ function fillRange(a, b, step, options, fn) {
11046
11304
 
11047
11305
  // repeat string
11048
11306
  if (m === '+') {
11049
- return index$36(a, b);
11307
+ return repeatElement(a, b);
11050
11308
 
11051
11309
  // randomize a, `b` times
11052
11310
  } else if (m === '?') {
11053
- return [index$26(a, b)];
11311
+ return [randomatic_1(a, b)];
11054
11312
 
11055
11313
  // expand right, no regex reduction
11056
11314
  } else if (m === '>') {
@@ -11073,7 +11331,7 @@ function fillRange(a, b, step, options, fn) {
11073
11331
  regex = true;
11074
11332
  sep$$1 = m;
11075
11333
  }
11076
- } else if (!index$20(step)) {
11334
+ } else if (!isNumber(step)) {
11077
11335
  if (!opts.silent) {
11078
11336
  throw new TypeError('fill-range: invalid step.');
11079
11337
  }
@@ -11098,8 +11356,8 @@ function fillRange(a, b, step, options, fn) {
11098
11356
  }
11099
11357
 
11100
11358
  // validate arguments
11101
- var isNumA = index$20(zeros(a));
11102
- var isNumB = index$20(zeros(b));
11359
+ var isNumA = isNumber(zeros(a));
11360
+ var isNumB = isNumber(zeros(b));
11103
11361
 
11104
11362
  if ((!isNumA && isNumB) || (isNumA && !isNumB)) {
11105
11363
  if (!opts.silent) {
@@ -11362,7 +11620,7 @@ function isPadded(origA, origB) {
11362
11620
  : blen;
11363
11621
 
11364
11622
  return function (a) {
11365
- return index$34('0', len - length(a));
11623
+ return repeatString('0', len - length(a));
11366
11624
  };
11367
11625
  }
11368
11626
  return false;
@@ -11376,7 +11634,7 @@ function length(val) {
11376
11634
  return val.toString().length;
11377
11635
  }
11378
11636
 
11379
- var index$12 = function expandRange(str, options, fn) {
11637
+ var expandRange = function expandRange(str, options, fn) {
11380
11638
  if (typeof str !== 'string') {
11381
11639
  throw new TypeError('expand-range expects a string.');
11382
11640
  }
@@ -11406,7 +11664,7 @@ var index$12 = function expandRange(str, options, fn) {
11406
11664
  }
11407
11665
 
11408
11666
  args.push(opts);
11409
- return index$14.apply(null, args.concat(fn));
11667
+ return fillRange_1.apply(null, args.concat(fn));
11410
11668
  };
11411
11669
 
11412
11670
  /*!
@@ -11462,7 +11720,7 @@ function randomize$1() {
11462
11720
 
11463
11721
  var cache$1 = {};
11464
11722
 
11465
- var index$38 = {
11723
+ var preserve = {
11466
11724
  before: before,
11467
11725
  after: after
11468
11726
  };
@@ -11479,7 +11737,7 @@ var index$38 = {
11479
11737
  * Expose `braces`
11480
11738
  */
11481
11739
 
11482
- var index$10 = function(str, options) {
11740
+ var braces_1 = function(str, options) {
11483
11741
  if (typeof str !== 'string') {
11484
11742
  throw new Error('braces expects a string');
11485
11743
  }
@@ -11549,7 +11807,7 @@ function braces(str, arr, options) {
11549
11807
  return arr.concat(str);
11550
11808
  } else {
11551
11809
  es6 = true;
11552
- str = index$38.before(str, es6Regex());
11810
+ str = preserve.before(str, es6Regex());
11553
11811
  }
11554
11812
  }
11555
11813
 
@@ -11569,7 +11827,7 @@ function braces(str, arr, options) {
11569
11827
  var segs, segsLength;
11570
11828
 
11571
11829
  if (inner.indexOf('..') !== -1) {
11572
- segs = index$12(inner, opts, fn) || inner.split(',');
11830
+ segs = expandRange(inner, opts, fn) || inner.split(',');
11573
11831
  segsLength = segs.length;
11574
11832
 
11575
11833
  } else if (inner[0] === '"' || inner[0] === '\'') {
@@ -11607,7 +11865,7 @@ function braces(str, arr, options) {
11607
11865
  arr = braces(val, arr, opts);
11608
11866
  } else if (val !== '') {
11609
11867
  if (opts.nodupes && arr.indexOf(val) !== -1) { continue; }
11610
- arr.push(es6 ? index$38.after(val) : val);
11868
+ arr.push(es6 ? preserve.after(val) : val);
11611
11869
  }
11612
11870
  }
11613
11871
 
@@ -11657,7 +11915,7 @@ function exponential(str, options, fn) {
11657
11915
 
11658
11916
  } else {
11659
11917
  var num = Math.pow(2, exp);
11660
- arr.push.apply(arr, index$36(ele, num));
11918
+ arr.push.apply(arr, repeatElement(ele, num));
11661
11919
  }
11662
11920
  }
11663
11921
  }
@@ -11865,7 +12123,7 @@ function filter$1(arr, cb) {
11865
12123
  * Licensed under the MIT License.
11866
12124
  */
11867
12125
 
11868
- var index$42 = function isPosixBracket(str) {
12126
+ var isPosixBracket = function isPosixBracket(str) {
11869
12127
  return typeof str === 'string' && /\[([:.=+])(?:[^\[\]]|)+\1\]/.test(str);
11870
12128
  };
11871
12129
 
@@ -11893,10 +12151,10 @@ var POSIX = {
11893
12151
  * Expose `brackets`
11894
12152
  */
11895
12153
 
11896
- var index$40 = brackets;
12154
+ var expandBrackets = brackets;
11897
12155
 
11898
12156
  function brackets(str) {
11899
- if (!index$42(str)) {
12157
+ if (!isPosixBracket(str)) {
11900
12158
  return str;
11901
12159
  }
11902
12160
 
@@ -12029,7 +12287,7 @@ brackets.match = function(arr, pattern) {
12029
12287
  * Licensed under the MIT License.
12030
12288
  */
12031
12289
 
12032
- var index$46 = function isExtglob(str) {
12290
+ var isExtglob = function isExtglob(str) {
12033
12291
  return typeof str === 'string'
12034
12292
  && /[@?!+*]\(/.test(str);
12035
12293
  };
@@ -12046,7 +12304,7 @@ var cache$2 = {};
12046
12304
  * Expose `extglob`
12047
12305
  */
12048
12306
 
12049
- var index$44 = extglob;
12307
+ var extglob_1 = extglob;
12050
12308
 
12051
12309
  /**
12052
12310
  * Convert the given extglob `string` to a regex-compatible
@@ -12214,15 +12472,15 @@ function toRegex$1(pattern, contains, isNegated) {
12214
12472
 
12215
12473
 
12216
12474
 
12217
- var index$48 = function isGlob(str) {
12475
+ var isGlob = function isGlob(str) {
12218
12476
  return typeof str === 'string'
12219
12477
  && (/[*!?{}(|)[\]]/.test(str)
12220
- || index$46(str));
12478
+ || isExtglob(str));
12221
12479
  };
12222
12480
 
12223
12481
  var isWin = process.platform === 'win32';
12224
12482
 
12225
- var index$52 = function (str) {
12483
+ var removeTrailingSeparator = function (str) {
12226
12484
  var i = str.length - 1;
12227
12485
  if (i < 2) {
12228
12486
  return str;
@@ -12247,13 +12505,13 @@ function isSeparator(str, i) {
12247
12505
 
12248
12506
 
12249
12507
 
12250
- var index$50 = function normalizePath(str, stripTrailing) {
12508
+ var normalizePath = function normalizePath(str, stripTrailing) {
12251
12509
  if (typeof str !== 'string') {
12252
12510
  throw new TypeError('expected a string');
12253
12511
  }
12254
12512
  str = str.replace(/[\\\/]+/g, '/');
12255
12513
  if (stripTrailing !== false) {
12256
- str = index$52(str);
12514
+ str = removeTrailingSeparator(str);
12257
12515
  }
12258
12516
  return str;
12259
12517
  };
@@ -12265,7 +12523,7 @@ var index$50 = function normalizePath(str, stripTrailing) {
12265
12523
  * Licensed under the MIT License.
12266
12524
  */
12267
12525
 
12268
- var index$56 = function isExtendable(val) {
12526
+ var isExtendable = function isExtendable(val) {
12269
12527
  return typeof val !== 'undefined' && val !== null
12270
12528
  && (typeof val === 'object' || typeof val === 'function');
12271
12529
  };
@@ -12277,7 +12535,7 @@ var index$56 = function isExtendable(val) {
12277
12535
  * Released under the MIT License.
12278
12536
  */
12279
12537
 
12280
- var index$60 = function forIn(obj, fn, thisArg) {
12538
+ var forIn = function forIn(obj, fn, thisArg) {
12281
12539
  for (var key in obj) {
12282
12540
  if (fn.call(thisArg, obj[key], key, obj) === false) {
12283
12541
  break;
@@ -12287,16 +12545,16 @@ var index$60 = function forIn(obj, fn, thisArg) {
12287
12545
 
12288
12546
  var hasOwn = Object.prototype.hasOwnProperty;
12289
12547
 
12290
- var index$58 = function forOwn(obj, fn, thisArg) {
12291
- index$60(obj, function(val, key) {
12548
+ var forOwn$1 = function forOwn(obj, fn, thisArg) {
12549
+ forIn(obj, function(val, key) {
12292
12550
  if (hasOwn.call(obj, key)) {
12293
12551
  return fn.call(thisArg, obj[key], key, obj);
12294
12552
  }
12295
12553
  });
12296
12554
  };
12297
12555
 
12298
- var index$54 = function omit(obj, keys) {
12299
- if (!index$56(obj)) return {};
12556
+ var object_omit = function omit(obj, keys) {
12557
+ if (!isExtendable(obj)) return {};
12300
12558
 
12301
12559
  keys = [].concat.apply([], [].slice.call(arguments, 1));
12302
12560
  var last = keys[keys.length - 1];
@@ -12311,7 +12569,7 @@ var index$54 = function omit(obj, keys) {
12311
12569
  return obj;
12312
12570
  }
12313
12571
 
12314
- index$58(obj, function(value, key) {
12572
+ forOwn$1(obj, function(value, key) {
12315
12573
  if (keys.indexOf(key) === -1) {
12316
12574
 
12317
12575
  if (!isFunction) {
@@ -12324,20 +12582,20 @@ var index$54 = function omit(obj, keys) {
12324
12582
  return res;
12325
12583
  };
12326
12584
 
12327
- var index$66 = function globParent(str) {
12585
+ var globParent = function globParent(str) {
12328
12586
  str += 'a'; // preserves full path in case of trailing path separator
12329
- do {str = path.dirname(str);} while (index$48(str));
12587
+ do {str = path.dirname(str);} while (isGlob(str));
12330
12588
  return str;
12331
12589
  };
12332
12590
 
12333
- var index$64 = function globBase(pattern) {
12591
+ var globBase = function globBase(pattern) {
12334
12592
  if (typeof pattern !== 'string') {
12335
12593
  throw new TypeError('glob-base expects a string.');
12336
12594
  }
12337
12595
 
12338
12596
  var res = {};
12339
- res.base = index$66(pattern);
12340
- res.isGlob = index$48(pattern);
12597
+ res.base = globParent(pattern);
12598
+ res.isGlob = isGlob(pattern);
12341
12599
 
12342
12600
  if (res.base !== '.') {
12343
12601
  res.glob = pattern.substr(res.base.length);
@@ -12376,7 +12634,7 @@ function dirname$1(glob) {
12376
12634
  * Released under the MIT License.
12377
12635
  */
12378
12636
 
12379
- var index$68 = function(str) {
12637
+ var isDotfile = function(str) {
12380
12638
  if (str.charCodeAt(0) === 46 /* . */ && str.indexOf('/', 1) === -1) {
12381
12639
  return true;
12382
12640
  }
@@ -12384,7 +12642,7 @@ var index$68 = function(str) {
12384
12642
  return slash !== -1 ? str.charCodeAt(slash + 1) === 46 /* . */ : false;
12385
12643
  };
12386
12644
 
12387
- var index$62 = createCommonjsModule(function (module) {
12645
+ var parseGlob = createCommonjsModule(function (module) {
12388
12646
  /*!
12389
12647
  * parse-glob <https://github.com/jonschlinkert/parse-glob>
12390
12648
  *
@@ -12429,7 +12687,7 @@ module.exports = function parseGlob(glob) {
12429
12687
  // unescape dots and slashes in braces/brackets
12430
12688
  glob = escape(glob);
12431
12689
 
12432
- var parsed = index$64(glob);
12690
+ var parsed = globBase(glob);
12433
12691
  tok.is.glob = parsed.isGlob;
12434
12692
 
12435
12693
  tok.glob = parsed.glob;
@@ -12445,7 +12703,7 @@ module.exports = function parseGlob(glob) {
12445
12703
  tok.path.extname = basename$$1.slice(1).join('.') || '';
12446
12704
  tok.path.ext = '';
12447
12705
 
12448
- if (index$48(tok.path.dirname) && !tok.path.basename) {
12706
+ if (isGlob(tok.path.dirname) && !tok.path.basename) {
12449
12707
  if (!/\/$/.test(tok.glob)) {
12450
12708
  tok.path.basename = tok.glob;
12451
12709
  }
@@ -12478,11 +12736,11 @@ module.exports = function parseGlob(glob) {
12478
12736
  // Booleans
12479
12737
  var is = (glob && tok.is.glob);
12480
12738
  tok.is.negated = glob && glob.charAt(0) === '!';
12481
- tok.is.extglob = glob && index$46(glob);
12739
+ tok.is.extglob = glob && isExtglob(glob);
12482
12740
  tok.is.braces = has(is, glob, '{');
12483
12741
  tok.is.brackets = has(is, glob, '[:');
12484
12742
  tok.is.globstar = has(is, glob, '**');
12485
- tok.is.dotfile = index$68(tok.path.basename) || index$68(tok.path.filename);
12743
+ tok.is.dotfile = isDotfile(tok.path.basename) || isDotfile(tok.path.filename);
12486
12744
  tok.is.dotdir = dotdir(tok.path.dirname);
12487
12745
  return (cache[glob] = tok);
12488
12746
  };
@@ -12551,18 +12809,18 @@ function unescape(str) {
12551
12809
  */
12552
12810
 
12553
12811
  // see http://jsperf.com/testing-value-is-primitive/7
12554
- var index$72 = function isPrimitive(value) {
12812
+ var isPrimitive = function isPrimitive(value) {
12555
12813
  return value == null || (typeof value !== 'function' && typeof value !== 'object');
12556
12814
  };
12557
12815
 
12558
- var index$74 = function isEqual(a, b) {
12816
+ var isEqualShallow = function isEqual(a, b) {
12559
12817
  if (!a && !b) { return true; }
12560
12818
  if (!a && b || a && !b) { return false; }
12561
12819
 
12562
12820
  var numKeysA = 0, numKeysB = 0, key;
12563
12821
  for (key in b) {
12564
12822
  numKeysB++;
12565
- if (!index$72(b[key]) || !a.hasOwnProperty(key) || (a[key] !== b[key])) {
12823
+ if (!isPrimitive(b[key]) || !a.hasOwnProperty(key) || (a[key] !== b[key])) {
12566
12824
  return false;
12567
12825
  }
12568
12826
  }
@@ -12579,7 +12837,7 @@ var cache$3 = {};
12579
12837
  * Expose `regexCache`
12580
12838
  */
12581
12839
 
12582
- var index$70 = regexCache;
12840
+ var regexCache_1 = regexCache;
12583
12841
 
12584
12842
  /**
12585
12843
  * Memoize the results of a call to the new RegExp constructor.
@@ -12612,7 +12870,7 @@ function regexCache(fn, str, opts) {
12612
12870
  }
12613
12871
 
12614
12872
  cached = cache$3[key];
12615
- if (cached && index$74(cached.opts, opts)) {
12873
+ if (cached && isEqualShallow(cached.opts, opts)) {
12616
12874
  return cached.regex;
12617
12875
  }
12618
12876
 
@@ -12631,8 +12889,8 @@ function memo(key, opts, regex) {
12631
12889
  var cache_1 = cache$3;
12632
12890
  var basic_1 = basic;
12633
12891
 
12634
- index$70.cache = cache_1;
12635
- index$70.basic = basic_1;
12892
+ regexCache_1.cache = cache_1;
12893
+ regexCache_1.basic = basic_1;
12636
12894
 
12637
12895
  var utils_1 = createCommonjsModule(function (module) {
12638
12896
  'use strict';
@@ -12646,18 +12904,18 @@ var utils = module.exports;
12646
12904
  * Module dependencies
12647
12905
  */
12648
12906
 
12649
- utils.diff = index$4;
12650
- utils.unique = index$8;
12651
- utils.braces = index$10;
12652
- utils.brackets = index$40;
12653
- utils.extglob = index$44;
12654
- utils.isExtglob = index$46;
12655
- utils.isGlob = index$48;
12656
- utils.typeOf = index$22;
12657
- utils.normalize = index$50;
12658
- utils.omit = index$54;
12659
- utils.parseGlob = index$62;
12660
- utils.cache = index$70;
12907
+ utils.diff = arrDiff;
12908
+ utils.unique = arrayUnique;
12909
+ utils.braces = braces_1;
12910
+ utils.brackets = expandBrackets;
12911
+ utils.extglob = extglob_1;
12912
+ utils.isExtglob = isExtglob;
12913
+ utils.isGlob = isGlob;
12914
+ utils.typeOf = kindOf;
12915
+ utils.normalize = normalizePath;
12916
+ utils.omit = object_omit;
12917
+ utils.parseGlob = parseGlob;
12918
+ utils.cache = regexCache_1;
12661
12919
 
12662
12920
  /**
12663
12921
  * Get the filename of a filepath
@@ -12667,7 +12925,7 @@ utils.cache = index$70;
12667
12925
  */
12668
12926
 
12669
12927
  utils.filename = function filename(fp) {
12670
- var seg = fp.match(index$2());
12928
+ var seg = fp.match(filenameRegex());
12671
12929
  return seg && seg[0];
12672
12930
  };
12673
12931
 
@@ -13761,7 +14019,7 @@ micromatch.matchKeys = matchKeys;
13761
14019
  * Expose `micromatch`
13762
14020
  */
13763
14021
 
13764
- var index$1 = micromatch;
14022
+ var micromatch_1 = micromatch;
13765
14023
 
13766
14024
  function ensureArray$1 ( thing ) {
13767
14025
  if ( Array.isArray( thing ) ) return thing;
@@ -13770,7 +14028,7 @@ function ensureArray$1 ( thing ) {
13770
14028
  }
13771
14029
 
13772
14030
  function createFilter ( include, exclude ) {
13773
- const getMatcher = id => ( isRegexp( id ) ? id : { test: index$1.matcher( resolve( id ) ) } );
14031
+ const getMatcher = id => ( isRegexp( id ) ? id : { test: micromatch_1.matcher( resolve( id ) ) } );
13774
14032
  include = ensureArray$1( include ).map( getMatcher );
13775
14033
  exclude = ensureArray$1( exclude ).map( getMatcher );
13776
14034
 
@@ -13824,12 +14082,12 @@ requireRelative.resolve = function(requested, relativeTo) {
13824
14082
  return module$1._resolveFilename(requested, root);
13825
14083
  };
13826
14084
 
13827
- var index$76 = requireRelative;
14085
+ var requireRelative_1$1 = requireRelative;
13828
14086
 
13829
14087
  let chokidar;
13830
14088
 
13831
14089
  try {
13832
- chokidar = index$76( 'chokidar', process.cwd() );
14090
+ chokidar = requireRelative_1$1( 'chokidar', process.cwd() );
13833
14091
  } catch (err) {
13834
14092
  chokidar = null;
13835
14093
  }
@@ -14165,7 +14423,7 @@ function watch$1(configs) {
14165
14423
  return new Watcher(configs);
14166
14424
  }
14167
14425
 
14168
- var version$1 = "0.49.3";
14426
+ var version$1 = "0.50.0";
14169
14427
 
14170
14428
  export { rollup, watch$1 as watch, version$1 as VERSION };
14171
14429
  //# sourceMappingURL=rollup.es.js.map