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:
Tobias Koppers 2017-01-05 03:18:23 +01:00 committed by Sean Larkin
parent 80e177a2a5
commit 29c1fd2417
9 changed files with 35 additions and 3 deletions

View File

@ -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) => {

View File

@ -0,0 +1 @@
export var a = "a";

View File

@ -0,0 +1,4 @@
export * from "./a";
export default "default-value";
export var b = "b";
export { default as external } from "external";

View File

@ -0,0 +1 @@
exports.noTests = true;

View File

@ -0,0 +1,6 @@
module.exports = {
output: {
libraryTarget: "commonjs2"
},
externals: ["external"]
};

View File

@ -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"));
});

View File

@ -0,0 +1 @@
module.exports = ["external"];

View File

@ -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")
}
}
};

View File

@ -1,4 +1,4 @@
Hash: e94a2c6bee98efb02ae8
Hash: 264630d9963a6039f9e0
Time: Xms
Asset Size Chunks Chunk Names
bundle.js 7.16 kB 0 [emitted] main