Browse Source

better (if slightly in need of refactoring) comment handling

contingency-plan
Rich-Harris 10 years ago
parent
commit
f60120bbc6
  1. 30
      src/Bundle.js
  2. 4
      src/Module.js
  3. 3
      src/Statement.js
  4. 19
      src/ast/analyse.js
  5. 3
      test/form/block-comments/_config.js
  6. 19
      test/form/block-comments/_expected/amd.js
  7. 17
      test/form/block-comments/_expected/cjs.js
  8. 15
      test/form/block-comments/_expected/es6.js
  9. 19
      test/form/block-comments/_expected/iife.js
  10. 23
      test/form/block-comments/_expected/umd.js
  11. 4
      test/form/sourcemaps-inline/_expected/amd.js
  12. 4
      test/form/sourcemaps-inline/_expected/cjs.js
  13. 4
      test/form/sourcemaps-inline/_expected/es6.js
  14. 4
      test/form/sourcemaps-inline/_expected/iife.js
  15. 4
      test/form/sourcemaps-inline/_expected/umd.js
  16. 2
      test/form/sourcemaps/_expected/amd.js
  17. 2
      test/form/sourcemaps/_expected/amd.js.map
  18. 2
      test/form/sourcemaps/_expected/cjs.js
  19. 2
      test/form/sourcemaps/_expected/cjs.js.map
  20. 2
      test/form/sourcemaps/_expected/es6.js
  21. 2
      test/form/sourcemaps/_expected/es6.js.map
  22. 2
      test/form/sourcemaps/_expected/iife.js
  23. 2
      test/form/sourcemaps/_expected/iife.js.map
  24. 2
      test/form/sourcemaps/_expected/umd.js
  25. 2
      test/form/sourcemaps/_expected/umd.js.map

30
src/Bundle.js

