Browse Source

Fix for malformed output.

Without this change, you can get malformed stuff like this:

  var foo = function() {
    return "foo";
  }var bar = function() {
    return "bar";
  }

By introducing a newline, a semicolon is implicitly inserted between statements
when necessary:

  var foo = function() {
    return "foo";
  }
  var bar = function() {
    return "bar";
  }

The indentation as a result of this commit is off, but I’m not sure how to fix
it because the build fails for me. (I tested this by editing dist directly.)
contingency-plan
Mike Bostock 10 years ago
parent
commit
d9be5d6286
  1. 2
      src/Module.js
  2. 2
      src/Statement.js

2
src/Module.js

@ -44,7 +44,7 @@ export default class Module {
});
this.statements = ast.body.map( node => {
const magicString = this.magicString.snip( node.start, node.end );
const magicString = this.magicString.snip( node.start, node.end ).append( '\n' );
return new Statement( node, magicString, this );
});
} catch ( err ) {

2
src/Statement.js

@ -248,7 +248,7 @@ export default class Statement {
}
replaceIdentifiers ( names ) {
const magicString = this.magicString.clone().trim();
const magicString = this.magicString.clone();
const replacementStack = [ names ];
const nameList = keys( names );

Loading…
Cancel
Save