mirror of https://github.com/webpack/webpack.git
refactor library tests
This commit is contained in:
parent
d3a0fc980e
commit
c123016b64
|
@ -1,3 +1,4 @@
|
|||
export * from "./a";
|
||||
export default "default-value";
|
||||
export var b = "b";
|
||||
export { default as external } from "external";
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export default "non-external";
|
|
@ -1,5 +1,53 @@
|
|||
module.exports = {
|
||||
output: {
|
||||
libraryTarget: "commonjs-module"
|
||||
module.exports = [
|
||||
{
|
||||
output: {
|
||||
filename: "commonjs.js",
|
||||
libraryTarget: "commonjs-module"
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
external: "./non-external"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
output: {
|
||||
filename: "umd.js",
|
||||
libraryTarget: "umd"
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
external: "./non-external"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
output: {
|
||||
filename: "this.js",
|
||||
libraryTarget: "this"
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
external: "./non-external"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
output: {
|
||||
filename: "global.js",
|
||||
library: "globalName"
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
external: "./non-external"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
output: {
|
||||
filename: "commonjs2-external.js",
|
||||
libraryTarget: "commonjs2"
|
||||
},
|
||||
externals: ["external"]
|
||||
}
|
||||
};
|
||||
];
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
var data = require("library");
|
||||
|
||||
it("should be able get items from library (" + NAME + ")", function() {
|
||||
data.should.have.property("default").be.eql("default-value");
|
||||
data.should.have.property("a").be.eql("a");
|
||||
data.should.have.property("b").be.eql("b");
|
||||
});
|
|
@ -1,8 +1,14 @@
|
|||
import d from "library";
|
||||
import { a, b } from "library";
|
||||
import { a, b, external } from "library";
|
||||
|
||||
it("should be able to import hamorny exports from library", function() {
|
||||
it("should be able to import hamorny exports from library (" + NAME + ")", function() {
|
||||
d.should.be.eql("default-value");
|
||||
a.should.be.eql("a");
|
||||
b.should.be.eql("b");
|
||||
if(typeof TEST_EXTERNAL !== "undefined" && TEST_EXTERNAL) {
|
||||
external.should.be.eql(["external"]);
|
||||
external.should.be.equal(require("external"));
|
||||
} else {
|
||||
external.should.be.eql("non-external");
|
||||
}
|
||||
});
|
|
@ -1,8 +1,55 @@
|
|||
var webpack = require("../../../../");
|
||||
var path = require("path");
|
||||
module.exports = {
|
||||
resolve: {
|
||||
alias: {
|
||||
library: path.resolve(__dirname, "../../../js/config/library/0-create-library/bundle0.js")
|
||||
}
|
||||
module.exports = [
|
||||
{
|
||||
resolve: {
|
||||
alias: {
|
||||
library: path.resolve(__dirname, "../../../js/config/library/0-create-library/commonjs.js")
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
NAME: JSON.stringify("commonjs")
|
||||
})
|
||||
]
|
||||
},
|
||||
{
|
||||
resolve: {
|
||||
alias: {
|
||||
library: path.resolve(__dirname, "../../../js/config/library/0-create-library/umd.js")
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
NAME: JSON.stringify("umd")
|
||||
})
|
||||
]
|
||||
},
|
||||
{
|
||||
entry: "./global-test.js",
|
||||
resolve: {
|
||||
alias: {
|
||||
library: path.resolve(__dirname, "../../../js/config/library/0-create-library/this.js")
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
NAME: JSON.stringify("this")
|
||||
})
|
||||
]
|
||||
},
|
||||
{
|
||||
resolve: {
|
||||
alias: {
|
||||
library: path.resolve(__dirname, "../../../js/config/library/0-create-library/commonjs2-external.js"),
|
||||
external: path.resolve(__dirname, "node_modules/external.js")
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
NAME: JSON.stringify("commonjs2 with external"),
|
||||
TEST_EXTERNAL: true
|
||||
})
|
||||
]
|
||||
}
|
||||
};
|
||||
];
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export var a = "a";
|
|
@ -1,4 +0,0 @@
|
|||
export * from "./a";
|
||||
export default "default-value";
|
||||
export var b = "b";
|
||||
export { default as external } from "external";
|
|
@ -1 +0,0 @@
|
|||
exports.noTests = true;
|
|
@ -1,6 +0,0 @@
|
|||
module.exports = {
|
||||
output: {
|
||||
libraryTarget: "commonjs2"
|
||||
},
|
||||
externals: ["external"]
|
||||
};
|
|
@ -1,10 +0,0 @@
|
|||
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,9 +0,0 @@
|
|||
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")
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue