ko 5.2.2 → 5.3.0
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 +9 -8
- package/lib/actions/dev.js +11 -21
- package/lib/cli.js +0 -0
- package/lib/utils/config.js +1 -1
- package/lib/utils/config.test.js +1 -1
- package/lib/webpack/index.js +9 -8
- package/lib/webpack/loaders/index.js +2 -4
- package/lib/webpack/loaders/script.js +30 -48
- package/lib/webpack/loaders/style.js +2 -6
- package/lib/webpack/plugins.js +7 -18
- package/package.json +40 -41
- package/scripts/preinstall.js +2 -2
package/lib/actions/build.js
CHANGED
|
@@ -17,11 +17,12 @@ class Build extends creator_1.WebpackCreator {
|
|
|
17
17
|
optimization: {
|
|
18
18
|
minimizer: [
|
|
19
19
|
!esbuild && new CssMinimizerPlugin(),
|
|
20
|
-
esbuild &&
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
esbuild &&
|
|
21
|
+
new esbuild_loader_1.ESBuildMinifyPlugin({
|
|
22
|
+
target: 'es2015',
|
|
23
|
+
css: true,
|
|
24
|
+
}),
|
|
25
|
+
].filter(Boolean),
|
|
25
26
|
},
|
|
26
27
|
plugins: [
|
|
27
28
|
new webpack_1.default.optimize.SplitChunksPlugin({
|
|
@@ -50,8 +51,8 @@ class Build extends creator_1.WebpackCreator {
|
|
|
50
51
|
reuseExistingChunk: true,
|
|
51
52
|
},
|
|
52
53
|
},
|
|
53
|
-
})
|
|
54
|
-
]
|
|
54
|
+
}),
|
|
55
|
+
],
|
|
55
56
|
};
|
|
56
57
|
return this.mergeConfig([this.baseConfig, conf]);
|
|
57
58
|
}
|
|
@@ -61,7 +62,7 @@ class Build extends creator_1.WebpackCreator {
|
|
|
61
62
|
if (stats && stats.hasErrors()) {
|
|
62
63
|
throw stats.toString({
|
|
63
64
|
logging: 'warn',
|
|
64
|
-
colors: true
|
|
65
|
+
colors: true,
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
if (error) {
|
package/lib/actions/dev.js
CHANGED
|
@@ -20,19 +20,15 @@ class Dev extends creator_1.WebpackCreator {
|
|
|
20
20
|
const defaultDevServerConfig = {
|
|
21
21
|
port,
|
|
22
22
|
host,
|
|
23
|
-
contentBase: config_1.default.defaultPaths.dist,
|
|
24
23
|
historyApiFallback: true,
|
|
25
|
-
|
|
26
|
-
compress: true,
|
|
27
|
-
clientLogLevel: 'none',
|
|
24
|
+
allowedHosts: "all",
|
|
28
25
|
hot: true,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
aggregateTimeout: 600,
|
|
26
|
+
static: {
|
|
27
|
+
directory: config_1.default.defaultPaths.dist,
|
|
28
|
+
publicPath: '/',
|
|
29
|
+
watch: true,
|
|
34
30
|
},
|
|
35
|
-
open: true
|
|
31
|
+
open: true,
|
|
36
32
|
};
|
|
37
33
|
return { ...defaultDevServerConfig, ...userDefinedDevServerConfig };
|
|
38
34
|
}
|
|
@@ -41,7 +37,7 @@ class Dev extends creator_1.WebpackCreator {
|
|
|
41
37
|
devtool: 'cheap-module-source-map',
|
|
42
38
|
plugins: [
|
|
43
39
|
new webpack_1.default.HotModuleReplacementPlugin(),
|
|
44
|
-
this.opts.analyzer && new BundleAnalyzerPlugin()
|
|
40
|
+
this.opts.analyzer && new BundleAnalyzerPlugin(),
|
|
45
41
|
].filter(Boolean),
|
|
46
42
|
};
|
|
47
43
|
return this.mergeConfig([this.baseConfig, conf]);
|
|
@@ -80,11 +76,10 @@ class Dev extends creator_1.WebpackCreator {
|
|
|
80
76
|
const newPort = await this.checkPort(parseInt(port));
|
|
81
77
|
if (!newPort)
|
|
82
78
|
return;
|
|
83
|
-
webpack_dev_server_1.default.addDevServerEntrypoints(this.config(), this.devSerConf());
|
|
84
79
|
const compiler = (0, webpack_1.default)(this.config());
|
|
85
|
-
const devServer = new webpack_dev_server_1.default(
|
|
80
|
+
const devServer = new webpack_dev_server_1.default(this.devSerConf(), compiler);
|
|
86
81
|
let isFirstCompile = true;
|
|
87
|
-
compiler.hooks.done.tap('done',
|
|
82
|
+
compiler.hooks.done.tap('done', stats => {
|
|
88
83
|
if (isFirstCompile) {
|
|
89
84
|
isFirstCompile = false;
|
|
90
85
|
this.successStdout('development server has been started');
|
|
@@ -92,19 +87,14 @@ class Dev extends creator_1.WebpackCreator {
|
|
|
92
87
|
}
|
|
93
88
|
if (stats.hasErrors()) {
|
|
94
89
|
console.log(stats.toString({
|
|
95
|
-
colors: true
|
|
90
|
+
colors: true,
|
|
96
91
|
}));
|
|
97
92
|
}
|
|
98
93
|
});
|
|
99
94
|
compiler.hooks.invalid.tap('invalid', () => {
|
|
100
95
|
console.log('Compiling...');
|
|
101
96
|
});
|
|
102
|
-
devServer.
|
|
103
|
-
if (err) {
|
|
104
|
-
console.error(err);
|
|
105
|
-
process.exit(500);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
97
|
+
devServer.start();
|
|
108
98
|
}
|
|
109
99
|
}
|
|
110
100
|
exports.default = Dev;
|
package/lib/cli.js
CHANGED
|
File without changes
|
package/lib/utils/config.js
CHANGED
|
@@ -31,7 +31,7 @@ class Config {
|
|
|
31
31
|
dist: this.getFileRealPath('dist'),
|
|
32
32
|
public: this.getFileRealPath('public'),
|
|
33
33
|
html: this.getFileRealPath('public/index.html'),
|
|
34
|
-
tsconfig: this.getFileRealPath('tsconfig.json')
|
|
34
|
+
tsconfig: this.getFileRealPath('tsconfig.json'),
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
get isProductionEnv() {
|
package/lib/utils/config.test.js
CHANGED
package/lib/webpack/index.js
CHANGED
|
@@ -20,7 +20,7 @@ const extensions = [
|
|
|
20
20
|
'.html',
|
|
21
21
|
];
|
|
22
22
|
function getWebpackBaseConf(opts) {
|
|
23
|
-
const { ts, hash } = opts;
|
|
23
|
+
const { ts = true, hash } = opts;
|
|
24
24
|
const webpackBaseConf = {
|
|
25
25
|
mode: config_1.default.isProductionEnv ? 'production' : 'development',
|
|
26
26
|
target: 'web',
|
|
@@ -32,23 +32,24 @@ function getWebpackBaseConf(opts) {
|
|
|
32
32
|
publicPath: '/',
|
|
33
33
|
},
|
|
34
34
|
module: {
|
|
35
|
-
rules:
|
|
35
|
+
rules: loaders_1.default,
|
|
36
36
|
},
|
|
37
|
-
plugins: (0, plugins_1.default)(
|
|
37
|
+
plugins: (0, plugins_1.default)(),
|
|
38
38
|
resolve: {
|
|
39
39
|
extensions,
|
|
40
40
|
plugins: [
|
|
41
|
-
ts &&
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
ts &&
|
|
42
|
+
new tsconfig_paths_webpack_plugin_1.default({
|
|
43
|
+
configFile: config_1.default.defaultPaths.tsconfig,
|
|
44
|
+
}),
|
|
45
|
+
].filter(Boolean),
|
|
45
46
|
},
|
|
46
47
|
performance: {
|
|
47
48
|
hints: false,
|
|
48
49
|
},
|
|
49
50
|
cache: {
|
|
50
51
|
type: 'filesystem',
|
|
51
|
-
}
|
|
52
|
+
},
|
|
52
53
|
};
|
|
53
54
|
return webpackBaseConf;
|
|
54
55
|
}
|
|
@@ -6,7 +6,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const style_1 = __importDefault(require("./style"));
|
|
7
7
|
const asset_1 = __importDefault(require("./asset"));
|
|
8
8
|
const script_1 = __importDefault(require("./script"));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
exports.default = getLoaders;
|
|
9
|
+
const loaders = [...style_1.default, ...asset_1.default, ...script_1.default];
|
|
10
|
+
exports.default = loaders;
|
|
@@ -7,53 +7,35 @@ 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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
THREAD_LOADER,
|
|
17
|
-
{
|
|
18
|
-
loader: BABEL_LOADER,
|
|
19
|
-
options: {
|
|
20
|
-
presets: [
|
|
21
|
-
[
|
|
22
|
-
require.resolve('babel-preset-ko-app'),
|
|
23
|
-
{
|
|
24
|
-
useAbsoluteRuntime: true,
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
],
|
|
28
|
-
babelrc: false,
|
|
29
|
-
configFile: false,
|
|
30
|
-
cacheIdentifier: (0, getCacheIdentifier_1.default)(config_1.default.isProductionEnv ? 'production' : '', ['babel-preset-ko-app', 'react-dev-utils', 'ko']),
|
|
31
|
-
cacheDirectory: true,
|
|
32
|
-
cacheCompression: false,
|
|
33
|
-
compact: config_1.default.isProductionEnv,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
],
|
|
10
|
+
const scriptLoader = [
|
|
11
|
+
{
|
|
12
|
+
test: /\.(t|j)sx?$/,
|
|
13
|
+
exclude: {
|
|
14
|
+
and: [/node_modules/],
|
|
15
|
+
not: [/dt-common/],
|
|
37
16
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
17
|
+
use: [
|
|
18
|
+
THREAD_LOADER,
|
|
19
|
+
{
|
|
20
|
+
loader: BABEL_LOADER,
|
|
21
|
+
options: {
|
|
22
|
+
presets: [
|
|
23
|
+
[
|
|
24
|
+
require.resolve('babel-preset-ko-app'),
|
|
25
|
+
{
|
|
26
|
+
useAbsoluteRuntime: true,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
],
|
|
30
|
+
babelrc: false,
|
|
31
|
+
configFile: false,
|
|
32
|
+
cacheIdentifier: (0, getCacheIdentifier_1.default)(config_1.default.isProductionEnv ? 'production' : '', ['babel-preset-ko-app', 'react-dev-utils', 'ko']),
|
|
33
|
+
cacheDirectory: true,
|
|
34
|
+
cacheCompression: false,
|
|
35
|
+
compact: config_1.default.isProductionEnv,
|
|
52
36
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
exports.default = getScriptLoaders;
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
exports.default = scriptLoader;
|
|
@@ -10,7 +10,7 @@ const LESS_LOADER = require.resolve('less-loader');
|
|
|
10
10
|
const SASS_LOADER = require.resolve('sass-loader');
|
|
11
11
|
const POSTCSS_LOADER = require.resolve('postcss-loader');
|
|
12
12
|
const styleLoader = {
|
|
13
|
-
loader: mini_css_extract_plugin_1.loader
|
|
13
|
+
loader: mini_css_extract_plugin_1.loader,
|
|
14
14
|
};
|
|
15
15
|
const cssLoader = {
|
|
16
16
|
loader: CSS_LOADER,
|
|
@@ -31,11 +31,7 @@ const postcssLoader = {
|
|
|
31
31
|
const styleLoaders = [
|
|
32
32
|
{
|
|
33
33
|
test: /\.css$/,
|
|
34
|
-
use: [
|
|
35
|
-
styleLoader,
|
|
36
|
-
cssLoader,
|
|
37
|
-
postcssLoader,
|
|
38
|
-
],
|
|
34
|
+
use: [styleLoader, cssLoader, postcssLoader],
|
|
39
35
|
},
|
|
40
36
|
{
|
|
41
37
|
test: /\.s[ac]ss$/,
|
package/lib/webpack/plugins.js
CHANGED
|
@@ -8,10 +8,11 @@ const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sens
|
|
|
8
8
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
9
9
|
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
10
10
|
const config_1 = __importDefault(require("../utils/config"));
|
|
11
|
-
function getPlugins(
|
|
12
|
-
const { ts } = opts;
|
|
11
|
+
function getPlugins() {
|
|
13
12
|
const { userConf, defaultPaths } = config_1.default;
|
|
14
|
-
const publicPath =
|
|
13
|
+
const publicPath = userConf.output && userConf.output.publicPath
|
|
14
|
+
? userConf.output.publicPath
|
|
15
|
+
: '/';
|
|
15
16
|
let plugins = [
|
|
16
17
|
new webpack_1.IgnorePlugin({
|
|
17
18
|
resourceRegExp: /^\.\/locale$/,
|
|
@@ -28,23 +29,11 @@ function getPlugins(opts) {
|
|
|
28
29
|
template: defaultPaths.html,
|
|
29
30
|
title: 'Ko App',
|
|
30
31
|
templateParameters: {
|
|
31
|
-
configPath: `${publicPath}config/config.js
|
|
32
|
+
configPath: `${publicPath}config/config.js`,
|
|
32
33
|
},
|
|
33
|
-
inject: 'body'
|
|
34
|
+
inject: 'body',
|
|
34
35
|
}),
|
|
35
36
|
];
|
|
36
|
-
if (ts) {
|
|
37
|
-
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
38
|
-
const typescriptPlugins = [
|
|
39
|
-
new ForkTsCheckerWebpackPlugin({
|
|
40
|
-
async: false,
|
|
41
|
-
typescript: {
|
|
42
|
-
configFile: defaultPaths.tsconfig,
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
];
|
|
46
|
-
plugins = plugins.concat(typescriptPlugins);
|
|
47
|
-
}
|
|
48
37
|
plugins = plugins.concat(userConf.plugins || []);
|
|
49
38
|
if (config_1.default.isProductionEnv) {
|
|
50
39
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
@@ -52,7 +41,7 @@ function getPlugins(opts) {
|
|
|
52
41
|
new CleanWebpackPlugin({
|
|
53
42
|
verbose: false,
|
|
54
43
|
dry: false,
|
|
55
|
-
})
|
|
44
|
+
}),
|
|
56
45
|
];
|
|
57
46
|
plugins.concat(prodPlugins);
|
|
58
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ko",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "build & lint library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ko",
|
|
@@ -34,58 +34,57 @@
|
|
|
34
34
|
"scripts/*",
|
|
35
35
|
"lib/*"
|
|
36
36
|
],
|
|
37
|
-
"scripts": {
|
|
38
|
-
"prepublishOnly": "rm -rf lib && tsc",
|
|
39
|
-
"preinstall": "node scripts/preinstall.js",
|
|
40
|
-
"debug": "tsc -w --sourceMap",
|
|
41
|
-
"test": "jest",
|
|
42
|
-
"build": "tsc"
|
|
43
|
-
},
|
|
44
37
|
"dependencies": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
38
|
+
"@babel/core": "^7.17.5",
|
|
39
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",
|
|
40
|
+
"autoprefixer": "^10.4.2",
|
|
41
|
+
"babel-loader": "^8.2.3",
|
|
42
|
+
"babel-preset-ko-app": "^1.0.0",
|
|
48
43
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
49
44
|
"chalk": "^4.1.2",
|
|
50
|
-
"clean-webpack-plugin": "
|
|
51
|
-
"commander": "^
|
|
52
|
-
"css-loader": "^
|
|
53
|
-
"css-minimizer-webpack-plugin": "^3.
|
|
45
|
+
"clean-webpack-plugin": "4.0.0",
|
|
46
|
+
"commander": "^9.0.0",
|
|
47
|
+
"css-loader": "^6.6.0",
|
|
48
|
+
"css-minimizer-webpack-plugin": "^3.4.1",
|
|
54
49
|
"detect-port": "^1.3.0",
|
|
55
|
-
"esbuild-loader": "^2.
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"inquirer": "^8.1.2",
|
|
50
|
+
"esbuild-loader": "^2.18.0",
|
|
51
|
+
"html-webpack-plugin": "^5.5.0",
|
|
52
|
+
"inquirer": "^8.2.0",
|
|
59
53
|
"ko-lints": "^1.0.0",
|
|
60
54
|
"less": "^3.13.1",
|
|
61
|
-
"less-loader": "^9.
|
|
62
|
-
"mini-css-extract-plugin": "^
|
|
63
|
-
"postcss": "^8.
|
|
64
|
-
"postcss-loader": "^
|
|
65
|
-
"react-dev-utils": "^
|
|
66
|
-
"
|
|
67
|
-
"sass
|
|
55
|
+
"less-loader": "^9.1.0",
|
|
56
|
+
"mini-css-extract-plugin": "^2.5.3",
|
|
57
|
+
"postcss": "^8.4.7",
|
|
58
|
+
"postcss-loader": "^6.2.1",
|
|
59
|
+
"react-dev-utils": "^12.0.0",
|
|
60
|
+
"react-refresh": "^0.11.0",
|
|
61
|
+
"sass": "^1.49.9",
|
|
62
|
+
"sass-loader": "^12.6.0",
|
|
68
63
|
"thread-loader": "^3.0.4",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"webpack": "^5.
|
|
72
|
-
"webpack-
|
|
73
|
-
"webpack-dev-server": "^3.11.2",
|
|
64
|
+
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
65
|
+
"webpack": "^5.69.1",
|
|
66
|
+
"webpack-bundle-analyzer": "^4.5.0",
|
|
67
|
+
"webpack-dev-server": "^4.7.4",
|
|
74
68
|
"webpack-merge": "^5.8.0"
|
|
75
69
|
},
|
|
76
70
|
"devDependencies": {
|
|
77
71
|
"@types/case-sensitive-paths-webpack-plugin": "^2.1.6",
|
|
78
|
-
"@types/detect-port": "^1.3.
|
|
79
|
-
"@types/inquirer": "^
|
|
80
|
-
"@types/jest": "^27.
|
|
81
|
-
"@types/
|
|
82
|
-
"
|
|
83
|
-
"jest": "^27.
|
|
84
|
-
"
|
|
85
|
-
"typescript": "^4.4.4"
|
|
72
|
+
"@types/detect-port": "^1.3.2",
|
|
73
|
+
"@types/inquirer": "^8.2.0",
|
|
74
|
+
"@types/jest": "^27.4.1",
|
|
75
|
+
"@types/react-dev-utils": "^9.0.10",
|
|
76
|
+
"jest": "^27.5.1",
|
|
77
|
+
"ts-jest": "^27.1.3",
|
|
78
|
+
"typescript": "^4.6.2"
|
|
86
79
|
},
|
|
87
80
|
"engines": {
|
|
88
81
|
"node": ">=10.13.0"
|
|
89
82
|
},
|
|
90
|
-
"
|
|
91
|
-
|
|
83
|
+
"scripts": {
|
|
84
|
+
"preinstall": "node scripts/preinstall.js",
|
|
85
|
+
"debug": "tsc -w --sourceMap",
|
|
86
|
+
"test": "jest",
|
|
87
|
+
"build": "tsc"
|
|
88
|
+
},
|
|
89
|
+
"readme": "# ko\n\nbuild & lint library\n"
|
|
90
|
+
}
|
package/scripts/preinstall.js
CHANGED
|
@@ -16,7 +16,7 @@ if (LOCK_NODE_VERSION) {
|
|
|
16
16
|
* webpack minor support version
|
|
17
17
|
* @link https://webpack.js.org/migrate/5/#preparations
|
|
18
18
|
*/
|
|
19
|
-
const webpack5SupportLeastVersion = 10.13;
|
|
19
|
+
const webpack5SupportLeastVersion = 10.13;
|
|
20
20
|
|
|
21
21
|
if (majorAndMinorNodeVersion < webpack5SupportLeastVersion) {
|
|
22
22
|
console.error(
|
|
@@ -49,4 +49,4 @@ if (FORCE_YARN_INSTALL) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
err && process.exit(1);
|
|
52
|
+
err && process.exit(1);
|