Browse Source

use options.indent for UMD block - fixes #797

gh-1187
Rich-Harris 8 years ago
parent
commit
101ad286b5
  1. 2
      src/finalisers/umd.js
  2. 2
      test/form/indent-false/_expected/amd.js
  3. 2
      test/form/indent-false/_expected/cjs.js
  4. 2
      test/form/indent-false/_expected/es.js
  5. 2
      test/form/indent-false/_expected/iife.js
  6. 2
      test/form/indent-false/_expected/umd.js
  7. 2
      test/form/indent-false/main.js
  8. 7
      test/form/indent-spaces/_config.js
  9. 9
      test/form/indent-spaces/_expected/amd.js
  10. 7
      test/form/indent-spaces/_expected/cjs.js
  11. 5
      test/form/indent-spaces/_expected/es.js
  12. 10
      test/form/indent-spaces/_expected/iife.js
  13. 13
      test/form/indent-spaces/_expected/umd.js
  14. 3
      test/form/indent-spaces/main.js

2
src/finalisers/umd.js

@ -78,7 +78,7 @@ export default function umd ( bundle, magicString, { exportMode, indentString, i
${globalExport};
}(this, (function (${args}) {${useStrict}
`.replace( /^\t\t/gm, '' ).replace( /^\t/gm, magicString.getIndentString() );
`.replace( /^\t\t/gm, '' ).replace( /^\t/gm, indentString || '\t' );
// var foo__default = 'default' in foo ? foo['default'] : foo;
const interopBlock = getInteropBlock( bundle, options );

2
test/form/indent-false/_expected/amd.js

@ -1,7 +1,7 @@
define(function () { 'use strict';
function foo () {
console.log( 'indented with tabs' );
console.log( 'not indented' );
}
return foo;

2
test/form/indent-false/_expected/cjs.js

@ -1,7 +1,7 @@
'use strict';
function foo () {
console.log( 'indented with tabs' );
console.log( 'not indented' );
}
module.exports = foo;

2
test/form/indent-false/_expected/es.js

@ -1,5 +1,5 @@
function foo () {
console.log( 'indented with tabs' );
console.log( 'not indented' );
}
export default foo;

2
test/form/indent-false/_expected/iife.js

@ -2,7 +2,7 @@ var foo = (function () {
'use strict';
function foo () {
console.log( 'indented with tabs' );
console.log( 'not indented' );
}
return foo;

2
test/form/indent-false/_expected/umd.js

@ -5,7 +5,7 @@
}(this, (function () { 'use strict';
function foo () {
console.log( 'indented with tabs' );
console.log( 'not indented' );
}
return foo;

2
test/form/indent-false/main.js

@ -1,3 +1,3 @@
export default function foo () {
console.log( 'indented with tabs' );
console.log( 'not indented' );
}

7
test/form/indent-spaces/_config.js

@ -0,0 +1,7 @@
module.exports = {
description: 'auto-indents with indent: true',
options: {
moduleName: 'foo',
indent: ' '
}
};

9
test/form/indent-spaces/_expected/amd.js

@ -0,0 +1,9 @@
define(function () { 'use strict';
function foo () {
console.log( 'indented with tabs' );
}
return foo;
});

7
test/form/indent-spaces/_expected/cjs.js

@ -0,0 +1,7 @@
'use strict';
function foo () {
console.log( 'indented with tabs' );
}
module.exports = foo;

5
test/form/indent-spaces/_expected/es.js

@ -0,0 +1,5 @@
function foo () {
console.log( 'indented with tabs' );
}
export default foo;

10
test/form/indent-spaces/_expected/iife.js

@ -0,0 +1,10 @@
var foo = (function () {
'use strict';
function foo () {
console.log( 'indented with tabs' );
}
return foo;
}());

13
test/form/indent-spaces/_expected/umd.js

@ -0,0 +1,13 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.foo = factory());
}(this, (function () { 'use strict';
function foo () {
console.log( 'indented with tabs' );
}
return foo;
})));

3
test/form/indent-spaces/main.js

@ -0,0 +1,3 @@
export default function foo () {
console.log( 'indented with tabs' );
}
Loading…
Cancel
Save