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 authored 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function foo () {
console.log( 'indented with tabs' );
}

0 comments on commit 6384b6c

Please sign in to comment.