ko 5.3.4 → 5.3.7
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/build.js +15 -13
- package/lib/actions/dev.js +6 -3
- package/lib/cli.js +1 -0
- package/lib/webpack/index.js +1 -1
- package/lib/webpack/loaders/script.js +13 -4
- package/package.json +1 -2
- package/scripts/preinstall.js +0 -52
package/lib/actions/build.js
CHANGED
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const webpack_1 = __importDefault(require("webpack"));
|
|
7
|
-
const esbuild_loader_1 = require("esbuild-loader");
|
|
8
7
|
const creator_1 = require("./creator");
|
|
9
8
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
10
9
|
class Build extends creator_1.WebpackCreator {
|
|
@@ -12,28 +11,31 @@ class Build extends creator_1.WebpackCreator {
|
|
|
12
11
|
super(opts);
|
|
13
12
|
}
|
|
14
13
|
config() {
|
|
15
|
-
const { esbuild } = this.opts;
|
|
14
|
+
// const { esbuild } = this.opts;
|
|
16
15
|
const conf = {
|
|
17
16
|
optimization: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
esbuild &&
|
|
21
|
-
new esbuild_loader_1.ESBuildMinifyPlugin({
|
|
22
|
-
target: 'es2015',
|
|
23
|
-
css: true,
|
|
24
|
-
}),
|
|
25
|
-
].filter(Boolean),
|
|
17
|
+
minimize: true,
|
|
18
|
+
minimizer: ['...', new CssMinimizerPlugin()],
|
|
26
19
|
},
|
|
27
20
|
plugins: [
|
|
28
21
|
new webpack_1.default.optimize.SplitChunksPlugin({
|
|
29
|
-
chunks: '
|
|
22
|
+
chunks: 'all',
|
|
30
23
|
minSize: 30000,
|
|
31
24
|
maxSize: 600000,
|
|
32
25
|
minChunks: 1,
|
|
33
|
-
maxAsyncRequests: 5,
|
|
34
|
-
maxInitialRequests: 3,
|
|
35
26
|
automaticNameDelimiter: '_',
|
|
36
27
|
cacheGroups: {
|
|
28
|
+
baseCommon: {
|
|
29
|
+
test: new RegExp(`[\\/]node_modules[\\/](${[
|
|
30
|
+
'react',
|
|
31
|
+
'react-router',
|
|
32
|
+
'react-dom',
|
|
33
|
+
'react-redux',
|
|
34
|
+
'redux',
|
|
35
|
+
'react-router-redux',
|
|
36
|
+
].join('|')})`),
|
|
37
|
+
priority: 1,
|
|
38
|
+
},
|
|
37
39
|
antd: {
|
|
38
40
|
name: 'antd',
|
|
39
41
|
test: /[\\/]node_modules[\\/]antd[\\/]/,
|
package/lib/actions/dev.js
CHANGED
|
@@ -37,6 +37,11 @@ class Dev extends creator_1.WebpackCreator {
|
|
|
37
37
|
const conf = {
|
|
38
38
|
devtool: 'cheap-module-source-map',
|
|
39
39
|
plugins: [this.opts.analyzer && new BundleAnalyzerPlugin()].filter(Boolean),
|
|
40
|
+
optimization: {
|
|
41
|
+
splitChunks: {
|
|
42
|
+
chunks: 'all',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
40
45
|
};
|
|
41
46
|
return this.mergeConfig([this.baseConfig, conf]);
|
|
42
47
|
}
|
|
@@ -77,6 +82,7 @@ class Dev extends creator_1.WebpackCreator {
|
|
|
77
82
|
}
|
|
78
83
|
this.devServerConf.port = newPort;
|
|
79
84
|
webpack_dev_server_1.default.addDevServerEntrypoints(this.config(), this.devServerConf);
|
|
85
|
+
this.threadLoaderWarmUp();
|
|
80
86
|
const compiler = (0, webpack_1.default)(this.config());
|
|
81
87
|
const devServer = new webpack_dev_server_1.default(compiler, this.devServerConf);
|
|
82
88
|
let isFirstCompile = true;
|
|
@@ -91,9 +97,6 @@ class Dev extends creator_1.WebpackCreator {
|
|
|
91
97
|
}));
|
|
92
98
|
}
|
|
93
99
|
});
|
|
94
|
-
compiler.hooks.invalid.tap('invalid', () => {
|
|
95
|
-
console.log('Compiling...');
|
|
96
|
-
});
|
|
97
100
|
devServer.listen(this.devServerConf.port, this.devServerConf.host, err => {
|
|
98
101
|
if (err) {
|
|
99
102
|
console.error(err);
|
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: {
|
|
@@ -7,19 +7,28 @@ const getCacheIdentifier_1 = __importDefault(require("react-dev-utils/getCacheId
|
|
|
7
7
|
const config_1 = __importDefault(require("../../utils/config"));
|
|
8
8
|
const THREAD_LOADER = require.resolve('thread-loader');
|
|
9
9
|
const BABEL_LOADER = require.resolve('babel-loader');
|
|
10
|
+
const WORKER_LOADER = require.resolve('worker-loader');
|
|
10
11
|
const scriptLoader = [
|
|
11
12
|
{
|
|
12
13
|
test: /\.worker.[jt]s$/,
|
|
13
|
-
loader:
|
|
14
|
+
loader: WORKER_LOADER,
|
|
14
15
|
options: {
|
|
15
16
|
inline: 'fallback',
|
|
16
17
|
},
|
|
17
18
|
},
|
|
18
19
|
{
|
|
19
20
|
test: /\.(t|j)sx?$/,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
include: (input) => {
|
|
22
|
+
// internal modules dt-common compatible
|
|
23
|
+
if (input.includes('node_modules/dt-common/src/')) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
else if (input.includes('node_modules')) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
23
32
|
},
|
|
24
33
|
use: [
|
|
25
34
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ko",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.7",
|
|
4
4
|
"description": "build & lint library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ko",
|
|
@@ -86,7 +86,6 @@
|
|
|
86
86
|
"node": ">=10.13.0"
|
|
87
87
|
},
|
|
88
88
|
"scripts": {
|
|
89
|
-
"preinstall": "node scripts/preinstall.js",
|
|
90
89
|
"debug": "tsc -w --sourceMap",
|
|
91
90
|
"test": "jest",
|
|
92
91
|
"build": "tsc"
|
package/scripts/preinstall.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-octal-escape */
|
|
2
|
-
/**
|
|
3
|
-
* @link https://github.com/DTStack/devops/blob/main/force-using-yarn-and-lock-version/preinstall.js
|
|
4
|
-
*/
|
|
5
|
-
let err = false;
|
|
6
|
-
|
|
7
|
-
const LOCK_NODE_VERSION = true;
|
|
8
|
-
const LOCK_YARN_VERSION = false;
|
|
9
|
-
const FORCE_YARN_INSTALL = false;
|
|
10
|
-
|
|
11
|
-
if (LOCK_NODE_VERSION) {
|
|
12
|
-
const majorAndMinorNodeVersion = Number(
|
|
13
|
-
/(\d+).(\d+)/.exec(process.versions.node)[0]
|
|
14
|
-
);
|
|
15
|
-
/**
|
|
16
|
-
* webpack minor support version
|
|
17
|
-
* @link https://webpack.js.org/migrate/5/#preparations
|
|
18
|
-
*/
|
|
19
|
-
const webpack5SupportLeastVersion = 10.13;
|
|
20
|
-
|
|
21
|
-
if (majorAndMinorNodeVersion < webpack5SupportLeastVersion) {
|
|
22
|
-
console.error(
|
|
23
|
-
'\033[1;31m*** Webpack 5 requires at least Node.js 10.13.0 (LTS), please make sure you upgrade your Node.js.\033[0;0m'
|
|
24
|
-
);
|
|
25
|
-
err = true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (LOCK_YARN_VERSION) {
|
|
30
|
-
const cp = require('child_process');
|
|
31
|
-
const yarnVersion = cp.execSync('yarn -v', { encoding: 'utf8' }).trim();
|
|
32
|
-
const parsedYarnVersion = /^(\d+)\.(\d+)\./.exec(yarnVersion);
|
|
33
|
-
const majorYarnVersion = parseInt(parsedYarnVersion[1]);
|
|
34
|
-
const minorYarnVersion = parseInt(parsedYarnVersion[2]);
|
|
35
|
-
|
|
36
|
-
if (majorYarnVersion < 1 || minorYarnVersion < 10) {
|
|
37
|
-
console.error('\033[1;31m*** Please use yarn >=1.10.1.\033[0;0m');
|
|
38
|
-
err = true;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (FORCE_YARN_INSTALL) {
|
|
43
|
-
// eslint-disable-next-line dot-notation
|
|
44
|
-
if (!/yarn[\w-.]*\.js$|yarnpkg$/.test(process.env['npm_execpath'])) {
|
|
45
|
-
console.error(
|
|
46
|
-
'\033[1;31m*** Please use yarn to install dependencies.\033[0;0m'
|
|
47
|
-
);
|
|
48
|
-
err = true;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
err && process.exit(1);
|