ko 5.3.1 → 5.3.4
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 -25
- package/lib/cli.js +1 -0
- package/lib/webpack/index.js +14 -1
- package/lib/webpack/loaders/script.js +10 -3
- package/lib/webpack/plugins.js +1 -13
- package/package.json +7 -3
package/lib/actions/dev.js
CHANGED
|
@@ -13,28 +13,25 @@ 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
|
-
|
|
27
|
+
inline: true,
|
|
28
|
+
publicPath: '/',
|
|
29
|
+
watchOptions: {
|
|
30
|
+
ignored: /node_modules/,
|
|
31
|
+
aggregateTimeout: 600,
|
|
30
32
|
},
|
|
31
|
-
|
|
32
|
-
overlay: false,
|
|
33
|
-
},
|
|
34
|
-
setupExitSignals: true,
|
|
35
|
-
open: true,
|
|
33
|
+
...userDefinedDevServerConfig,
|
|
36
34
|
};
|
|
37
|
-
return { ...defaultDevServerConfig, ...userDefinedDevServerConfig };
|
|
38
35
|
}
|
|
39
36
|
config() {
|
|
40
37
|
const conf = {
|
|
@@ -68,19 +65,41 @@ class Dev extends creator_1.WebpackCreator {
|
|
|
68
65
|
return this.changePort(newPort, port);
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
68
|
+
threadLoaderWarmUp() {
|
|
69
|
+
const threadLoader = require('thread-loader');
|
|
70
|
+
threadLoader.warmup({}, [require.resolve('babel-loader')]);
|
|
74
71
|
}
|
|
75
72
|
async action() {
|
|
76
|
-
const { port
|
|
77
|
-
const newPort = await this.checkPort(
|
|
78
|
-
if (!newPort)
|
|
79
|
-
|
|
73
|
+
const { port } = this.devServerConf;
|
|
74
|
+
const newPort = await this.checkPort(port);
|
|
75
|
+
if (!newPort) {
|
|
76
|
+
process.exit(0);
|
|
77
|
+
}
|
|
78
|
+
this.devServerConf.port = newPort;
|
|
79
|
+
webpack_dev_server_1.default.addDevServerEntrypoints(this.config(), this.devServerConf);
|
|
80
80
|
const compiler = (0, webpack_1.default)(this.config());
|
|
81
|
-
const devServer = new webpack_dev_server_1.default(this.
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const devServer = new webpack_dev_server_1.default(compiler, this.devServerConf);
|
|
82
|
+
let isFirstCompile = true;
|
|
83
|
+
compiler.hooks.done.tap('done', stats => {
|
|
84
|
+
if (isFirstCompile) {
|
|
85
|
+
isFirstCompile = false;
|
|
86
|
+
this.successStdout('development server has been started');
|
|
87
|
+
}
|
|
88
|
+
if (stats.hasErrors()) {
|
|
89
|
+
console.log(stats.toString({
|
|
90
|
+
colors: true,
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
compiler.hooks.invalid.tap('invalid', () => {
|
|
95
|
+
console.log('Compiling...');
|
|
96
|
+
});
|
|
97
|
+
devServer.listen(this.devServerConf.port, this.devServerConf.host, err => {
|
|
98
|
+
if (err) {
|
|
99
|
+
console.error(err);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
84
103
|
}
|
|
85
104
|
}
|
|
86
105
|
exports.default = Dev;
|
package/lib/cli.js
CHANGED
package/lib/webpack/index.js
CHANGED
|
@@ -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: {
|
|
@@ -31,11 +37,12 @@ const scriptLoader = [
|
|
|
31
37
|
require.resolve('babel-preset-ko-app'),
|
|
32
38
|
{
|
|
33
39
|
useAbsoluteRuntime: true,
|
|
34
|
-
customizePlugins: config_1.default.babelPlugins,
|
|
35
40
|
},
|
|
36
41
|
],
|
|
37
42
|
],
|
|
38
|
-
plugins:
|
|
43
|
+
plugins: config_1.default.isProductionEnv
|
|
44
|
+
? [require.resolve('react-refresh/babel')]
|
|
45
|
+
: [],
|
|
39
46
|
babelrc: false,
|
|
40
47
|
configFile: false,
|
|
41
48
|
cacheIdentifier: (0, getCacheIdentifier_1.default)(config_1.default.isProductionEnv ? 'production' : '', ['babel-preset-ko-app', 'react-dev-utils', 'ko']),
|
package/lib/webpack/plugins.js
CHANGED
|
@@ -6,15 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const webpack_1 = require("webpack");
|
|
7
7
|
const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
|
|
8
8
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
9
|
-
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
10
9
|
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
11
10
|
const webpackbar_1 = __importDefault(require("webpackbar"));
|
|
12
11
|
const config_1 = __importDefault(require("../utils/config"));
|
|
13
12
|
function getPlugins() {
|
|
14
|
-
const { userConf
|
|
15
|
-
const publicPath = userConf.output && userConf.output.publicPath
|
|
16
|
-
? userConf.output.publicPath
|
|
17
|
-
: '/';
|
|
13
|
+
const { userConf } = config_1.default;
|
|
18
14
|
let plugins = [
|
|
19
15
|
new webpack_1.IgnorePlugin({
|
|
20
16
|
resourceRegExp: /^\.\/locale$/,
|
|
@@ -26,14 +22,6 @@ function getPlugins() {
|
|
|
26
22
|
chunkFilename: 'css/[id].[contenthash].css',
|
|
27
23
|
}),
|
|
28
24
|
new case_sensitive_paths_webpack_plugin_1.default(),
|
|
29
|
-
new html_webpack_plugin_1.default({
|
|
30
|
-
template: defaultPaths.html,
|
|
31
|
-
title: 'Ko App',
|
|
32
|
-
templateParameters: {
|
|
33
|
-
configPath: `${publicPath}config/config.js`,
|
|
34
|
-
},
|
|
35
|
-
inject: 'body',
|
|
36
|
-
}),
|
|
37
25
|
new react_refresh_webpack_plugin_1.default(),
|
|
38
26
|
new webpackbar_1.default(),
|
|
39
27
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ko",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.4",
|
|
4
4
|
"description": "build & lint library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ko",
|
|
@@ -40,30 +40,34 @@
|
|
|
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",
|
|
50
52
|
"esbuild-loader": "^2.18.0",
|
|
51
|
-
"html-webpack-plugin": "^5.5.0",
|
|
52
53
|
"inquirer": "^8.2.0",
|
|
53
54
|
"less": "^3.13.1",
|
|
54
55
|
"less-loader": "^9.1.0",
|
|
55
56
|
"mini-css-extract-plugin": "^2.5.3",
|
|
57
|
+
"os-browserify": "^0.3.0",
|
|
56
58
|
"postcss": "^8.4.7",
|
|
57
59
|
"postcss-loader": "^6.2.1",
|
|
58
60
|
"react-dev-utils": "^12.0.0",
|
|
59
61
|
"react-refresh": "^0.11.0",
|
|
60
62
|
"sass": "^1.49.9",
|
|
61
63
|
"sass-loader": "^12.6.0",
|
|
64
|
+
"stream-browserify": "^3.0.0",
|
|
65
|
+
"string_decoder": "^1.3.0",
|
|
62
66
|
"thread-loader": "^3.0.4",
|
|
63
67
|
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
64
68
|
"webpack": "^5.69.1",
|
|
65
69
|
"webpack-bundle-analyzer": "^4.5.0",
|
|
66
|
-
"webpack-dev-server": "
|
|
70
|
+
"webpack-dev-server": "3.11.3",
|
|
67
71
|
"webpack-merge": "^5.8.0",
|
|
68
72
|
"webpackbar": "^5.0.2",
|
|
69
73
|
"worker-loader": "^3.0.8"
|