Browse Source

update to latest magic-string

ghi-672
Rich-Harris 9 years ago
parent
commit
200eb13259
  1. 1
      package.json
  2. 4
      src/Bundle.js
  3. 9
      src/Module.js

1
package.json

@ -63,6 +63,7 @@
},
"dependencies": {
"chalk": "^1.1.1",
"magic-string": "^0.15.0",
"minimist": "^1.2.0",
"source-map-support": "^0.4.0"
},

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';
@ -268,7 +268,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

@ -491,15 +491,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
}
}
@ -530,7 +531,7 @@ export default class Module {
}
if ( reference.isShorthandProperty ) {
magicString.insert( end, `: ${name}` );
magicString.insertLeft( end, `: ${name}` );
} else {
magicString.overwrite( start, end, name, true );
}

Loading…
Cancel
Save