Skip to content

Commit 446a07e

Browse files
committed
fix browsertests
1 parent a0bfab2 commit 446a07e

File tree

8 files changed

+83
-56
lines changed

8 files changed

+83
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/node_modules
22
/test/js
33
/test/browsertest/js
4+
/test/browsertest/node_modules/.cache
45
/test/fixtures/temp-cache-fixture
56
/benchmark/js
67
/benchmark/fixtures

test/browsertest/build.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ console.log("compile scripts…");
2828
var extraArgsNoWatch = extraArgs.slice(0);
2929
var watchIndex = extraArgsNoWatch.indexOf("--watch");
3030
if(watchIndex != -1) extraArgsNoWatch.splice(watchIndex, 1);
31-
// node ../../bin/webpack --output-pathinfo --color --optimize-max-chunks 1 --output-library library1 node_modules/library1 js/library1
32-
var library1 = cp.spawn("node", join(["../../bin/webpack.js", "--output-pathinfo", "--color", "--optimize-max-chunks", "1", "--output-library", "library1",
33-
"node_modules/library1", "js/library1.js"], extraArgsNoWatch));
31+
// node ../../bin/webpack --output-pathinfo --color --optimize-max-chunks 1 --output-library library1 node_modules/library1 --output js/library1
32+
var library1 = cp.spawn("node", join(["../../bin/webpack.js", "--mode", "production", "--output-pathinfo", "--color", "--optimize-max-chunks", "1", "--output-library", "library1",
33+
"node_modules/library1", "--output", "js/library1.js"], extraArgsNoWatch));
3434
bindOutput(library1);
3535
library1.on("exit", function(code) {
3636
if(code === 0) {
37-
// node ../../bin/webpack --output-pathinfo --color --resolve-alias vm=vm-browserify --output-public-path js/ --output-chunk-filename [name].web.js --module-bind css=style!css --module-bind less=style-loader!css-loader!less-loader --module-bind coffee --module-bind jade --prefetch ./lib/stylesheet.less ./lib/index "js/web.js?h=[hash]"
37+
// node ../../bin/webpack --output-pathinfo --color --resolve-alias vm=vm-browserify --output-public-path js/ --output-chunk-filename [name].web.js --module-bind css=style!css --module-bind less=style-loader!css-loader!less-loader --module-bind coffee --module-bind jade --prefetch ./lib/stylesheet.less ./lib/index --output "js/web.js?h=[hash]"
3838
var main = cp.spawn("node", join(["../../bin/webpack.js", "--output-pathinfo", "--color", "--resolve-alias", "vm=vm-browserify",
3939
"--output-public-path", "js/", "--output-chunk-filename", "[name].web.js",
40-
"--module-bind", "css=style-loader!css-loader", "--module-bind", "less=style-loader/url!file-loader?postfix=.css&string!less-loader", "--module-bind", "coffee", "--module-bind", "jade", "--prefetch", "./lib/stylesheet.less", "./lib/index", "js/web.js?h=[hash]", "--progress"], extraArgs));
40+
"--module-bind", "css=style-loader!css-loader", "--module-bind", "less=style-loader/url!file-loader?postfix=.css&string!less-loader", "--module-bind", "coffee", "--module-bind", "jade", "--prefetch", "./lib/stylesheet.less", "./lib/index", "--output", "js/web.js?h=[hash]", "--progress"], extraArgs));
4141
bindOutput(main);
4242
}
4343
});
44-
// node ../../bin/webpack --output-pathinfo --color --output-library-target umd --output-jsonp-function webpackJsonpLib2 --output-public-path js/ --output-chunk-filename [chunkhash].lib2.js --config library2config.coffee library2b library2 js/library2.js
44+
// node ../../bin/webpack --output-pathinfo --color --output-library-target umd --output-jsonp-function webpackJsonpLib2 --output-public-path js/ --output-chunk-filename [chunkhash].lib2.js --config library2config.js library2b library2 --output js/library2.js
4545
var library2 = cp.spawn("node", join(["../../bin/webpack.js", "--output-pathinfo", "--color", "--output-library-target", "umd", "--output-jsonp-function", "webpackJsonpLib2",
46-
"--output-public-path", "js/", "--output-chunk-filename", "[chunkhash].lib2.js", "--config", "library2config.coffee", "library2b", "library2", "js/library2.js"], extraArgsNoWatch));
46+
"--output-public-path", "js/", "--output-chunk-filename", "[chunkhash].lib2.js", "--config", "library2config.js", "library2b", "library2", "--output", "js/library2.[name].js"], extraArgsNoWatch));
4747
bindOutput(library2);

