ko 5.3.5 → 5.3.8
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/webpack/loaders/script.js +13 -4
- package/lib/webpack/loaders/style.js +2 -0
- package/package.json +1 -2
- package/lib/utils/config.test.js +0 -30
- 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[\\/]/,
|
|
@@ -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
|
{
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
6
7
|
const mini_css_extract_plugin_1 = require("mini-css-extract-plugin");
|
|
7
8
|
const autoprefixer_1 = __importDefault(require("autoprefixer"));
|
|
8
9
|
const CSS_LOADER = require.resolve('css-loader');
|
|
@@ -49,6 +50,7 @@ const styleLoaders = [
|
|
|
49
50
|
},
|
|
50
51
|
{
|
|
51
52
|
test: /\.less$/,
|
|
53
|
+
exclude: [path_1.default.join(process.cwd(), 'node_modules/antd-v4')],
|
|
52
54
|
use: [
|
|
53
55
|
styleLoader,
|
|
54
56
|
cssLoader,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ko",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.8",
|
|
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/lib/utils/config.test.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const config_1 = __importDefault(require("./config"));
|
|
7
|
-
console.log(typeof config_1.default.getFileRealPath);
|
|
8
|
-
describe('config instance', () => {
|
|
9
|
-
it('getFileRealPath should return absolute path', () => {
|
|
10
|
-
const absolutePath = '/foo/bar';
|
|
11
|
-
expect(config_1.default.getFileRealPath(absolutePath)).toBe(absolutePath);
|
|
12
|
-
const relativePath = 'ko.config.js';
|
|
13
|
-
expect(config_1.default.getFileRealPath(relativePath)).toBe(process.cwd() + '/' + relativePath);
|
|
14
|
-
});
|
|
15
|
-
it('userConf should throw', () => {
|
|
16
|
-
expect(() => {
|
|
17
|
-
config_1.default.userConf;
|
|
18
|
-
}).toThrow();
|
|
19
|
-
});
|
|
20
|
-
it('defaultPaths should ', () => {
|
|
21
|
-
const cwd = process.cwd();
|
|
22
|
-
expect(config_1.default.defaultPaths).toEqual({
|
|
23
|
-
src: cwd + '/src',
|
|
24
|
-
dist: cwd + '/dist',
|
|
25
|
-
public: cwd + '/public',
|
|
26
|
-
html: cwd + '/public/index.html',
|
|
27
|
-
tsconfig: cwd + '/tsconfig.json',
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
});
|
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);
|