ko 6.3.2 → 6.4.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 +4 -0
- package/lib/actions/dev.js +6 -2
- package/lib/core/config.js +1 -0
- package/lib/core/hooks.js +3 -5
- package/lib/core/service.js +9 -1
- package/lib/types.js +6 -1
- package/lib/webpack/index.js +13 -2
- package/lib/webpack/loaders/style.js +2 -1
- package/lib/webpack/plugins.js +5 -4
- package/package.json +2 -2
package/lib/actions/build.js
CHANGED
package/lib/actions/dev.js
CHANGED
|
@@ -12,7 +12,7 @@ class Dev extends factory_1.default {
|
|
|
12
12
|
super(service);
|
|
13
13
|
}
|
|
14
14
|
get devServerConfig() {
|
|
15
|
-
const { serve, publicPath } = this.service.config;
|
|
15
|
+
const { serve, publicPath, logLevel } = this.service.config;
|
|
16
16
|
const { host, port, proxy, staticPath } = serve;
|
|
17
17
|
return {
|
|
18
18
|
port,
|
|
@@ -28,7 +28,7 @@ class Dev extends factory_1.default {
|
|
|
28
28
|
allowedHosts: 'all',
|
|
29
29
|
client: {
|
|
30
30
|
overlay: false,
|
|
31
|
-
logging:
|
|
31
|
+
logging: logLevel,
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
34
|
}
|
|
@@ -56,6 +56,10 @@ class Dev extends factory_1.default {
|
|
|
56
56
|
}
|
|
57
57
|
: speedUp,
|
|
58
58
|
};
|
|
59
|
+
await this.service.apply({
|
|
60
|
+
key: this.service.hookKeySet.MODIFY_WEBPACK,
|
|
61
|
+
context: ret,
|
|
62
|
+
});
|
|
59
63
|
return ret;
|
|
60
64
|
}
|
|
61
65
|
registerCommand() {
|
package/lib/core/config.js
CHANGED
package/lib/core/hooks.js
CHANGED
|
@@ -2,13 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tapable_1 = require("tapable");
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
-
var HOOK_KEY_SET;
|
|
6
|
-
(function (HOOK_KEY_SET) {
|
|
7
|
-
HOOK_KEY_SET["WEBPACK_PLUGIN"] = "WebpackPlugin";
|
|
8
|
-
})(HOOK_KEY_SET || (HOOK_KEY_SET = {}));
|
|
9
5
|
class Hooks {
|
|
10
6
|
constructor() {
|
|
11
|
-
this.hookKeySet = HOOK_KEY_SET;
|
|
7
|
+
this.hookKeySet = types_1.HOOK_KEY_SET;
|
|
12
8
|
this.hooks = {};
|
|
13
9
|
}
|
|
14
10
|
register({ key, action, opts }) {
|
|
@@ -21,6 +17,8 @@ class Hooks {
|
|
|
21
17
|
}
|
|
22
18
|
apply(opts) {
|
|
23
19
|
const hooks = this.hooks[opts.key];
|
|
20
|
+
if (!hooks)
|
|
21
|
+
return Promise.resolve(opts.context);
|
|
24
22
|
const tapInstance = new tapable_1.AsyncSeriesWaterfallHook(['ctx']);
|
|
25
23
|
hooks[types_1.ACTION.ADD].forEach(hook => {
|
|
26
24
|
tapInstance.tapPromise({ name: hook.name, stage: hook.stage, before: hook.before }, async (ctx) => {
|
package/lib/core/service.js
CHANGED
|
@@ -6,12 +6,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const commander_1 = __importDefault(require("./commander"));
|
|
7
7
|
const hooks_1 = __importDefault(require("./hooks"));
|
|
8
8
|
const config_1 = __importDefault(require("./config"));
|
|
9
|
+
const types_1 = require("../types");
|
|
9
10
|
class Service extends hooks_1.default {
|
|
10
11
|
constructor() {
|
|
11
12
|
super();
|
|
12
13
|
this.commander = new commander_1.default();
|
|
13
14
|
this.config = new config_1.default().generate();
|
|
14
|
-
this.config.plugins &&
|
|
15
|
+
this.config.plugins &&
|
|
16
|
+
this.config.plugins.forEach(p => {
|
|
17
|
+
// MODIFY_WEBPACK only support UPDATE
|
|
18
|
+
if (p.key === types_1.HOOK_KEY_SET.MODIFY_WEBPACK) {
|
|
19
|
+
p.action = types_1.ACTION.UPDATE;
|
|
20
|
+
}
|
|
21
|
+
this.register(p);
|
|
22
|
+
});
|
|
15
23
|
}
|
|
16
24
|
freezeCliOptsWith(cliOpts) {
|
|
17
25
|
this.cliOpts = Object.freeze(cliOpts);
|
package/lib/types.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ACTION = void 0;
|
|
3
|
+
exports.HOOK_KEY_SET = exports.ACTION = void 0;
|
|
4
4
|
var ACTION;
|
|
5
5
|
(function (ACTION) {
|
|
6
6
|
ACTION["ADD"] = "add";
|
|
7
7
|
ACTION["UPDATE"] = "update";
|
|
8
8
|
})(ACTION = exports.ACTION || (exports.ACTION = {}));
|
|
9
|
+
var HOOK_KEY_SET;
|
|
10
|
+
(function (HOOK_KEY_SET) {
|
|
11
|
+
HOOK_KEY_SET["WEBPACK_PLUGIN"] = "WebpackPlugin";
|
|
12
|
+
HOOK_KEY_SET["MODIFY_WEBPACK"] = "ModifyWebpack";
|
|
13
|
+
})(HOOK_KEY_SET = exports.HOOK_KEY_SET || (exports.HOOK_KEY_SET = {}));
|
package/lib/webpack/index.js
CHANGED
|
@@ -54,6 +54,16 @@ class WebpackConfig {
|
|
|
54
54
|
(0, utils_1.assert)((0, fs_1.existsSync)(pkgPath), 'project package.json file not found');
|
|
55
55
|
return require(pkgPath).version;
|
|
56
56
|
}
|
|
57
|
+
get stats() {
|
|
58
|
+
const mapping = {
|
|
59
|
+
info: 'normal',
|
|
60
|
+
error: 'errors-only',
|
|
61
|
+
warn: 'errors-warnings',
|
|
62
|
+
none: 'none',
|
|
63
|
+
};
|
|
64
|
+
const { logLevel } = this.opts;
|
|
65
|
+
return mapping[logLevel];
|
|
66
|
+
}
|
|
57
67
|
get base() {
|
|
58
68
|
const { cwd, publicPath, entry, outputPath, alias, hash, analyzer } = this.opts;
|
|
59
69
|
const webpackBaseConf = {
|
|
@@ -101,8 +111,9 @@ class WebpackConfig {
|
|
|
101
111
|
hints: false,
|
|
102
112
|
},
|
|
103
113
|
cache: this.cache,
|
|
104
|
-
stats:
|
|
105
|
-
|
|
114
|
+
stats: this.stats,
|
|
115
|
+
infrastructureLogging: {
|
|
116
|
+
level: 'error',
|
|
106
117
|
},
|
|
107
118
|
};
|
|
108
119
|
return webpackBaseConf;
|
|
@@ -11,6 +11,7 @@ const postCssUrl = require('postcss-url');
|
|
|
11
11
|
const utils_1 = require("../../utils");
|
|
12
12
|
class Style {
|
|
13
13
|
constructor(opts) {
|
|
14
|
+
this.STYLE_LOADER = (0, utils_1.getResolvePath)('style-loader');
|
|
14
15
|
this.CSS_LOADER = (0, utils_1.getResolvePath)('css-loader');
|
|
15
16
|
this.SASS_LOADER = (0, utils_1.getResolvePath)('sass-loader');
|
|
16
17
|
this.LESS_LOADER = (0, utils_1.getResolvePath)('less-loader');
|
|
@@ -95,7 +96,7 @@ class Style {
|
|
|
95
96
|
}
|
|
96
97
|
get styleLoader() {
|
|
97
98
|
return {
|
|
98
|
-
loader: mini_css_extract_plugin_1.loader,
|
|
99
|
+
loader: this.opts.isProd ? mini_css_extract_plugin_1.loader : this.STYLE_LOADER,
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
102
|
get cssLoader() {
|
package/lib/webpack/plugins.js
CHANGED
|
@@ -57,10 +57,11 @@ function getPlugins(opts) {
|
|
|
57
57
|
},
|
|
58
58
|
},
|
|
59
59
|
}),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
isProd &&
|
|
61
|
+
new mini_css_extract_plugin_1.default({
|
|
62
|
+
filename: 'css/[name].[contenthash].css',
|
|
63
|
+
chunkFilename: 'css/[id].[contenthash].css',
|
|
64
|
+
}),
|
|
64
65
|
new case_sensitive_paths_webpack_plugin_1.default(),
|
|
65
66
|
new html_webpack_plugin_1.default({
|
|
66
67
|
template: htmlTemplate,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ko",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0",
|
|
4
4
|
"description": "build & lint library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ko",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@babel/core": "^7.18.0",
|
|
38
38
|
"@parcel/css": "^1.12.2",
|
|
39
39
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
|
|
40
|
-
"auto-polyfills-webpack-plugin": "^1.0
|
|
40
|
+
"auto-polyfills-webpack-plugin": "^1.1.0",
|
|
41
41
|
"autoprefixer": "^10.4.7",
|
|
42
42
|
"babel-loader": "^8.2.5",
|
|
43
43
|
"babel-plugin-treasure": "^0.9.0",
|