Browse Source

Style iife

gh-438-b
mnater 9 years ago
parent
commit
20a9923e98
  1. 7
      src/finalisers/iife.js
  2. 5
      test/form/banner-and-footer-plugin/_expected/iife.js
  3. 5
      test/form/banner-and-footer/_expected/iife.js
  4. 5
      test/form/block-comments/_expected/iife.js
  5. 5
      test/form/dedupes-external-imports/_expected/iife.js
  6. 5
      test/form/exclude-unnecessary-modifications/_expected/iife.js

7
src/finalisers/iife.js

@ -35,9 +35,10 @@ export default function iife ( bundle, magicString, { exportMode, indentString }
args.unshift( 'exports' );
}
const useStrict = options.useStrict !== false ? ` 'use strict';` : ``;
let intro = `(function (${args}) {${useStrict}\n\n`;
let outro = `\n\n})(${dependencies});`;
const useStrict = options.useStrict !== false ? `'use strict';` : ``;
if ( useStrict ) magicString.prepend( useStrict + '\n\n' );
let intro = `(function (${args}) {\n`;
let outro = `\n\n}(${dependencies}));`;
if ( exportMode === 'default' ) {
intro = ( isNamespaced ? `this.` : `var ` ) + `${name} = ${intro}`;

5
test/form/banner-and-footer-plugin/_expected/iife.js

@ -1,9 +1,10 @@
/* first banner */
/* second banner */
(function () { 'use strict';
(function () {
'use strict';
console.log( 1 + 1 );
})();
}());
/* first footer */
/* second footer */

5
test/form/banner-and-footer/_expected/iife.js

@ -1,7 +1,8 @@
/* this is a banner */
(function () { 'use strict';
(function () {
'use strict';
console.log( 'hello world' );
})();
}());
/* this is a footer */

5
test/form/block-comments/_expected/iife.js

@ -1,4 +1,5 @@
(function () { 'use strict';
(function () {
'use strict';
function foo () {
return embiggen( 6, 7 );
@ -16,4 +17,4 @@
alert( foo() );
})();
}());

5
test/form/dedupes-external-imports/_expected/iife.js

@ -1,4 +1,5 @@
(function (exports,external) { 'use strict';
(function (exports,external) {
'use strict';
class Foo extends external.Component {
constructor () {
@ -29,4 +30,4 @@
exports.bar = bar;
exports.baz = baz;
})((this.myBundle = {}),external);
}((this.myBundle = {}),external));

5
test/form/exclude-unnecessary-modifications/_expected/iife.js

@ -1,4 +1,5 @@
(function () { 'use strict';
(function () {
'use strict';
var foo = {};
@ -25,4 +26,4 @@
console.log( foo );
})();
}());

Loading…
Cancel
Save