mirror of https://github.com/webpack/webpack.git
Test/library with external (#3753)
* fixes position of __esModule flag (should be on top) * add testcase for library with external * updated stats test cases
This commit is contained in:
parent
80e177a2a5
commit
29c1fd2417
|
|
@ -26,17 +26,17 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|||
apply(parser) {
|
||||
parser.plugin("export", statement => {
|
||||
const dep = new HarmonyExportHeaderDependency(statement.declaration && statement.declaration.range, statement.range);
|
||||
makeHarmonyModule(parser.state.module, statement.loc);
|
||||
dep.loc = statement.loc;
|
||||
parser.state.current.addDependency(dep);
|
||||
makeHarmonyModule(parser.state.module, statement.loc);
|
||||
return true;
|
||||
});
|
||||
parser.plugin("export import", (statement, source) => {
|
||||
const dep = new HarmonyImportDependency(source, HarmonyModulesHelpers.getNewModuleVar(parser.state, source), statement.range);
|
||||
makeHarmonyModule(parser.state.module, statement.loc);
|
||||
dep.loc = statement.loc;
|
||||
parser.state.current.addDependency(dep);
|
||||
parser.state.lastHarmoryImport = dep;
|
||||
makeHarmonyModule(parser.state.module, statement.loc);
|
||||
return true;
|
||||
});
|
||||
parser.plugin("export expression", (statement, expr) => {
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
export var a = "a";
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
export * from "./a";
|
||||
export default "default-value";
|
||||
export var b = "b";
|
||||
export { default as external } from "external";
|
||||
|
|
@ -0,0 +1 @@
|
|||
exports.noTests = true;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
output: {
|
||||
libraryTarget: "commonjs2"
|
||||
},
|
||||
externals: ["external"]
|
||||
};
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import d from "library";
|
||||
import { a, b, external } from "library";
|
||||
|
||||
it("should be able to import hamorny exports from library", function() {
|
||||
d.should.be.eql("default-value");
|
||||
a.should.be.eql("a");
|
||||
b.should.be.eql("b");
|
||||
external.should.be.eql(["external"]);
|
||||
external.should.be.equal(require("external"));
|
||||
});
|
||||
1
test/configCases/library/3-use-library-with-external/node_modules/external.js
generated
vendored
Normal file
1
test/configCases/library/3-use-library-with-external/node_modules/external.js
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
module.exports = ["external"];
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
var path = require("path");
|
||||
module.exports = {
|
||||
resolve: {
|
||||
alias: {
|
||||
library: path.resolve(__dirname, "../../../js/config/library/2-create-library-with-external/bundle0.js"),
|
||||
external: path.resolve(__dirname, "node_modules/external.js")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
Hash: e94a2c6bee98efb02ae8
|
||||
Hash: 264630d9963a6039f9e0
|
||||
Time: Xms
|
||||
Asset Size Chunks Chunk Names
|
||||
bundle.js 7.16 kB 0 [emitted] main
|
||||
|
|
|
|||
Loading…
Reference in New Issue