Browse Source

include default exports in ASI

legacy-quote-reserved-properties
Rich-Harris 8 years ago
parent
commit
40643bf543
  1. 2
      src/ast/nodes/ExportDefaultDeclaration.js
  2. 2
      test/form/removes-existing-sourcemap-comments/_expected/amd.js
  3. 2
      test/form/removes-existing-sourcemap-comments/_expected/cjs.js
  4. 2
      test/form/removes-existing-sourcemap-comments/_expected/es.js
  5. 2
      test/form/removes-existing-sourcemap-comments/_expected/iife.js
  6. 2
      test/form/removes-existing-sourcemap-comments/_expected/umd.js
  7. 3
      test/function/adds-semicolons-if-necessary-c/_config.js
  8. 3
      test/function/adds-semicolons-if-necessary-c/foo.js
  9. 7
      test/function/adds-semicolons-if-necessary-c/main.js

2
src/ast/nodes/ExportDefaultDeclaration.js

@ -67,6 +67,8 @@ export default class ExportDefaultDeclaration extends Node {
} else {
code.overwrite( this.start, this.declaration.start, `${this.module.bundle.varOrConst} ${name} = ` );
}
this.insertSemicolon( code );
}
} else {
// remove `var foo` from `var foo = bar()`, if `foo` is unused

2
test/form/removes-existing-sourcemap-comments/_expected/amd.js

@ -2,7 +2,7 @@ define(function () { 'use strict';
var foo = function () {
return 42;
}
};
console.log( foo() );

2
test/form/removes-existing-sourcemap-comments/_expected/cjs.js

@ -2,6 +2,6 @@
var foo = function () {
return 42;
}
};
console.log( foo() );

2
test/form/removes-existing-sourcemap-comments/_expected/es.js

@ -1,5 +1,5 @@
var foo = function () {
return 42;
}
};
console.log( foo() );

2
test/form/removes-existing-sourcemap-comments/_expected/iife.js

@ -3,7 +3,7 @@
var foo = function () {
return 42;
}
};
console.log( foo() );

2
test/form/removes-existing-sourcemap-comments/_expected/umd.js

@ -6,7 +6,7 @@
var foo = function () {
return 42;
}
};
console.log( foo() );

3
test/function/adds-semicolons-if-necessary-c/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'adds semi-colons if necessary'
};

3
test/function/adds-semicolons-if-necessary-c/foo.js

@ -0,0 +1,3 @@
export default function () {
return 42;
}

7
test/function/adds-semicolons-if-necessary-c/main.js

@ -0,0 +1,7 @@
import foo from './foo.js';
(function bar() {
assert.ok( true );
})();
assert.equal( foo(), 42 );
Loading…
Cancel
Save