ko 5.3.2 → 5.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actions/dev.js +44 -23
- package/lib/cli.js +1 -0
- package/lib/webpack/index.js +15 -2
- package/lib/webpack/loaders/script.js +7 -1
- package/package.json +7 -2
package/lib/actions/dev.js
CHANGED
|
@@ -13,32 +13,35 @@ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
|
|
13
13
|
class Dev extends creator_1.WebpackCreator {
|
|
14
14
|
constructor(opts) {
|
|
15
15
|
super(opts);
|
|
16
|
-
}
|
|
17
|
-
devSerConf() {
|
|
18
|
-
const userDefinedDevServerConfig = config_1.default.userConf.devServer || {};
|
|
19
16
|
const { port, host } = this.opts;
|
|
20
|
-
const
|
|
17
|
+
const userDefinedDevServerConfig = config_1.default.userConf.devServer || {};
|
|
18
|
+
this.devServerConf = {
|
|
21
19
|
port,
|
|
22
20
|
host,
|
|
21
|
+
contentBase: config_1.default.defaultPaths.dist,
|
|
23
22
|
historyApiFallback: true,
|
|
24
|
-
|
|
23
|
+
disableHostCheck: true,
|
|
24
|
+
compress: true,
|
|
25
|
+
clientLogLevel: 'none',
|
|
25
26
|
hot: true,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
client: {
|
|
32
|
-
overlay: false,
|
|
27
|
+
inline: true,
|
|
28
|
+
publicPath: '/',
|
|
29
|
+
watchOptions: {
|
|
30
|
+
ignored: /node_modules/,
|
|
31
|
+
aggregateTimeout: 600,
|
|
33
32
|
},
|
|
34
|
-
|
|
33
|
+
...userDefinedDevServerConfig,
|
|
35
34
|
};
|
|
36
|
-
return { ...defaultDevServerConfig, ...userDefinedDevServerConfig };
|
|
37
35
|
}
|
|
38
36
|
config() {
|
|
39
37
|
const conf = {
|
|
40
38
|
devtool: 'cheap-module-source-map',
|
|
41
39
|
plugins: [this.opts.analyzer && new BundleAnalyzerPlugin()].filter(Boolean),
|
|
40
|
+
optimization: {
|
|
41
|
+
splitChunks: {
|
|
42
|
+
chunks: 'all',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
42
45
|
};
|
|
43
46
|
return this.mergeConfig([this.baseConfig, conf]);
|
|
44
47
|
}
|
|
@@ -67,20 +70,38 @@ class Dev extends creator_1.WebpackCreator {
|
|
|
67
70
|
return this.changePort(newPort, port);
|
|
68
71
|
}
|
|
69
72
|
}
|
|
73
|
+
threadLoaderWarmUp() {
|
|
74
|
+
const threadLoader = require('thread-loader');
|
|
75
|
+
threadLoader.warmup({}, [require.resolve('babel-loader')]);
|
|
76
|
+
}
|
|
70
77
|
async action() {
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const newPort = await this.checkPort(parseInt(port));
|
|
78
|
+
const { port } = this.devServerConf;
|
|
79
|
+
const newPort = await this.checkPort(port);
|
|
74
80
|
if (!newPort) {
|
|
75
81
|
process.exit(0);
|
|
76
82
|
}
|
|
77
|
-
|
|
83
|
+
this.devServerConf.port = newPort;
|
|
84
|
+
webpack_dev_server_1.default.addDevServerEntrypoints(this.config(), this.devServerConf);
|
|
85
|
+
this.threadLoaderWarmUp();
|
|
78
86
|
const compiler = (0, webpack_1.default)(this.config());
|
|
79
|
-
const devServer = new webpack_dev_server_1.default(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
const devServer = new webpack_dev_server_1.default(compiler, this.devServerConf);
|
|
88
|
+
let isFirstCompile = true;
|
|
89
|
+
compiler.hooks.done.tap('done', stats => {
|
|
90
|
+
if (isFirstCompile) {
|
|
91
|
+
isFirstCompile = false;
|
|
92
|
+
this.successStdout('development server has been started');
|
|
93
|
+
}
|
|
94
|
+
if (stats.hasErrors()) {
|
|
95
|
+
console.log(stats.toString({
|
|
96
|
+
colors: true,
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
devServer.listen(this.devServerConf.port, this.devServerConf.host, err => {
|
|
101
|
+
if (err) {
|
|
102
|
+
console.error(err);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
84
105
|
});
|
|
85
106
|
}
|
|
86
107
|
}
|
package/lib/cli.js
CHANGED
|
@@ -30,6 +30,7 @@ program
|
|
|
30
30
|
.option('-p, --port <port>', 'server start on which port', parseInt)
|
|
31
31
|
.option('--host <host>', 'specify a host to use')
|
|
32
32
|
.option('-t, --ts', 'support typescript')
|
|
33
|
+
.option('-h, --hash', 'output file name with hash')
|
|
33
34
|
.option('-a,--analyzer', 'support building analyzer')
|
|
34
35
|
.action((opts) => {
|
|
35
36
|
process.env.NODE_ENV = 'development';
|
package/lib/webpack/index.js
CHANGED
|
@@ -28,7 +28,7 @@ function getWebpackBaseConf(opts) {
|
|
|
28
28
|
entry: `src/index.${ts ? 'tsx' : 'js'}`,
|
|
29
29
|
output: {
|
|
30
30
|
path: config_1.default.defaultPaths.dist,
|
|
31
|
-
filename: hash ? '
|
|
31
|
+
filename: hash ? '[name].[contenthash].js' : '[name].js',
|
|
32
32
|
publicPath: '/',
|
|
33
33
|
},
|
|
34
34
|
module: {
|
|
@@ -43,12 +43,25 @@ function getWebpackBaseConf(opts) {
|
|
|
43
43
|
configFile: config_1.default.defaultPaths.tsconfig,
|
|
44
44
|
}),
|
|
45
45
|
].filter(Boolean),
|
|
46
|
+
fallback: {
|
|
47
|
+
fs: false,
|
|
48
|
+
path: false,
|
|
49
|
+
events: false,
|
|
50
|
+
os: require.resolve('os-browserify/browser'),
|
|
51
|
+
crypto: require.resolve('crypto-browserify'),
|
|
52
|
+
stream: require.resolve('stream-browserify'),
|
|
53
|
+
buffer: require.resolve('buffer/'),
|
|
54
|
+
string_decoder: require.resolve('string_decoder/'),
|
|
55
|
+
},
|
|
46
56
|
},
|
|
47
57
|
performance: {
|
|
48
58
|
hints: false,
|
|
49
59
|
},
|
|
50
60
|
cache: {
|
|
51
|
-
type: 'filesystem',
|
|
61
|
+
type: config_1.default.isProductionEnv ? 'filesystem' : 'memory',
|
|
62
|
+
},
|
|
63
|
+
stats: {
|
|
64
|
+
cachedModules: false,
|
|
52
65
|
},
|
|
53
66
|
};
|
|
54
67
|
return webpackBaseConf;
|
|
@@ -22,7 +22,13 @@ const scriptLoader = [
|
|
|
22
22
|
not: [/dt-common/],
|
|
23
23
|
},
|
|
24
24
|
use: [
|
|
25
|
-
|
|
25
|
+
{
|
|
26
|
+
loader: THREAD_LOADER,
|
|
27
|
+
options: {
|
|
28
|
+
workerNodeArgs: ['--max-old-space-size=4096'],
|
|
29
|
+
name: 'ko-js-pool',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
26
32
|
{
|
|
27
33
|
loader: BABEL_LOADER,
|
|
28
34
|
options: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ko",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.5",
|
|
4
4
|
"description": "build & lint library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ko",
|
|
@@ -40,10 +40,12 @@
|
|
|
40
40
|
"autoprefixer": "^10.4.2",
|
|
41
41
|
"babel-loader": "^8.2.3",
|
|
42
42
|
"babel-preset-ko-app": "^1.0.0",
|
|
43
|
+
"buffer": "^6.0.3",
|
|
43
44
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
44
45
|
"chalk": "^4.1.2",
|
|
45
46
|
"clean-webpack-plugin": "4.0.0",
|
|
46
47
|
"commander": "^9.0.0",
|
|
48
|
+
"crypto-browserify": "^3.12.0",
|
|
47
49
|
"css-loader": "^6.6.0",
|
|
48
50
|
"css-minimizer-webpack-plugin": "^3.4.1",
|
|
49
51
|
"detect-port": "^1.3.0",
|
|
@@ -52,17 +54,20 @@
|
|
|
52
54
|
"less": "^3.13.1",
|
|
53
55
|
"less-loader": "^9.1.0",
|
|
54
56
|
"mini-css-extract-plugin": "^2.5.3",
|
|
57
|
+
"os-browserify": "^0.3.0",
|
|
55
58
|
"postcss": "^8.4.7",
|
|
56
59
|
"postcss-loader": "^6.2.1",
|
|
57
60
|
"react-dev-utils": "^12.0.0",
|
|
58
61
|
"react-refresh": "^0.11.0",
|
|
59
62
|
"sass": "^1.49.9",
|
|
60
63
|
"sass-loader": "^12.6.0",
|
|
64
|
+
"stream-browserify": "^3.0.0",
|
|
65
|
+
"string_decoder": "^1.3.0",
|
|
61
66
|
"thread-loader": "^3.0.4",
|
|
62
67
|
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
63
68
|
"webpack": "^5.69.1",
|
|
64
69
|
"webpack-bundle-analyzer": "^4.5.0",
|
|
65
|
-
"webpack-dev-server": "
|
|
70
|
+
"webpack-dev-server": "3.11.3",
|
|
66
71
|
"webpack-merge": "^5.8.0",
|
|
67
72
|
"webpackbar": "^5.0.2",
|
|
68
73
|
"worker-loader": "^3.0.8"
|