Browse Source

Merge pull request #694 from rollup/gh-690

update to latest magic-string
ghi-672
Rich Harris 9 years ago
parent
commit
a87401c11a
  1. 2
      package.json
  2. 4
      src/Bundle.js
  3. 9
      src/Module.js
  4. 2
      test/cli/multiple-targets-shared-config/_expected/cjs.js.map
  5. 2
      test/cli/multiple-targets-shared-config/_expected/es6.js.map
  6. 0
      test/form/sourcemaps-external/_config.js
  7. 0
      test/form/sourcemaps-external/_expected/amd.js
  8. 0
      test/form/sourcemaps-external/_expected/amd.js.map
  9. 0
      test/form/sourcemaps-external/_expected/cjs.js
  10. 0
      test/form/sourcemaps-external/_expected/cjs.js.map
  11. 0
      test/form/sourcemaps-external/_expected/es6.js
  12. 0
      test/form/sourcemaps-external/_expected/es6.js.map
  13. 0
      test/form/sourcemaps-external/_expected/iife.js
  14. 0
      test/form/sourcemaps-external/_expected/iife.js.map
  15. 0
      test/form/sourcemaps-external/_expected/umd.js
  16. 0
      test/form/sourcemaps-external/_expected/umd.js.map
  17. 0
      test/form/sourcemaps-external/bar.js
  18. 0
      test/form/sourcemaps-external/foo.js
  19. 0
      test/form/sourcemaps-external/main.js
  20. 1
      test/test.js

2
package.json

@ -48,7 +48,7 @@
"eslint": "^2.9.0",
"estree-walker": "^0.2.0",
"istanbul": "^0.4.0",
"magic-string": "^0.10.1",
"magic-string": "^0.15.1",
"mocha": "^2.3.3",
"remap-istanbul": "^0.5.1",
"rollup": "^0.26.2",

4
src/Bundle.js

@ -1,4 +1,4 @@
import MagicString from 'magic-string';
import { Bundle as MagicStringBundle } from 'magic-string';
import first from './utils/first.js';
import { blank, forOwn, keys } from './utils/object.js';
import Module from './Module.js';
@ -282,7 +282,7 @@ export default class Bundle {
// Determine export mode - 'default', 'named', 'none'
const exportMode = getExportMode( this, options.exports, options.moduleName );
let magicString = new MagicString.Bundle({ separator: '\n\n' });
let magicString = new MagicStringBundle({ separator: '\n\n' });
let usedModules = [];
this.orderedModules.forEach( module => {

9
src/Module.js

@ -488,15 +488,16 @@ export default class Module {
const declaration = this.declarations[ name ];
if ( declaration.exportName && declaration.isReassigned ) {
magicString.insert( statement.end, `;\nexports.${name} = ${declaration.render( es6 )}` );
magicString.insertLeft( statement.end, `;\nexports.${name} = ${declaration.render( es6 )}` );
}
});
}
if ( statement.node.isSynthetic ) {
// insert `var/let/const` if necessary
magicString.insert( statement.start, `${statement.node.kind} ` );
magicString.overwrite( statement.end, statement.next, ';\n' ); // TODO account for trailing newlines
magicString.insertRight( statement.start, `${statement.node.kind} ` );
magicString.insertLeft( statement.end, ';' );
magicString.overwrite( statement.end, statement.next, '\n' ); // TODO account for trailing newlines
}
}
@ -527,7 +528,7 @@ export default class Module {
}
if ( reference.isShorthandProperty ) {
magicString.insert( end, `: ${name}` );
magicString.insertLeft( end, `: ${name}` );
} else {
magicString.overwrite( start, end, name, true );
}

2
test/cli/multiple-targets-shared-config/_expected/cjs.js.map

@ -1 +1 @@
{"version":3,"file":"cjs.js","sources":["../main.js"],"sourcesContent":["export default 0;\n"],"names":[],"mappings":";;WAAe,CAAC,CAAC,;;"}
{"version":3,"file":"cjs.js","sources":["../main.js"],"sourcesContent":["export default 0;\n"],"names":[],"mappings":";;AAAA,WAAe,CAAC,CAAC,;;"}

2
test/cli/multiple-targets-shared-config/_expected/es6.js.map

@ -1 +1 @@
{"version":3,"file":"es6.js","sources":["../main.js"],"sourcesContent":["export default 0;\n"],"names":[],"mappings":"WAAe,CAAC,CAAC,;;"}
{"version":3,"file":"es6.js","sources":["../main.js"],"sourcesContent":["export default 0;\n"],"names":[],"mappings":"AAAA,WAAe,CAAC,CAAC,;;"}

0
test/form/sourcemaps/_config.js → test/form/sourcemaps-external/_config.js

0
test/form/sourcemaps/_expected/amd.js → test/form/sourcemaps-external/_expected/amd.js

0
test/form/sourcemaps/_expected/amd.js.map → test/form/sourcemaps-external/_expected/amd.js.map

0
test/form/sourcemaps/_expected/cjs.js → test/form/sourcemaps-external/_expected/cjs.js

0
test/form/sourcemaps/_expected/cjs.js.map → test/form/sourcemaps-external/_expected/cjs.js.map

0
test/form/sourcemaps/_expected/es6.js → test/form/sourcemaps-external/_expected/es6.js

0
test/form/sourcemaps/_expected/es6.js.map → test/form/sourcemaps-external/_expected/es6.js.map

0
test/form/sourcemaps/_expected/iife.js → test/form/sourcemaps-external/_expected/iife.js

0
test/form/sourcemaps/_expected/iife.js.map → test/form/sourcemaps-external/_expected/iife.js.map

0
test/form/sourcemaps/_expected/umd.js → test/form/sourcemaps-external/_expected/umd.js

0
test/form/sourcemaps/_expected/umd.js.map → test/form/sourcemaps-external/_expected/umd.js.map

0
test/form/sourcemaps/bar.js → test/form/sourcemaps-external/bar.js

0
test/form/sourcemaps/foo.js → test/form/sourcemaps-external/foo.js

0
test/form/sourcemaps/main.js → test/form/sourcemaps-external/main.js

1
test/test.js

@ -13,7 +13,6 @@ var FUNCTION = path.resolve( __dirname, 'function' );
var FORM = path.resolve( __dirname, 'form' );
var SOURCEMAPS = path.resolve( __dirname, 'sourcemaps' );
var CLI = path.resolve( __dirname, 'cli' );
var INCREMENTAL = path.resolve( __dirname, 'incremental' );
var PROFILES = [
{ format: 'amd' },

Loading…
Cancel
Save