Skip to content

Commit

Permalink
Merge pull request #694 from rollup/gh-690
Browse files Browse the repository at this point in the history
update to latest magic-string
  • Loading branch information
Rich-Harris committed Jun 9, 2016
2 parents 9b61546 + 9575b68 commit a87401c
Show file tree
Hide file tree
Showing 20 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/Bundle.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 => {
Expand Down
9 changes: 5 additions & 4 deletions src/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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 );
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down

0 comments on commit a87401c

Please sign in to comment.