mirror of https://github.com/webpack/webpack.git
parent
2edd1ad5eb
commit
f4ba0d0f0a
|
@ -652,8 +652,12 @@ Parser.prototype.walkSpreadElement = function walkSpreadElement(expression) {
|
|||
Parser.prototype.walkObjectExpression = function walkObjectExpression(expression) {
|
||||
expression.properties.forEach(function(prop) {
|
||||
if(prop.computed)
|
||||
this.walkExpression(prop.key)
|
||||
this.walkExpression(prop.key);
|
||||
if(prop.shorthand)
|
||||
this.scope.inShorthand = true;
|
||||
this.walkExpression(prop.value);
|
||||
if(prop.shorthand)
|
||||
this.scope.inShorthand = false;
|
||||
}, this);
|
||||
};
|
||||
|
||||
|
@ -858,6 +862,7 @@ Parser.prototype.inScope = function inScope(params, fn) {
|
|||
var oldScope = this.scope;
|
||||
this.scope = {
|
||||
inTry: false,
|
||||
inShorthand: false,
|
||||
definitions: oldScope.definitions.slice(),
|
||||
renames: Object.create(oldScope.renames)
|
||||
};
|
||||
|
|
|
@ -29,6 +29,7 @@ module.exports = AbstractPlugin.create({
|
|||
var name = expr.name;
|
||||
var settings = this.state.harmonySpecifier["$" + name];
|
||||
var dep = new HarmonyImportSpecifierDependency(settings[0], settings[1], settings[2], name, expr.range);
|
||||
dep.shorthand = this.scope.inShorthand;
|
||||
dep.loc = expr.loc;
|
||||
this.state.current.addDependency(dep);
|
||||
return true;
|
||||
|
|
|
@ -51,11 +51,15 @@ HarmonyImportSpecifierDependency.Template.prototype.apply = function(dep, source
|
|||
} else {
|
||||
content = dep.importedVar;
|
||||
}
|
||||
if(!dep.call) {
|
||||
source.replace(dep.range[0], dep.range[1] - 1, content);
|
||||
} else if(defaultImport) {
|
||||
source.replace(dep.range[0], dep.range[1] - 1, dep.importedVar + "_default()");
|
||||
if(dep.call) {
|
||||
if(defaultImport) {
|
||||
content = dep.importedVar + "_default()";
|
||||
} else {
|
||||
source.replace(dep.range[0], dep.range[1] - 1, "__webpack_require__.i(" + content + ")");
|
||||
content = "__webpack_require__.i(" + content + ")";
|
||||
}
|
||||
}
|
||||
if(dep.shorthand) {
|
||||
content = dep.name + ": " + content;
|
||||
}
|
||||
source.replace(dep.range[0], dep.range[1] - 1, content);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import { a, a as aa } from "./module";
|
||||
import b from "./module";
|
||||
import * as c from "./module";
|
||||
|
||||
it("should import into object shorthand", function() {
|
||||
var o = {
|
||||
a,
|
||||
aa,
|
||||
b,
|
||||
c
|
||||
};
|
||||
o.should.be.eql({
|
||||
a: 123,
|
||||
aa: 123,
|
||||
b: 456,
|
||||
c: {
|
||||
a: 123,
|
||||
default: 456
|
||||
}
|
||||
});
|
||||
})
|
|
@ -0,0 +1,2 @@
|
|||
export var a = 123;
|
||||
export default 456;
|
|
@ -0,0 +1,5 @@
|
|||
var supportsES6 = require("../../../helpers/supportsES6");
|
||||
|
||||
module.exports = function(config) {
|
||||
return !config.minimize && supportsES6();
|
||||
};
|
Loading…
Reference in New Issue