fix module shadowing when using CommonJS-like module formatters - fixes #1544

This commit is contained in:
Sebastian McKenzie 2015-05-16 01:47:48 +01:00
parent 375689a1ff
commit ea510d09d0
5 changed files with 38 additions and 17 deletions

View File

@ -6,8 +6,8 @@ import * as util from "../../util";
import * as t from "../../types";
export default class AMDFormatter extends DefaultFormatter {
init() {
CommonFormatter.prototype._init.call(this, this.hasNonDefaultExports);
setup() {
CommonFormatter.prototype._setup.call(this, this.hasNonDefaultExports);
}
buildDependencyLiterals() {

View File

@ -4,11 +4,11 @@ import * as util from "../../util";
import * as t from "../../types";
export default class CommonJSFormatter extends DefaultFormatter {
init() {
this._init(this.hasLocalExports);
setup() {
this._setup(this.hasLocalExports);
}
_init(conditional) {
_setup(conditional) {
var file = this.file;
var scope = file.scope;

View File

@ -85,7 +85,8 @@ export function ExportNamedDeclaration(node, parent, scope) {
}
}
export function Program(node) {
export var Program = {
enter(node) {
var imports = [];
var rest = [];
@ -99,4 +100,13 @@ export function Program(node) {
}
node.body = imports.concat(rest);
},
exit(node, parent, scope, file) {
if (!file.transformers["es6.modules"].canTransform()) return;
if (file.moduleFormatter.setup) {
file.moduleFormatter.setup();
}
}
};

View File

@ -0,0 +1,3 @@
export function module() {
}

View File

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.module = _module;
function _module() {}