Browse Source

Style iife

gh-438-b
mnater 9 years ago
parent
commit
bc8a78d862
  1. 4
      src/finalisers/iife.js
  2. 2
      test/form/indent-false/_expected/iife.js
  3. 2
      test/form/indent-true-spaces/_expected/iife.js
  4. 5
      test/form/sourcemaps-inline/_expected/iife.js
  5. 5
      test/form/sourcemaps/_expected/iife.js
  6. 5
      test/form/spacing-after-function-with-semicolon/_expected/iife.js
  7. 5
      test/form/string-indentation-b/_expected/iife.js
  8. 5
      test/form/string-indentation/_expected/iife.js
  9. 5
      test/form/unmodified-default-exports-function-argument/_expected/iife.js
  10. 5
      test/form/unmodified-default-exports/_expected/iife.js
  11. 5
      test/form/unused-default-exports/_expected/iife.js

4
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 );

2
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' );

2
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' );

5
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

5
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

5
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' );
})();
}());

5
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' );
})();
}());

5
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' );
})();
}());

5
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 );
})();
}());

5
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();
})();
}());

5
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 );
})();
}());

Loading…
Cancel
Save