test/browsertest/library2config.coffee

Lines changed: 0 additions & 45 deletions
This file was deleted.

test/browsertest/library2config.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"use strict";
2+
3+
const webpack = require("../../");
4+
exports.default = new Promise((resolve, reject) => {
5+
const resolveIt = () => {
6+
resolve({
7+
mode: "production",
8+
entry: {
9+
common: "library2/lib/common"
10+
},
11+
output: {
12+
hashDigestLength: 5
13+
},
14+
module: {
15+
rules: [
16+
{ test: /extra2?\.js/, loader: "raw-loader!./node_modules/extra.loader.js!val-loader?cacheable", enforce: "post" }
17+
]
18+
},
19+
amd: {
20+
fromOptions: true
21+
},
22+
resolve: {
23+
// cannot resolve should outside the outermost node_modules
24+
// so it is injected here
25+
alias: {
26+
should: require.resolve("should")
27+
}
28+
},
29+
optimization: {
30+
minimize: false
31+
},
32+
plugins: [
33+
new webpack.optimize.LimitChunkCountPlugin({
34+
maxChunks: 3
35+
}),
36+
new webpack.DefinePlugin({
37+
"typeof CONST_TYPEOF": JSON.stringify("typeof"),
38+
CONST_UNDEFINED: undefined,
39+
CONST_NULL: "null",
40+
CONST_TRUE: true,
41+
CONST_FALSE: false,
42+
CONST_FUNCTION: function() { return "ok"; },
43+
CONST_NUMBER: 123,
44+
CONST_NUMBER_EXPR: "(1*100+23)",
45+
CONST_OBJECT: {
46+
A: 1,
47+
B: JSON.stringify("B"),
48+
C: () => "C"
49+
}
50+
}),
51+
new webpack.ProvidePlugin({
52+
s3: "submodule3"
53+
}),
54+
function() {
55+
this.plugin("normal-module-factory", (nmf) => {
56+
nmf.plugin("after-resolve", (data, callback) => {
57+
data.resource = data.resource.replace(/extra\.js/, "extra2.js");
58+
callback(null, data);
59+
});
60+
});
61+
}
62+
]
63+
});
64+
};
65+
setTimeout(resolveIt, 300);
66+
});

test/browsertest/node_modules/library2/lib/extra.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/browsertest/node_modules/library2/lib/extra2.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/browsertest/tests.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<script>
1111
mocha.setup('bdd');
1212
</script>
13-
<script src="js/library2.commons.js" charset="utf-8"></script>
14-
<script src="js/library2.js" charset="utf-8"></script>
13+
<script src="js/library2.common.js" charset="utf-8"></script>
14+
<script src="js/library2.main.js" charset="utf-8"></script>
1515
<script src="js/web.js" charset="utf-8"></script>
1616
<!-- fixtures -->
1717
<style>

test/browsertest/webpack.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
mode: "production",
23
resolve: {
34
modules: ["web_modules", "node_modules"],
45
extensions: [".json", ".web.js", ".js"]
@@ -12,5 +13,9 @@ module.exports = {
1213
".js"
1314
],
1415
mainFields: ["webpackLoader", "loader", "main"]
16+
},
17+
optimization: {
18+
noEmitOnErrors: false,
19+
minimize: false
1520
}
1621
};

0 commit comments

Comments
 (0)