diff --git a/src/ast/nodes/ExportDefaultDeclaration.js b/src/ast/nodes/ExportDefaultDeclaration.js index ab4a776..81ae1c9 100644 --- a/src/ast/nodes/ExportDefaultDeclaration.js +++ b/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 diff --git a/test/form/removes-existing-sourcemap-comments/_expected/amd.js b/test/form/removes-existing-sourcemap-comments/_expected/amd.js index 99bdf35..b89e399 100644 --- a/test/form/removes-existing-sourcemap-comments/_expected/amd.js +++ b/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() ); diff --git a/test/form/removes-existing-sourcemap-comments/_expected/cjs.js b/test/form/removes-existing-sourcemap-comments/_expected/cjs.js index 8735c93..1152d76 100644 --- a/test/form/removes-existing-sourcemap-comments/_expected/cjs.js +++ b/test/form/removes-existing-sourcemap-comments/_expected/cjs.js @@ -2,6 +2,6 @@ var foo = function () { return 42; -} +}; console.log( foo() ); diff --git a/test/form/removes-existing-sourcemap-comments/_expected/es.js b/test/form/removes-existing-sourcemap-comments/_expected/es.js index 2a09cfb..0ef1000 100644 --- a/test/form/removes-existing-sourcemap-comments/_expected/es.js +++ b/test/form/removes-existing-sourcemap-comments/_expected/es.js @@ -1,5 +1,5 @@ var foo = function () { return 42; -} +}; console.log( foo() ); diff --git a/test/form/removes-existing-sourcemap-comments/_expected/iife.js b/test/form/removes-existing-sourcemap-comments/_expected/iife.js index 6381613..cac12fb 100644 --- a/test/form/removes-existing-sourcemap-comments/_expected/iife.js +++ b/test/form/removes-existing-sourcemap-comments/_expected/iife.js @@ -3,7 +3,7 @@ var foo = function () { return 42; - } + }; console.log( foo() ); diff --git a/test/form/removes-existing-sourcemap-comments/_expected/umd.js b/test/form/removes-existing-sourcemap-comments/_expected/umd.js index b291566..9a6706d 100644 --- a/test/form/removes-existing-sourcemap-comments/_expected/umd.js +++ b/test/form/removes-existing-sourcemap-comments/_expected/umd.js @@ -6,7 +6,7 @@ var foo = function () { return 42; - } + }; console.log( foo() ); diff --git a/test/function/adds-semicolons-if-necessary-c/_config.js b/test/function/adds-semicolons-if-necessary-c/_config.js new file mode 100644 index 0000000..bb17123 --- /dev/null +++ b/test/function/adds-semicolons-if-necessary-c/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'adds semi-colons if necessary' +}; diff --git a/test/function/adds-semicolons-if-necessary-c/foo.js b/test/function/adds-semicolons-if-necessary-c/foo.js new file mode 100644 index 0000000..7dc8833 --- /dev/null +++ b/test/function/adds-semicolons-if-necessary-c/foo.js @@ -0,0 +1,3 @@ +export default function () { + return 42; +} diff --git a/test/function/adds-semicolons-if-necessary-c/main.js b/test/function/adds-semicolons-if-necessary-c/main.js new file mode 100644 index 0000000..ae0bdb2 --- /dev/null +++ b/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 );