Skip to content

Commit

Permalink
Merge pull request #1238 from rollup/gh-797
Browse files Browse the repository at this point in the history
use options.indent for UMD block
  • Loading branch information
Rich-Harris committed Jan 7, 2017
2 parents e938d86 + 101ad28 commit 6384b6c
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/finalisers/umd.js
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion 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;
Expand Down
2 changes: 1 addition & 1 deletion 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 changes: 1 addition & 1 deletion 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 changes: 1 addition & 1 deletion test/form/indent-false/_expected/iife.js
Expand Up @@ -2,7 +2,7 @@ var foo = (function () {
'use strict';

function foo () {
console.log( 'indented with tabs' );
console.log( 'not indented' );
}

return foo;
Expand Down
4 changes: 2 additions & 2 deletions test/form/indent-false/_expected/umd.js
Expand Up @@ -5,9 +5,9 @@
}(this, (function () { 'use strict';

function foo () {
console.log( 'indented with tabs' );
console.log( 'not indented' );
}

return foo;

})));
})));
2 changes: 1 addition & 1 deletion test/form/indent-false/main.js
@@ -1,3 +1,3 @@
export default function foo () {
console.log( 'indented with tabs' );
console.log( 'not indented' );
}
7 changes: 7 additions & 0 deletions test/form/indent-spaces/_config.js
@@ -0,0 +1,7 @@
module.exports = {
description: 'auto-indents with indent: true',
options: {
moduleName: 'foo',
indent: ' '
}
};
9 changes: 9 additions & 0 deletions 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 changes: 7 additions & 0 deletions test/form/indent-spaces/_expected/cjs.js
@@ -0,0 +1,7 @@
'use strict';

function foo () {
console.log( 'indented with tabs' );
}

module.exports = foo;
5 changes: 5 additions & 0 deletions test/form/indent-spaces/_expected/es.js
@@ -0,0 +1,5 @@
function foo () {
console.log( 'indented with tabs' );
}

export default foo;
10 changes: 10 additions & 0 deletions 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 changes: 13 additions & 0 deletions 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 changes: 3 additions & 0 deletions test/form/indent-spaces/main.js
@@ -0,0 +1,3 @@
export default function foo () {
console.log( 'indented with tabs' );
}

0 comments on commit 6384b6c

Please sign in to comment.