diff --git a/src/Bundle.js b/src/Bundle.js index 276e347..e1f5754 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -196,8 +196,6 @@ export default class Bundle { const format = options.format || 'es6'; - let previousMargin = 0; - // If we have named exports from the bundle, and those exports // are assigned to *within* the bundle, we may need to rewrite e.g. // @@ -212,7 +210,7 @@ export default class Bundle { // } // exports.incr = incr; // - // TODO This doesn't apply if the bundle is exported as ES6! + // This doesn't apply if the bundle is exported as ES6! let allBundleExports = blank(); if ( format !== 'es6' ) { @@ -236,6 +234,10 @@ export default class Bundle { .filter( key => !this.varExports[ key ] ); // Apply new names and add to the output bundle + let previousModule = null; + let previousIndex = -1; + let previousMargin = 0; + this.statements.forEach( statement => { // skip `export { foo, bar, baz }` if ( statement.node.type === 'ExportNamedDeclaration' && statement.node.specifiers.length ) { @@ -288,22 +290,24 @@ export default class Bundle { } } + // ensure there is always a newline between statements, and add + // additional newlines as necessary to reflect original source + const minSeparation = ( previousModule !== statement.module ) || ( statement.index !== previousIndex + 1 ) ? 3 : 2; + const margin = Math.max( minSeparation, statement.margin[0], previousMargin ); + let newLines = new Array( margin ).join( '\n' ); + // add leading comments if ( statement.leadingComments.length ) { - const commentBlock = statement.leadingComments.map( comment => { - return comment.block ? + const commentBlock = newLines + statement.leadingComments.map( ({ separator, comment }) => { + return separator + ( comment.block ? `/*${comment.text}*/` : - `//${comment.text}`; - }).join( '\n' ); + `//${comment.text}` ); + }).join( '' ); magicString.addSource( new MagicString( commentBlock ) ); + newLines = new Array( statement.margin[0] ).join( '\n' ); // TODO handle gaps between comment block and statement } - // ensure there is always a newline between statements, and add - // additional newlines as necessary to reflect original source - const margin = Math.max( 2, statement.margin[0], previousMargin ); - const newLines = new Array( margin ).join( '\n' ); - // add the statement itself magicString.addSource({ content: source, @@ -321,6 +325,8 @@ export default class Bundle { } previousMargin = statement.margin[1]; + previousModule = statement.module; + previousIndex = statement.index; }); // prepend bundle with internal namespaces diff --git a/src/Module.js b/src/Module.js index caef50c..f7731b2 100644 --- a/src/Module.js +++ b/src/Module.js @@ -42,9 +42,9 @@ export default class Module { } }); - this.statements = ast.body.map( node => { + this.statements = ast.body.map( ( node, i ) => { const magicString = this.magicString.snip( node.start, node.end ).trim(); - return new Statement( node, magicString, this ); + return new Statement( node, magicString, this, i ); }); } catch ( err ) { err.code = 'PARSE_ERROR'; diff --git a/src/Statement.js b/src/Statement.js index fdc0cab..b96d8e7 100644 --- a/src/Statement.js +++ b/src/Statement.js @@ -8,10 +8,11 @@ import Scope from './ast/Scope'; const emptyArrayPromise = Promise.resolve([]); export default class Statement { - constructor ( node, magicString, module ) { + constructor ( node, magicString, module, index ) { this.node = node; this.module = module; this.magicString = magicString; + this.index = index; this.scope = new Scope(); this.defines = blank(); diff --git a/src/ast/analyse.js b/src/ast/analyse.js index e8fe422..21b5f4c 100644 --- a/src/ast/analyse.js +++ b/src/ast/analyse.js @@ -7,6 +7,7 @@ export default function analyse ( magicString, module ) { const node = statement.node; let trailing = !!previousStatement; + let previousComment; // TODO surely this can be neater // attach leading comment @@ -31,7 +32,12 @@ export default function analyse ( magicString, module ) { // then attach leading comments to this statement else { - statement.leadingComments.push( comment ); + statement.leadingComments.push({ + separator: previousComment ? magicString.slice( previousComment.end, comment.start ) : '\n', + comment + }); + + previousComment = comment; } commentIndex += 1; @@ -39,10 +45,15 @@ export default function analyse ( magicString, module ) { } while ( module.comments[ commentIndex ] ); // determine margin - const previousEnd = previousStatement ? ( previousStatement.trailingComment || previousStatement.node ).end : 0; - const start = ( statement.leadingComments[0] || node ).start; + const previousEnd = previousComment ? + previousComment.end : + previousStatement ? + ( previousStatement.trailingComment || previousStatement.node ).end : + 0; + + //const start = ( statement.leadingComments[0] || node ).start; - const gap = magicString.original.slice( previousEnd, start ); + const gap = magicString.original.slice( previousEnd, node.start ); const margin = gap.split( '\n' ).length; if ( previousStatement ) previousStatement.margin[1] = margin; diff --git a/test/form/block-comments/_config.js b/test/form/block-comments/_config.js index fc82b3f..f18362c 100644 --- a/test/form/block-comments/_config.js +++ b/test/form/block-comments/_config.js @@ -1,4 +1,3 @@ module.exports = { - description: 'block comments are printed correctly', - skip: true // work on this later + description: 'block comments are printed correctly' }; diff --git a/test/form/block-comments/_expected/amd.js b/test/form/block-comments/_expected/amd.js new file mode 100644 index 0000000..e4cb76c --- /dev/null +++ b/test/form/block-comments/_expected/amd.js @@ -0,0 +1,19 @@ +define(function () { 'use strict'; + + /** + * Embiggens a number + * @param {number} num - the number to embiggen + * @param {number} factor - the factor to embiggen it by + * @returns {number} + */ + function embiggen ( num, factor ) { + return num * factor; + } + + function foo () { + return embiggen( 6, 7 ); + } + + alert( foo() ); + +}); diff --git a/test/form/block-comments/_expected/cjs.js b/test/form/block-comments/_expected/cjs.js new file mode 100644 index 0000000..0ec12d5 --- /dev/null +++ b/test/form/block-comments/_expected/cjs.js @@ -0,0 +1,17 @@ +'use strict'; + +/** + * Embiggens a number + * @param {number} num - the number to embiggen + * @param {number} factor - the factor to embiggen it by + * @returns {number} + */ +function embiggen ( num, factor ) { + return num * factor; +} + +function foo () { + return embiggen( 6, 7 ); +} + +alert( foo() ); diff --git a/test/form/block-comments/_expected/es6.js b/test/form/block-comments/_expected/es6.js new file mode 100644 index 0000000..919a645 --- /dev/null +++ b/test/form/block-comments/_expected/es6.js @@ -0,0 +1,15 @@ +/** + * Embiggens a number + * @param {number} num - the number to embiggen + * @param {number} factor - the factor to embiggen it by + * @returns {number} + */ +function embiggen ( num, factor ) { + return num * factor; +} + +function foo () { + return embiggen( 6, 7 ); +} + +alert( foo() ); diff --git a/test/form/block-comments/_expected/iife.js b/test/form/block-comments/_expected/iife.js new file mode 100644 index 0000000..4528174 --- /dev/null +++ b/test/form/block-comments/_expected/iife.js @@ -0,0 +1,19 @@ +(function () { 'use strict'; + + /** + * Embiggens a number + * @param {number} num - the number to embiggen + * @param {number} factor - the factor to embiggen it by + * @returns {number} + */ + function embiggen ( num, factor ) { + return num * factor; + } + + function foo () { + return embiggen( 6, 7 ); + } + + alert( foo() ); + +})(); diff --git a/test/form/block-comments/_expected/umd.js b/test/form/block-comments/_expected/umd.js new file mode 100644 index 0000000..1c7727a --- /dev/null +++ b/test/form/block-comments/_expected/umd.js @@ -0,0 +1,23 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(this, function () { 'use strict'; + + /** + * Embiggens a number + * @param {number} num - the number to embiggen + * @param {number} factor - the factor to embiggen it by + * @returns {number} + */ + function embiggen ( num, factor ) { + return num * factor; + } + + function foo () { + return embiggen( 6, 7 ); + } + + alert( foo() ); + +})); diff --git a/test/form/sourcemaps-inline/_expected/amd.js b/test/form/sourcemaps-inline/_expected/amd.js index 3a3116b..48d1b0d 100644 --- a/test/form/sourcemaps-inline/_expected/amd.js +++ b/test/form/sourcemaps-inline/_expected/amd.js @@ -7,10 +7,12 @@ define(function () { 'use strict'; } foo(); + function bar () { console.log( 'hello from bar.js' ); } + bar(); }); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW1kLmpzIiwic291cmNlcyI6WyIuLi9tYWluLmpzIiwiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmb28gZnJvbSAnLi9mb28nO1xuaW1wb3J0IGJhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gZm9vICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGZvby5qcycgKTtcbn1cbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGJhciAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBiYXIuanMnICk7XG59XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncy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EVBQUU7QUFEbkMsQ0FFQTs7QURGQSxDQUtBLEdBQUcsRUFBRTs7QUVMTCxDQUFlLFNBQVMsR0FBRyxJQUFJO0FBQS9CLENBQ0EsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBRG5DLENBRUE7O0FGRkEsQ0FNQSxHQUFHLEVBQUUsOzsifQ== diff --git a/test/form/sourcemaps-inline/_expected/cjs.js b/test/form/sourcemaps-inline/_expected/cjs.js index 66e0831..1ad44f8 100644 --- a/test/form/sourcemaps-inline/_expected/cjs.js +++ b/test/form/sourcemaps-inline/_expected/cjs.js @@ -7,8 +7,10 @@ function foo () { } foo(); + function bar () { console.log( 'hello from bar.js' ); } + bar(); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2pzLmpzIiwic291cmNlcyI6WyIuLi9tYWluLmpzIiwiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmb28gZnJvbSAnLi9mb28nO1xuaW1wb3J0IGJhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gZm9vICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGZvby5qcycgKTtcbn1cbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGJhciAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBiYXIuanMnICk7XG59XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFHQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFOztBQ0hwQixTQUFTLEdBQUcsSUFBSTtBQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7QUFDbkM7O0FER0EsR0FBRyxFQUFFO0FFTFUsU0FBUyxHQUFHLElBQUk7QUFDL0IsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBQ25DO0FGSUEsR0FBRyxFQUFFIn0= +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2pzLmpzIiwic291cmNlcyI6WyIuLi9tYWluLmpzIiwiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmb28gZnJvbSAnLi9mb28nO1xuaW1wb3J0IGJhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gZm9vICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGZvby5qcycgKTtcbn1cbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGJhciAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBiYXIuanMnICk7XG59XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFHQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFOztBQ0hwQixTQUFTLEdBQUcsSUFBSTtBQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7QUFDbkM7O0FER0EsR0FBRyxFQUFFOztBRUxVLFNBQVMsR0FBRyxJQUFJO0FBQy9CLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxtQkFBbUIsRUFBRTtBQUNuQzs7QUZJQSxHQUFHLEVBQUUifQ== diff --git a/test/form/sourcemaps-inline/_expected/es6.js b/test/form/sourcemaps-inline/_expected/es6.js index 5032679..571bcb3 100644 --- a/test/form/sourcemaps-inline/_expected/es6.js +++ b/test/form/sourcemaps-inline/_expected/es6.js @@ -5,8 +5,10 @@ function foo () { } foo(); + function bar () { console.log( 'hello from bar.js' ); } + bar(); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXM2LmpzIiwic291cmNlcyI6WyIuLi9tYWluLmpzIiwiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmb28gZnJvbSAnLi9mb28nO1xuaW1wb3J0IGJhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gZm9vICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGZvby5qcycgKTtcbn1cbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGJhciAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBiYXIuanMnICk7XG59XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsT0FBTyxDQUFDLEdBQUcsRUFBRSxvQkFBb0IsRUFBRTs7QUNIcEIsU0FBUyxHQUFHLElBQUk7QUFDL0IsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBQ25DOztBREdBLEdBQUcsRUFBRTtBRUxVLFNBQVMsR0FBRyxJQUFJO0FBQy9CLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxtQkFBbUIsRUFBRTtBQUNuQztBRklBLEdBQUcsRUFBRSJ9 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXM2LmpzIiwic291cmNlcyI6WyIuLi9tYWluLmpzIiwiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmb28gZnJvbSAnLi9mb28nO1xuaW1wb3J0IGJhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gZm9vICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGZvby5qcycgKTtcbn1cbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGJhciAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBiYXIuanMnICk7XG59XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsT0FBTyxDQUFDLEdBQUcsRUFBRSxvQkFBb0IsRUFBRTs7QUNIcEIsU0FBUyxHQUFHLElBQUk7QUFDL0IsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBQ25DOztBREdBLEdBQUcsRUFBRTs7QUVMVSxTQUFTLEdBQUcsSUFBSTtBQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7QUFDbkM7O0FGSUEsR0FBRyxFQUFFIn0= diff --git a/test/form/sourcemaps-inline/_expected/iife.js b/test/form/sourcemaps-inline/_expected/iife.js index 9d451cb..d6cfbc6 100644 --- a/test/form/sourcemaps-inline/_expected/iife.js +++ b/test/form/sourcemaps-inline/_expected/iife.js @@ -7,10 +7,12 @@ } foo(); + function bar () { console.log( 'hello from bar.js' ); } + bar(); })(); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaWlmZS5qcyIsInNvdXJjZXMiOlsiLi4vbWFpbi5qcyIsIi4uL2Zvby5qcyIsIi4uL2Jhci5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgZm9vIGZyb20gJy4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vbyAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBmb28uanMnICk7XG59XG4iLCJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBiYXIgKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gYmFyLmpzJyApO1xufVxuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsQ0FHQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFOztBQ0huQyxDQUFlLFNBQVMsR0FBRyxJQUFJO0FBQS9CLENBQ0EsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBRG5DLENBRUE7O0FERkEsQ0FLQSxHQUFHLEVBQUU7O0FFTEwsQ0FBZSxTQUFTLEdBQUcsSUFBSTtBQUEvQixDQUNBLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxtQkFBbUIsRUFBRTtBQURuQyxDQUVBOztBRkZBLENBTUEsR0FBRyxFQUFFLDs7In0= diff --git a/test/form/sourcemaps-inline/_expected/umd.js b/test/form/sourcemaps-inline/_expected/umd.js index a0c5a5c..9960930 100644 --- a/test/form/sourcemaps-inline/_expected/umd.js +++ b/test/form/sourcemaps-inline/_expected/umd.js @@ -11,10 +11,12 @@ } foo(); + function bar () { console.log( 'hello from bar.js' ); } + bar(); })); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW1kLmpzIiwic291cmNlcyI6WyIuLi9tYWluLmpzIiwiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmb28gZnJvbSAnLi9mb28nO1xuaW1wb3J0IGJhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY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uanMnICk7XG59XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsQ0FHQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFOztBQ0huQyxDQUFlLFNBQVMsR0FBRyxJQUFJO0FBQS9CLENBQ0EsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBRG5DLENBRUE7O0FERkEsQ0FLQSxHQUFHLEVBQUU7O0FFTEwsQ0FBZSxTQUFTLEdBQUcsSUFBSTtBQUEvQixDQUNBLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxtQkFBbUIsRUFBRTtBQURuQyxDQUVBOztBRkZBLENBTUEsR0FBRyxFQUFFLDs7In0= diff --git a/test/form/sourcemaps/_expected/amd.js b/test/form/sourcemaps/_expected/amd.js index c7b07b1..eb6c830 100644 --- a/test/form/sourcemaps/_expected/amd.js +++ b/test/form/sourcemaps/_expected/amd.js @@ -7,9 +7,11 @@ define(function () { 'use strict'; } foo(); + function bar () { console.log( 'hello from bar.js' ); } + bar(); }); diff --git a/test/form/sourcemaps/_expected/amd.js.map b/test/form/sourcemaps/_expected/amd.js.map index 067db5b..53fcd75 100644 --- a/test/form/sourcemaps/_expected/amd.js.map +++ b/test/form/sourcemaps/_expected/amd.js.map @@ -1 +1 @@ -{"version":3,"file":"amd.js","sources":["../main.js","../foo.js","../bar.js"],"sourcesContent":["import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n","export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n"],"names":[],"mappings":";;AAAA,CAGA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;ACHnC,CAAe,SAAS,GAAG,IAAI;AAA/B,CACA,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AADnC,CAEA;;ADFA,CAKA,GAAG,EAAE;AELL,CAAe,SAAS,GAAG,IAAI;AAA/B,CACA,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AADnC,CAEA;AFFA,CAMA,GAAG,EAAE,;;"} +{"version":3,"file":"amd.js","sources":["../main.js","../foo.js","../bar.js"],"sourcesContent":["import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n","export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n"],"names":[],"mappings":";;AAAA,CAGA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;ACHnC,CAAe,SAAS,GAAG,IAAI;AAA/B,CACA,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AADnC,CAEA;;ADFA,CAKA,GAAG,EAAE;;AELL,CAAe,SAAS,GAAG,IAAI;AAA/B,CACA,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AADnC,CAEA;;AFFA,CAMA,GAAG,EAAE,;;"} diff --git a/test/form/sourcemaps/_expected/cjs.js b/test/form/sourcemaps/_expected/cjs.js index 618ea34..c4eecf7 100644 --- a/test/form/sourcemaps/_expected/cjs.js +++ b/test/form/sourcemaps/_expected/cjs.js @@ -7,8 +7,10 @@ function foo () { } foo(); + function bar () { console.log( 'hello from bar.js' ); } + bar(); //# sourceMappingURL=cjs.js.map diff --git a/test/form/sourcemaps/_expected/cjs.js.map b/test/form/sourcemaps/_expected/cjs.js.map index 612dca5..cabea9b 100644 --- a/test/form/sourcemaps/_expected/cjs.js.map +++ b/test/form/sourcemaps/_expected/cjs.js.map @@ -1 +1 @@ -{"version":3,"file":"cjs.js","sources":["../main.js","../foo.js","../bar.js"],"sourcesContent":["import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n","export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n"],"names":[],"mappings":";;AAGA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;ACHpB,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ADGA,GAAG,EAAE;AELU,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;AFIA,GAAG,EAAE"} +{"version":3,"file":"cjs.js","sources":["../main.js","../foo.js","../bar.js"],"sourcesContent":["import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n","export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n"],"names":[],"mappings":";;AAGA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;ACHpB,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ADGA,GAAG,EAAE;;AELU,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;AFIA,GAAG,EAAE"} diff --git a/test/form/sourcemaps/_expected/es6.js b/test/form/sourcemaps/_expected/es6.js index fe96052..3f78c3d 100644 --- a/test/form/sourcemaps/_expected/es6.js +++ b/test/form/sourcemaps/_expected/es6.js @@ -5,8 +5,10 @@ function foo () { } foo(); + function bar () { console.log( 'hello from bar.js' ); } + bar(); //# sourceMappingURL=es6.js.map diff --git a/test/form/sourcemaps/_expected/es6.js.map b/test/form/sourcemaps/_expected/es6.js.map index cdcd20b..5a3e7a5 100644 --- a/test/form/sourcemaps/_expected/es6.js.map +++ b/test/form/sourcemaps/_expected/es6.js.map @@ -1 +1 @@ -{"version":3,"file":"es6.js","sources":["../main.js","../foo.js","../bar.js"],"sourcesContent":["import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n","export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n"],"names":[],"mappings":"AAGA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;ACHpB,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ADGA,GAAG,EAAE;AELU,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;AFIA,GAAG,EAAE"} +{"version":3,"file":"es6.js","sources":["../main.js","../foo.js","../bar.js"],"sourcesContent":["import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n","export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n"],"names":[],"mappings":"AAGA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;ACHpB,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ADGA,GAAG,EAAE;;AELU,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;AFIA,GAAG,EAAE"} diff --git a/test/form/sourcemaps/_expected/iife.js b/test/form/sourcemaps/_expected/iife.js index 010aca6..9f993ed 100644 --- a/test/form/sourcemaps/_expected/iife.js +++ b/test/form/sourcemaps/_expected/iife.js @@ -7,9 +7,11 @@ } foo(); + function bar () { console.log( 'hello from bar.js' ); } + bar(); })(); diff --git a/test/form/sourcemaps/_expected/iife.js.map b/test/form/sourcemaps/_expected/iife.js.map index 93208ee..d9d8a6b 100644 --- a/test/form/sourcemaps/_expected/iife.js.map +++ b/test/form/sourcemaps/_expected/iife.js.map @@ -1 +1 @@ -{"version":3,"file":"iife.js","sources":["../main.js","../foo.js","../bar.js"],"sourcesContent":["import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n","export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n"],"names":[],"mappings":";;AAAA,CAGA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;ACHnC,CAAe,SAAS,GAAG,IAAI;AAA/B,CACA,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AADnC,CAEA;;ADFA,CAKA,GAAG,EAAE;AELL,CAAe,SAAS,GAAG,IAAI;AAA/B,CACA,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AADnC,CAEA;AFFA,CAMA,GAAG,EAAE,;;"} +{"version":3,"file":"iife.js","sources":["../main.js","../foo.js","../bar.js"],"sourcesContent":["import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n","export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n"],"names":[],"mappings":";;AAAA,CAGA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;ACHnC,CAAe,SAAS,GAAG,IAAI;AAA/B,CACA,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AADnC,CAEA;;ADFA,CAKA,GAAG,EAAE;;AELL,CAAe,SAAS,GAAG,IAAI;AAA/B,CACA,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AADnC,CAEA;;AFFA,CAMA,GAAG,EAAE,;;"} diff --git a/test/form/sourcemaps/_expected/umd.js b/test/form/sourcemaps/_expected/umd.js index 69d5f39..7fa1b71 100644 --- a/test/form/sourcemaps/_expected/umd.js +++ b/test/form/sourcemaps/_expected/umd.js @@ -11,9 +11,11 @@ } foo(); + function bar () { console.log( 'hello from bar.js' ); } + bar(); })); diff --git a/test/form/sourcemaps/_expected/umd.js.map b/test/form/sourcemaps/_expected/umd.js.map index 68687a8..788531e 100644 --- a/test/form/sourcemaps/_expected/umd.js.map +++ b/test/form/sourcemaps/_expected/umd.js.map @@ -1 +1 @@ -{"version":3,"file":"umd.js","sources":["../main.js","../foo.js","../bar.js"],"sourcesContent":["import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n","export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n"],"names":[],"mappings":";;;;;;AAAA,CAGA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;ACHnC,CAAe,SAAS,GAAG,IAAI;AAA/B,CACA,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AADnC,CAEA;;ADFA,CAKA,GAAG,EAAE;AELL,CAAe,SAAS,GAAG,IAAI;AAA/B,CACA,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AADnC,CAEA;AFFA,CAMA,GAAG,EAAE,;;"} +{"version":3,"file":"umd.js","sources":["../main.js","../foo.js","../bar.js"],"sourcesContent":["import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n","export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n"],"names":[],"mappings":";;;;;;AAAA,CAGA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;ACHnC,CAAe,SAAS,GAAG,IAAI;AAA/B,CACA,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AADnC,CAEA;;ADFA,CAKA,GAAG,EAAE;;AELL,CAAe,SAAS,GAAG,IAAI;AAA/B,CACA,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AADnC,CAEA;;AFFA,CAMA,GAAG,EAAE,;;"}