Browse Source

use magic-string@0.7.0, to fix #101

contingency-plan
Rich Harris 10 years ago
parent
commit
2e460eca26
  1. 2
      package.json
  2. 6
      src/Statement.js

2
package.json

@ -48,7 +48,7 @@
"dependencies": {
"acorn": "^2.3.0",
"chalk": "^1.0.0",
"magic-string": "^0.6.5",
"magic-string": "^0.7.0",
"minimist": "^1.1.1",
"sander": "^0.3.3",
"source-map-support": "^0.3.1"

6
src/Statement.js

@ -304,7 +304,7 @@ export default class Statement {
// `this` is undefined at the top level of ES6 modules
if ( node.type === 'ThisExpression' && depth === 0 ) {
magicString.overwrite( node.start, node.end, 'undefined' );
magicString.overwrite( node.start, node.end, 'undefined', true );
}
// special case - variable declarations that need to be rewritten
@ -315,7 +315,7 @@ export default class Statement {
// needs to be rewritten, we replace the whole lot
const name = node.declarations[0].id.name;
if ( node.declarations.length === 1 && bundleExports[ name ] ) {
magicString.overwrite( node.start, node.declarations[0].id.end, bundleExports[ name ] );
magicString.overwrite( node.start, node.declarations[0].id.end, bundleExports[ name ], true );
node.declarations[0].id._skip = true;
}
@ -392,7 +392,7 @@ export default class Statement {
// TODO others...?
// all other identifiers should be overwritten
magicString.overwrite( node.start, node.end, name );
magicString.overwrite( node.start, node.end, name, true );
},
leave ( node ) {

Loading…
Cancel
Save