@ -196,8 +196,6 @@ export default class Bundle {
const format = options.format || 'es6'; const format = options.format || 'es6';
let previousMargin = 0;
// If we have named exports from the bundle, and those exports // If we have named exports from the bundle, and those exports
// are assigned to *within* the bundle, we may need to rewrite e.g. // are assigned to *within* the bundle, we may need to rewrite e.g.
// //
@ -212,7 +210,7 @@ export default class Bundle {
// } // }
// exports.incr = incr; // 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(); let allBundleExports = blank();
if ( format !== 'es6' ) { if ( format !== 'es6' ) {
@ -236,6 +234,10 @@ export default class Bundle {
.filter( key => !this.varExports[ key ] ); .filter( key => !this.varExports[ key ] );
// Apply new names and add to the output bundle // Apply new names and add to the output bundle
let previousModule = null;
let previousIndex = -1;
let previousMargin = 0;
this.statements.forEach( statement => { this.statements.forEach( statement => {
// skip `export { foo, bar, baz }` // skip `export { foo, bar, baz }`
if ( statement.node.type === 'ExportNamedDeclaration' && statement.node.specifiers.length ) { 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 // add leading comments
if ( statement.leadingComments.length ) { if ( statement.leadingComments.length ) {
const commentBlock = statement.leadingComments.map( comment => { const commentBlock = newLines + statement.leadingComments.map( ({ separator, comment }) => {
return comment.block ? return separator + ( comment.block ?
`/*${comment.text}*/` : `/*${comment.text}*/` :
`//${comment.text}`; `//${comment.text}` );
}).join( '\n' ); }).join( '' );
magicString.addSource( new MagicString( commentBlock ) ); 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 // add the statement itself
magicString.addSource({ magicString.addSource({
content: source, content: source,
@ -321,6 +325,8 @@ export default class Bundle {
} }
previousMargin = statement.margin[1]; previousMargin = statement.margin[1];
previousModule = statement.module;
previousIndex = statement.index;
}); });
// prepend bundle with internal namespaces // prepend bundle with internal namespaces

4
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(); 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 ) { } catch ( err ) {
err.code = 'PARSE_ERROR'; err.code = 'PARSE_ERROR';

3
src/Statement.js

@ -8,10 +8,11 @@ import Scope from './ast/Scope';
const emptyArrayPromise = Promise.resolve([]); const emptyArrayPromise = Promise.resolve([]);
export default class Statement { export default class Statement {
constructor ( node, magicString, module ) { constructor ( node, magicString, module, index ) {
this.node = node; this.node = node;
this.module = module; this.module = module;
this.magicString = magicString; this.magicString = magicString;
this.index = index;
this.scope = new Scope(); this.scope = new Scope();
this.defines = blank(); this.defines = blank();

19
src/ast/analyse.js

@ -7,6 +7,7 @@ export default function analyse ( magicString, module ) {
const node = statement.node; const node = statement.node;
let trailing = !!previousStatement; let trailing = !!previousStatement;
let previousComment;
// TODO surely this can be neater // TODO surely this can be neater
// attach leading comment // attach leading comment
@ -31,7 +32,12 @@ export default function analyse ( magicString, module ) {
// then attach leading comments to this statement // then attach leading comments to this statement
else { else {
statement.leadingComments.push( comment ); statement.leadingComments.push({
separator: previousComment ? magicString.slice( previousComment.end, comment.start ) : '\n',
comment
});
previousComment = comment;
} }
commentIndex += 1; commentIndex += 1;
@ -39,10 +45,15 @@ export default function analyse ( magicString, module ) {
} while ( module.comments[ commentIndex ] ); } while ( module.comments[ commentIndex ] );
// determine margin // determine margin
const previousEnd = previousStatement ? ( previousStatement.trailingComment || previousStatement.node ).end : 0; const previousEnd = previousComment ?
const start = ( statement.leadingComments[0] || node ).start; 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; const margin = gap.split( '\n' ).length;
if ( previousStatement ) previousStatement.margin[1] = margin; if ( previousStatement ) previousStatement.margin[1] = margin;

3
test/form/block-comments/_config.js

@ -1,4 +1,3 @@
module.exports = { module.exports = {
description: 'block comments are printed correctly', description: 'block comments are printed correctly'
skip: true // work on this later
}; };

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

17
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() );

15
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() );

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

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

4
test/form/sourcemaps-inline/_expected/amd.js

@ -7,10 +7,12 @@ define(function () { 'use strict';
} }
foo(); foo();
function bar () { function bar () {
console.log( 'hello from bar.js' ); console.log( 'hello from bar.js' );
} }
bar(); bar();
}); });
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW1kLmpzIiwic291cmNlcyI6WyIuLi9tYWluLmpzIiwiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmb28gZnJvbSAnLi9mb28nO1xuaW1wb3J0IGJhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gZm9vICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGZvby5qcycgKTtcbn1cbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGJhciAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBiYXIuanMnICk7XG59XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxDQUdBLE9BQU8sQ0FBQyxHQUFHLEVBQUUsb0JBQW9CLEVBQUU7O0FDSG5DLENBQWUsU0FBUyxHQUFHLElBQUk7QUFBL0IsQ0FDQSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7QUFEbkMsQ0FFQTs7QURGQSxDQUtBLEdBQUcsRUFBRTtBRUxMLENBQWUsU0FBUyxHQUFHLElBQUk7QUFBL0IsQ0FDQSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7QUFEbkMsQ0FFQTtBRkZBLENBTUEsR0FBRyxFQUFFLDs7In0= //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW1kLmpzIiwic291cmNlcyI6WyIuLi9tYWluLmpzIiwiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmb28gZnJvbSAnLi9mb28nO1xuaW1wb3J0IGJhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gZm9vICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGZvby5qcycgKTtcbn1cbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGJhciAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBiYXIuanMnICk7XG59XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxDQUdBLE9BQU8sQ0FBQyxHQUFHLEVBQUUsb0JBQW9CLEVBQUU7O0FDSG5DLENBQWUsU0FBUyxHQUFHLElBQUk7QUFBL0IsQ0FDQSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7QUFEbkMsQ0FFQTs7QURGQSxDQUtBLEdBQUcsRUFBRTs7QUVMTCxDQUFlLFNBQVMsR0FBRyxJQUFJO0FBQS9CLENBQ0EsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBRG5DLENBRUE7O0FGRkEsQ0FNQSxHQUFHLEVBQUUsOzsifQ==

4
test/form/sourcemaps-inline/_expected/cjs.js

@ -7,8 +7,10 @@ function foo () {
} }
foo(); foo();
function bar () { function bar () {
console.log( 'hello from bar.js' ); console.log( 'hello from bar.js' );
} }
bar(); bar();
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2pzLmpzIiwic291cmNlcyI6WyIuLi9tYWluLmpzIiwiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmb28gZnJvbSAn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ZWZhdWx0IGZ1bmN0aW9uIGJhciAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBiYXIuanMnICk7XG59XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFHQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFOztBQ0hwQixTQUFTLEdBQUcsSUFBSTtBQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7QUFDbkM7O0FER0EsR0FBRyxFQUFFOztBRUxVLFNBQVMsR0FBRyxJQUFJO0FBQy9CLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxtQkFBbUIsRUFBRTtBQUNuQzs7QUZJQSxHQUFHLEVBQUUifQ==

4
test/form/sourcemaps-inline/_expected/es6.js

@ -5,8 +5,10 @@ function foo () {
} }
foo(); foo();
function bar () { function bar () {
console.log( 'hello from bar.js' ); console.log( 'hello from bar.js' );
} }
bar(); bar();
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXM2LmpzIiwic291cmNlcyI6WyIuLi9tYWluLmpzIiwiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmb28gZnJvbSAnLi9mb28nO1xuaW1wb3J0IGJhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gZm9vICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGZvby5qcycgKTtcbn1cbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGJhciAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBiYXIuanMnICk7XG59XG4iXSwibmFtZXMiOltdLCJtYXBwaW5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BQUUsbUJBQW1CLEVBQUU7QUFDbkM7O0FGSUEsR0FBRyxFQUFFIn0=

4
test/form/sourcemaps-inline/_expected/iife.js

@ -7,10 +7,12 @@
} }
foo(); foo();
function bar () { function bar () {
console.log( 'hello from bar.js' ); console.log( 'hello from bar.js' );
} }
bar(); bar();
})(); })();
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaWlmZS5qcyIsInNvdXJjZXMiOlsiLi4vbWFpbi5qcyIsIi4uL2Zvby5qcyIsIi4uL2Jhci5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgZm9vIGZyb20gJy4vZm9vJztcbmltcG9ydCBiYXIgZnJvbSAnLi9iYXInO1xuXG5jb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gbWFpbi5qcycgKTtcblxuZm9vKCk7XG5iYXIoKTtcbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGZvbyAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBmb28uanMnICk7XG59XG4iLCJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBiYXIgKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gYmFyLmpzJyApO1xufVxuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsQ0FHQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFOztBQ0huQyxDQUFlLFNBQVMsR0FBRyxJQUFJO0FBQS9CLENBQ0EsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBRG5DLENBRUE7O0FERkEsQ0FLQSxHQUFHLEVBQUU7QUVMTCxDQUFlLFNBQVMsR0FBRyxJQUFJO0FBQS9CLENBQ0EsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBRG5DLENBRUE7QUZGQSxDQU1BLEdBQUcsRUFBRSw7OyJ9 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaWlmZS5qcyIsInNvdXJjZXMiOlsiLi4vbWFpbi5qcyIsIi4uL2Zvby5qcyIsIi4uL2Jhci5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgZm9vIGZyb20gJy4vZm9vJztcbmltcG9ydCBiYXIgZnJvbSAnLi9iYXInO1xuXG5jb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gbWFpbi5qcycgKTtcblxuZm9vKCk7XG5iYXIoKTtcbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGZvbyAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBmb28uanMnICk7XG59XG4iLCJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBiYXIgKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gYmFyLmpzJyApO1xufVxuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsQ0FHQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFOztBQ0huQyxDQUFlLFNBQVMsR0FBRyxJQUFJO0FBQS9CLENBQ0EsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBRG5DLENBRUE7O0FERkEsQ0FLQSxHQUFHLEVBQUU7O0FFTEwsQ0FBZSxTQUFTLEdBQUcsSUFBSTtBQUEvQixDQUNBLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxtQkFBbUIsRUFBRTtBQURuQyxDQUVBOztBRkZBLENBTUEsR0FBRyxFQUFFLDs7In0=

4
test/form/sourcemaps-inline/_expected/umd.js

@ -11,10 +11,12 @@
} }
foo(); foo();
function bar () { function bar () {
console.log( 'hello from bar.js' ); console.log( 'hello from bar.js' );
} }
bar(); bar();
})); }));
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2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JhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gZm9vICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGZvby5qcycgKTtcbn1cbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGJhciAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBiYXIuanMnICk7XG59XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsQ0FHQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFOztBQ0huQyxDQUFlLFNBQVMsR0FBRyxJQUFJO0FBQS9CLENBQ0EsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBRG5DLENBRUE7O0FERkEsQ0FLQSxHQUFHLEVBQUU7O0FFTEwsQ0FBZSxTQUFTLEdBQUcsSUFBSTtBQUEvQixDQUNBLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxtQkFBbUIsRUFBRTtBQURuQyxDQUVBOztBRkZBLENBTUEsR0FBRyxFQUFFLDs7In0=

