diff --git a/src/finalisers/iife.js b/src/finalisers/iife.js index c497c2c..95c6d65 100644 --- a/src/finalisers/iife.js +++ b/src/finalisers/iife.js @@ -36,7 +36,7 @@ export default function iife ( bundle, magicString, { exportMode, indentString } } const useStrict = options.useStrict !== false ? `'use strict';` : ``; - if ( useStrict ) magicString.prepend( useStrict + '\n\n' ); + let intro = `(function (${args}) {\n`; let outro = `\n\n}(${dependencies}));`; @@ -51,7 +51,7 @@ export default function iife ( bundle, magicString, { exportMode, indentString } // var foo__default = 'default' in foo ? foo['default'] : foo; const interopBlock = getInteropBlock( bundle ); if ( interopBlock ) magicString.prepend( interopBlock + '\n\n' ); - + if ( useStrict ) magicString.prepend( useStrict + '\n\n' ); const exportBlock = getExportBlock( bundle.entryModule, exportMode ); if ( exportBlock ) magicString.append( '\n\n' + exportBlock ); diff --git a/test/form/indent-false/_expected/iife.js b/test/form/indent-false/_expected/iife.js index c6a9331..54ba717 100644 --- a/test/form/indent-false/_expected/iife.js +++ b/test/form/indent-false/_expected/iife.js @@ -1,5 +1,5 @@ var foo = (function () { - 'use strict'; +'use strict'; function foo () { console.log( 'indented with tabs' ); diff --git a/test/form/indent-true-spaces/_expected/iife.js b/test/form/indent-true-spaces/_expected/iife.js index d4abc78..e22164f 100644 --- a/test/form/indent-true-spaces/_expected/iife.js +++ b/test/form/indent-true-spaces/_expected/iife.js @@ -1,5 +1,5 @@ var foo = (function () { - 'use strict'; + 'use strict'; function foo () { console.log( 'indented with spaces' ); diff --git a/test/form/sourcemaps-inline/_expected/iife.js b/test/form/sourcemaps-inline/_expected/iife.js index c02953f..dc4202f 100644 --- a/test/form/sourcemaps-inline/_expected/iife.js +++ b/test/form/sourcemaps-inline/_expected/iife.js @@ -1,4 +1,5 @@ -(function () { 'use strict'; +(function () { + 'use strict'; function foo () { console.log( 'hello from foo.js' ); @@ -13,5 +14,5 @@ foo(); bar(); -})(); +}()); //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaWlmZS5qcyIsInNvdXJjZXMiOlsiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIiwiLi4vbWFpbi5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBmb28gKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gZm9vLmpzJyApO1xufVxuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gYmFyICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGJhci5qcycgKTtcbn1cbiIsImltcG9ydCBmb28gZnJvbSAnLi9mb28nO1xuaW1wb3J0IGJhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0NBQWUsU0FBUyxHQUFHLElBQUk7QUFDL0IsQ0FBQSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQztBQUNwQyxDQUFBLENBQUM7O0NDRmMsU0FBUyxHQUFHLElBQUk7QUFDL0IsQ0FBQSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQztBQUNwQyxDQUFBLENBQUM7O0NDQ0QsT0FBTyxDQUFDLEdBQUcsRUFBRSxvQkFBb0IsRUFBRSxDQUFDOztBQUVwQyxDQUFBLEdBQUcsRUFBRSxDQUFDO0FBQ04sQ0FBQSxHQUFHLEVBQUUsQ0FBQyw7OyJ9 \ No newline at end of file diff --git a/test/form/sourcemaps/_expected/iife.js b/test/form/sourcemaps/_expected/iife.js index 683379d..b45e3e8 100644 --- a/test/form/sourcemaps/_expected/iife.js +++ b/test/form/sourcemaps/_expected/iife.js @@ -1,4 +1,5 @@ -(function () { 'use strict'; +(function () { + 'use strict'; function foo () { console.log( 'hello from foo.js' ); @@ -13,5 +14,5 @@ foo(); bar(); -})(); +}()); //# sourceMappingURL=iife.js.map \ No newline at end of file diff --git a/test/form/spacing-after-function-with-semicolon/_expected/iife.js b/test/form/spacing-after-function-with-semicolon/_expected/iife.js index ea1be49..7ff78ec 100644 --- a/test/form/spacing-after-function-with-semicolon/_expected/iife.js +++ b/test/form/spacing-after-function-with-semicolon/_expected/iife.js @@ -1,7 +1,8 @@ -(function () { 'use strict'; +(function () { + 'use strict'; function x () { return 'x' }; assert.equal( x(), 'x' ); -})(); +}()); diff --git a/test/form/string-indentation-b/_expected/iife.js b/test/form/string-indentation-b/_expected/iife.js index 0ffdcbe..ae8c969 100644 --- a/test/form/string-indentation-b/_expected/iife.js +++ b/test/form/string-indentation-b/_expected/iife.js @@ -1,8 +1,9 @@ -(function () { 'use strict'; +(function () { + 'use strict'; var a = 'a'; var b = 'b'; assert.equal( a, 'a' ); assert.equal( b, 'b' ); -})(); \ No newline at end of file +}()); \ No newline at end of file diff --git a/test/form/string-indentation/_expected/iife.js b/test/form/string-indentation/_expected/iife.js index 47c6737..c2426fa 100644 --- a/test/form/string-indentation/_expected/iife.js +++ b/test/form/string-indentation/_expected/iife.js @@ -1,4 +1,5 @@ -(function () { 'use strict'; +(function () { + 'use strict'; var a = '1\ 2'; @@ -17,4 +18,4 @@ assert.equal( c, '1\n 2' ); assert.equal( d, '1\n\t2' ); -})(); +}()); diff --git a/test/form/unmodified-default-exports-function-argument/_expected/iife.js b/test/form/unmodified-default-exports-function-argument/_expected/iife.js index 9fb882d..c21e450 100644 --- a/test/form/unmodified-default-exports-function-argument/_expected/iife.js +++ b/test/form/unmodified-default-exports-function-argument/_expected/iife.js @@ -1,4 +1,5 @@ -(function () { 'use strict'; +(function () { + 'use strict'; var foo = function () { return 42; @@ -13,4 +14,4 @@ console.log( answer ); -})(); +}()); diff --git a/test/form/unmodified-default-exports/_expected/iife.js b/test/form/unmodified-default-exports/_expected/iife.js index 2942fdd..c07ff1a 100644 --- a/test/form/unmodified-default-exports/_expected/iife.js +++ b/test/form/unmodified-default-exports/_expected/iife.js @@ -1,4 +1,5 @@ -(function () { 'use strict'; +(function () { + 'use strict'; var Foo = function () { this.isFoo = true; @@ -12,4 +13,4 @@ var foo = new Foo(); -})(); +}()); diff --git a/test/form/unused-default-exports/_expected/iife.js b/test/form/unused-default-exports/_expected/iife.js index a745745..2c6a515 100644 --- a/test/form/unused-default-exports/_expected/iife.js +++ b/test/form/unused-default-exports/_expected/iife.js @@ -1,4 +1,5 @@ -(function () { 'use strict'; +(function () { + 'use strict'; var foo = { value: 1 }; @@ -11,4 +12,4 @@ assert.equal( foo.value, 2 ); -})(); +}());