2
test/form/sourcemaps/_expected/amd.js

@ -7,9 +7,11 @@ define(function () { 'use strict';
} }
foo(); foo();
function bar () { function bar () {
console.log( 'hello from bar.js' ); console.log( 'hello from bar.js' );
} }
bar(); bar();
}); });

2
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,;;"}

2
test/form/sourcemaps/_expected/cjs.js

@ -7,8 +7,10 @@ function foo () {
} }
foo(); foo();
function bar () { function bar () {
console.log( 'hello from bar.js' ); console.log( 'hello from bar.js' );
} }
bar(); bar();
//# sourceMappingURL=cjs.js.map //# sourceMappingURL=cjs.js.map

2
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"}

2
test/form/sourcemaps/_expected/es6.js

@ -5,8 +5,10 @@ function foo () {
} }
foo(); foo();
function bar () { function bar () {
console.log( 'hello from bar.js' ); console.log( 'hello from bar.js' );
} }
bar(); bar();
//# sourceMappingURL=es6.js.map //# sourceMappingURL=es6.js.map

2
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"}

2
test/form/sourcemaps/_expected/iife.js

@ -7,9 +7,11 @@
} }
foo(); foo();
function bar () { function bar () {
console.log( 'hello from bar.js' ); console.log( 'hello from bar.js' );
} }
bar(); bar();
})(); })();

2
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,;;"}

2
test/form/sourcemaps/_expected/umd.js

@ -11,9 +11,11 @@
} }
foo(); foo();
function bar () { function bar () {
console.log( 'hello from bar.js' ); console.log( 'hello from bar.js' );
} }
bar(); bar();
})); }));

2
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,;;"}

Loading…
Cancel
Save