ko 5.2.2-alpha.3 → 5.3.1
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 +13 -6
- package/lib/actions/creator.js +4 -4
- package/lib/actions/dev.js +17 -41
- package/lib/cli.js +1 -3
- package/lib/utils/config.js +12 -5
- package/lib/utils/config.test.js +30 -0
- package/lib/webpack/index.js +9 -8
- package/lib/webpack/loaders/index.js +2 -4
- package/lib/webpack/loaders/script.js +39 -48
- package/lib/webpack/loaders/style.js +3 -7
- package/lib/webpack/plugins.js +11 -19
- package/package.json +43 -38
- package/scripts/preinstall.js +2 -2
package/lib/actions/build.js
CHANGED
|
@@ -4,6 +4,7 @@ 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");
|
|
7
8
|
const creator_1 = require("./creator");
|
|
8
9
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
9
10
|
class Build extends creator_1.WebpackCreator {
|
|
@@ -11,11 +12,17 @@ class Build extends creator_1.WebpackCreator {
|
|
|
11
12
|
super(opts);
|
|
12
13
|
}
|
|
13
14
|
config() {
|
|
15
|
+
const { esbuild } = this.opts;
|
|
14
16
|
const conf = {
|
|
15
17
|
optimization: {
|
|
16
18
|
minimizer: [
|
|
17
|
-
new CssMinimizerPlugin()
|
|
18
|
-
|
|
19
|
+
!esbuild && new CssMinimizerPlugin(),
|
|
20
|
+
esbuild &&
|
|
21
|
+
new esbuild_loader_1.ESBuildMinifyPlugin({
|
|
22
|
+
target: 'es2015',
|
|
23
|
+
css: true,
|
|
24
|
+
}),
|
|
25
|
+
].filter(Boolean),
|
|
19
26
|
},
|
|
20
27
|
plugins: [
|
|
21
28
|
new webpack_1.default.optimize.SplitChunksPlugin({
|
|
@@ -44,18 +51,18 @@ class Build extends creator_1.WebpackCreator {
|
|
|
44
51
|
reuseExistingChunk: true,
|
|
45
52
|
},
|
|
46
53
|
},
|
|
47
|
-
})
|
|
48
|
-
]
|
|
54
|
+
}),
|
|
55
|
+
],
|
|
49
56
|
};
|
|
50
57
|
return this.mergeConfig([this.baseConfig, conf]);
|
|
51
58
|
}
|
|
52
59
|
action() {
|
|
53
60
|
//TODO: redefine stats
|
|
54
|
-
webpack_1.default(this.config(), (error, stats) => {
|
|
61
|
+
(0, webpack_1.default)(this.config(), (error, stats) => {
|
|
55
62
|
if (stats && stats.hasErrors()) {
|
|
56
63
|
throw stats.toString({
|
|
57
64
|
logging: 'warn',
|
|
58
|
-
colors: true
|
|
65
|
+
colors: true,
|
|
59
66
|
});
|
|
60
67
|
}
|
|
61
68
|
if (error) {
|
package/lib/actions/creator.js
CHANGED
|
@@ -17,16 +17,16 @@ class WebpackCreator extends Creator {
|
|
|
17
17
|
this.baseConfig = this.initConfig(opts);
|
|
18
18
|
}
|
|
19
19
|
pluginsUnique(pluginNames) {
|
|
20
|
-
return webpack_merge_1.unique('plugins', pluginNames, (plugin) => plugin.constructor && plugin.constructor.name);
|
|
20
|
+
return (0, webpack_merge_1.unique)('plugins', pluginNames, (plugin) => plugin.constructor && plugin.constructor.name);
|
|
21
21
|
}
|
|
22
22
|
initConfig(opts) {
|
|
23
|
-
this.baseConfig = webpack_1.default(opts);
|
|
24
|
-
return webpack_merge_1.mergeWithCustomize({
|
|
23
|
+
this.baseConfig = (0, webpack_1.default)(opts);
|
|
24
|
+
return (0, webpack_merge_1.mergeWithCustomize)({
|
|
25
25
|
customizeArray: this.pluginsUnique(['HtmlWebpackPlugin']),
|
|
26
26
|
})(this.baseConfig, config_1.default.userConf);
|
|
27
27
|
}
|
|
28
28
|
mergeConfig(conf) {
|
|
29
|
-
return webpack_merge_1.merge(conf);
|
|
29
|
+
return (0, webpack_merge_1.merge)(conf);
|
|
30
30
|
}
|
|
31
31
|
successStdout(log) {
|
|
32
32
|
console.log(chalk_1.default.green(log));
|
package/lib/actions/dev.js
CHANGED
|
@@ -20,29 +20,26 @@ 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
|
-
|
|
31
|
+
client: {
|
|
32
|
+
overlay: false,
|
|
33
|
+
},
|
|
34
|
+
setupExitSignals: true,
|
|
35
|
+
open: true,
|
|
36
36
|
};
|
|
37
37
|
return { ...defaultDevServerConfig, ...userDefinedDevServerConfig };
|
|
38
38
|
}
|
|
39
39
|
config() {
|
|
40
40
|
const conf = {
|
|
41
41
|
devtool: 'cheap-module-source-map',
|
|
42
|
-
plugins: [
|
|
43
|
-
new webpack_1.default.HotModuleReplacementPlugin(),
|
|
44
|
-
this.opts.analyzer && new BundleAnalyzerPlugin()
|
|
45
|
-
].filter(Boolean),
|
|
42
|
+
plugins: [this.opts.analyzer && new BundleAnalyzerPlugin()].filter(Boolean),
|
|
46
43
|
};
|
|
47
44
|
return this.mergeConfig([this.baseConfig, conf]);
|
|
48
45
|
}
|
|
@@ -53,7 +50,7 @@ class Dev extends creator_1.WebpackCreator {
|
|
|
53
50
|
message: `port: ${port} has been used,use new port ${newPort} instead?`,
|
|
54
51
|
default: true,
|
|
55
52
|
};
|
|
56
|
-
const answer = await inquirer_1.prompt([question]);
|
|
53
|
+
const answer = await (0, inquirer_1.prompt)([question]);
|
|
57
54
|
if (answer.changePort) {
|
|
58
55
|
return newPort;
|
|
59
56
|
}
|
|
@@ -62,7 +59,7 @@ class Dev extends creator_1.WebpackCreator {
|
|
|
62
59
|
}
|
|
63
60
|
}
|
|
64
61
|
async checkPort(port) {
|
|
65
|
-
const newPort = await detect_port_1.default(port);
|
|
62
|
+
const newPort = await (0, detect_port_1.default)(port);
|
|
66
63
|
if (newPort === port) {
|
|
67
64
|
return newPort;
|
|
68
65
|
}
|
|
@@ -80,31 +77,10 @@ class Dev extends creator_1.WebpackCreator {
|
|
|
80
77
|
const newPort = await this.checkPort(parseInt(port));
|
|
81
78
|
if (!newPort)
|
|
82
79
|
return;
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
compiler.hooks.done.tap('done', (stats) => {
|
|
88
|
-
if (isFirstCompile) {
|
|
89
|
-
isFirstCompile = false;
|
|
90
|
-
this.successStdout('development server has been started');
|
|
91
|
-
console.log(`server starts at: ${this.linkStdout(this.getUrlHost(host) + ':' + port)}`);
|
|
92
|
-
}
|
|
93
|
-
if (stats.hasErrors()) {
|
|
94
|
-
console.log(stats.toString({
|
|
95
|
-
colors: true
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
compiler.hooks.invalid.tap('invalid', () => {
|
|
100
|
-
console.log('Compiling...');
|
|
101
|
-
});
|
|
102
|
-
devServer.listen(port, host, (err) => {
|
|
103
|
-
if (err) {
|
|
104
|
-
console.error(err);
|
|
105
|
-
process.exit(500);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
80
|
+
const compiler = (0, webpack_1.default)(this.config());
|
|
81
|
+
const devServer = new webpack_dev_server_1.default(this.devSerConf(), compiler);
|
|
82
|
+
console.log(`dev server start at ${this.getUrlHost(host)}:${newPort}`);
|
|
83
|
+
await devServer.start();
|
|
108
84
|
}
|
|
109
85
|
}
|
|
110
86
|
exports.default = Dev;
|
package/lib/cli.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
|
-
const ko_lints_1 = __importDefault(require("ko-lints"));
|
|
9
8
|
const build_1 = __importDefault(require("./actions/build"));
|
|
10
9
|
const dev_1 = __importDefault(require("./actions/dev"));
|
|
11
10
|
const program = new commander_1.Command();
|
|
@@ -19,6 +18,7 @@ program
|
|
|
19
18
|
.description('build project')
|
|
20
19
|
.option('--hash', 'output file name with hash')
|
|
21
20
|
.option('-t,--ts,--typescript', 'support typescript')
|
|
21
|
+
.option('-e,--esbuild', 'enable esbuild')
|
|
22
22
|
.action((opts) => {
|
|
23
23
|
const buildInstance = new build_1.default(opts);
|
|
24
24
|
buildInstance.action();
|
|
@@ -35,6 +35,4 @@ program
|
|
|
35
35
|
const devInstance = new dev_1.default(opts);
|
|
36
36
|
devInstance.action();
|
|
37
37
|
});
|
|
38
|
-
//attach lint features to program
|
|
39
|
-
ko_lints_1.default(program);
|
|
40
38
|
program.parse();
|
package/lib/utils/config.js
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const path_1 = require("path");
|
|
4
|
+
const fs_1 = require("fs");
|
|
4
5
|
class Config {
|
|
5
6
|
constructor() {
|
|
7
|
+
this.babelPlugins = [];
|
|
6
8
|
this.cwd = process.cwd();
|
|
7
9
|
}
|
|
8
10
|
static getInstance() {
|
|
9
11
|
if (!Config.instance) {
|
|
10
|
-
Config.instance = new Config();
|
|
12
|
+
Config.instance = Object.freeze(new Config());
|
|
11
13
|
}
|
|
12
14
|
return Config.instance;
|
|
13
15
|
}
|
|
14
16
|
getFileRealPath(path) {
|
|
15
|
-
return path_1.isAbsolute(path) ? path : path_1.resolve(this.cwd, path);
|
|
17
|
+
return (0, path_1.isAbsolute)(path) ? path : (0, path_1.resolve)(this.cwd, path);
|
|
16
18
|
}
|
|
17
|
-
//TODO: define userConf
|
|
18
19
|
get userConf() {
|
|
19
20
|
const userConfPath = this.getFileRealPath('ko.config.js');
|
|
20
|
-
|
|
21
|
+
if ((0, fs_1.existsSync)(userConfPath)) {
|
|
22
|
+
const userConf = require(userConfPath);
|
|
23
|
+
return userConf;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw new Error('user config file not exist, please check it!');
|
|
27
|
+
}
|
|
21
28
|
}
|
|
22
29
|
get defaultPaths() {
|
|
23
30
|
return {
|
|
@@ -25,7 +32,7 @@ class Config {
|
|
|
25
32
|
dist: this.getFileRealPath('dist'),
|
|
26
33
|
public: this.getFileRealPath('public'),
|
|
27
34
|
html: this.getFileRealPath('public/index.html'),
|
|
28
|
-
tsconfig: this.getFileRealPath('tsconfig.json')
|
|
35
|
+
tsconfig: this.getFileRealPath('tsconfig.json'),
|
|
29
36
|
};
|
|
30
37
|
}
|
|
31
38
|
get isProductionEnv() {
|
|
@@ -0,0 +1,30 @@
|
|
|
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/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: loaders_1.default
|
|
35
|
+
rules: loaders_1.default,
|
|
36
36
|
},
|
|
37
|
-
plugins: 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,44 @@ 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: 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: /\.worker.[jt]s$/,
|
|
13
|
+
loader: 'worker-loader',
|
|
14
|
+
options: {
|
|
15
|
+
inline: 'fallback',
|
|
37
16
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
test: /\.(t|j)sx?$/,
|
|
20
|
+
exclude: {
|
|
21
|
+
and: [/node_modules/],
|
|
22
|
+
not: [/dt-common/],
|
|
23
|
+
},
|
|
24
|
+
use: [
|
|
25
|
+
THREAD_LOADER,
|
|
26
|
+
{
|
|
27
|
+
loader: BABEL_LOADER,
|
|
28
|
+
options: {
|
|
29
|
+
presets: [
|
|
30
|
+
[
|
|
31
|
+
require.resolve('babel-preset-ko-app'),
|
|
32
|
+
{
|
|
33
|
+
useAbsoluteRuntime: true,
|
|
34
|
+
customizePlugins: config_1.default.babelPlugins,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
],
|
|
38
|
+
plugins: [require.resolve('react-refresh/babel')],
|
|
39
|
+
babelrc: false,
|
|
40
|
+
configFile: false,
|
|
41
|
+
cacheIdentifier: (0, getCacheIdentifier_1.default)(config_1.default.isProductionEnv ? 'production' : '', ['babel-preset-ko-app', 'react-dev-utils', 'ko']),
|
|
42
|
+
cacheDirectory: true,
|
|
43
|
+
cacheCompression: false,
|
|
44
|
+
compact: config_1.default.isProductionEnv,
|
|
52
45
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
exports.default = getScriptLoaders;
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
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,
|
|
@@ -24,18 +24,14 @@ const postcssLoader = {
|
|
|
24
24
|
options: {
|
|
25
25
|
sourceMap: true,
|
|
26
26
|
postcssOptions: {
|
|
27
|
-
plugins: [autoprefixer_1.default()],
|
|
27
|
+
plugins: [(0, autoprefixer_1.default)()],
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
};
|
|
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
|
@@ -7,17 +7,19 @@ 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
9
|
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
10
|
+
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
11
|
+
const webpackbar_1 = __importDefault(require("webpackbar"));
|
|
10
12
|
const config_1 = __importDefault(require("../utils/config"));
|
|
11
|
-
function getPlugins(
|
|
12
|
-
const { ts } = opts;
|
|
13
|
+
function getPlugins() {
|
|
13
14
|
const { userConf, defaultPaths } = config_1.default;
|
|
14
|
-
const publicPath =
|
|
15
|
+
const publicPath = userConf.output && userConf.output.publicPath
|
|
16
|
+
? userConf.output.publicPath
|
|
17
|
+
: '/';
|
|
15
18
|
let plugins = [
|
|
16
19
|
new webpack_1.IgnorePlugin({
|
|
17
20
|
resourceRegExp: /^\.\/locale$/,
|
|
18
21
|
contextRegExp: /moment$/,
|
|
19
22
|
}),
|
|
20
|
-
new webpack_1.ProgressPlugin(),
|
|
21
23
|
//TODO: check if mini-css-extract-plugin should use base name if enable HMR
|
|
22
24
|
new mini_css_extract_plugin_1.default({
|
|
23
25
|
filename: 'css/[name].[contenthash].css',
|
|
@@ -28,23 +30,13 @@ function getPlugins(opts) {
|
|
|
28
30
|
template: defaultPaths.html,
|
|
29
31
|
title: 'Ko App',
|
|
30
32
|
templateParameters: {
|
|
31
|
-
configPath: `${publicPath}config/config.js
|
|
33
|
+
configPath: `${publicPath}config/config.js`,
|
|
32
34
|
},
|
|
33
|
-
inject: 'body'
|
|
35
|
+
inject: 'body',
|
|
34
36
|
}),
|
|
37
|
+
new react_refresh_webpack_plugin_1.default(),
|
|
38
|
+
new webpackbar_1.default(),
|
|
35
39
|
];
|
|
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
40
|
plugins = plugins.concat(userConf.plugins || []);
|
|
49
41
|
if (config_1.default.isProductionEnv) {
|
|
50
42
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
@@ -52,7 +44,7 @@ function getPlugins(opts) {
|
|
|
52
44
|
new CleanWebpackPlugin({
|
|
53
45
|
verbose: false,
|
|
54
46
|
dry: false,
|
|
55
|
-
})
|
|
47
|
+
}),
|
|
56
48
|
];
|
|
57
49
|
plugins.concat(prodPlugins);
|
|
58
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ko",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"description": "build & lint library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ko",
|
|
@@ -34,53 +34,58 @@
|
|
|
34
34
|
"scripts/*",
|
|
35
35
|
"lib/*"
|
|
36
36
|
],
|
|
37
|
-
"scripts": {
|
|
38
|
-
"prepublishOnly": "rm -rf lib && tsc",
|
|
39
|
-
"preinstall": "node scripts/preinstall.js",
|
|
40
|
-
"build": "tsc",
|
|
41
|
-
"debug": "tsc -w --sourceMap"
|
|
42
|
-
},
|
|
43
37
|
"dependencies": {
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
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",
|
|
47
43
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
48
44
|
"chalk": "^4.1.2",
|
|
49
|
-
"clean-webpack-plugin": "
|
|
50
|
-
"commander": "^
|
|
51
|
-
"css-loader": "^
|
|
52
|
-
"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",
|
|
53
49
|
"detect-port": "^1.3.0",
|
|
54
|
-
"
|
|
55
|
-
"html-webpack-plugin": "^5.
|
|
56
|
-
"inquirer": "^8.
|
|
57
|
-
"ko-lints": "^1.0.0-alpha.2",
|
|
50
|
+
"esbuild-loader": "^2.18.0",
|
|
51
|
+
"html-webpack-plugin": "^5.5.0",
|
|
52
|
+
"inquirer": "^8.2.0",
|
|
58
53
|
"less": "^3.13.1",
|
|
59
|
-
"less-loader": "^9.
|
|
60
|
-
"mini-css-extract-plugin": "^
|
|
61
|
-
"postcss": "^8.
|
|
62
|
-
"postcss-loader": "^
|
|
63
|
-
"react-dev-utils": "^
|
|
64
|
-
"
|
|
65
|
-
"sass
|
|
54
|
+
"less-loader": "^9.1.0",
|
|
55
|
+
"mini-css-extract-plugin": "^2.5.3",
|
|
56
|
+
"postcss": "^8.4.7",
|
|
57
|
+
"postcss-loader": "^6.2.1",
|
|
58
|
+
"react-dev-utils": "^12.0.0",
|
|
59
|
+
"react-refresh": "^0.11.0",
|
|
60
|
+
"sass": "^1.49.9",
|
|
61
|
+
"sass-loader": "^12.6.0",
|
|
66
62
|
"thread-loader": "^3.0.4",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"webpack": "^5.
|
|
70
|
-
"webpack-
|
|
71
|
-
"webpack-
|
|
72
|
-
"
|
|
63
|
+
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
64
|
+
"webpack": "^5.69.1",
|
|
65
|
+
"webpack-bundle-analyzer": "^4.5.0",
|
|
66
|
+
"webpack-dev-server": "^4.7.4",
|
|
67
|
+
"webpack-merge": "^5.8.0",
|
|
68
|
+
"webpackbar": "^5.0.2",
|
|
69
|
+
"worker-loader": "^3.0.8"
|
|
73
70
|
},
|
|
74
71
|
"devDependencies": {
|
|
75
72
|
"@types/case-sensitive-paths-webpack-plugin": "^2.1.6",
|
|
76
|
-
"@types/detect-port": "^1.3.
|
|
77
|
-
"@types/inquirer": "^
|
|
78
|
-
"@types/
|
|
79
|
-
"@types/react-dev-utils": "^9.0.
|
|
80
|
-
"
|
|
73
|
+
"@types/detect-port": "^1.3.2",
|
|
74
|
+
"@types/inquirer": "^8.2.0",
|
|
75
|
+
"@types/jest": "^27.4.1",
|
|
76
|
+
"@types/react-dev-utils": "^9.0.10",
|
|
77
|
+
"jest": "^27.5.1",
|
|
78
|
+
"ts-jest": "^27.1.3",
|
|
79
|
+
"typescript": "^4.6.2"
|
|
81
80
|
},
|
|
82
81
|
"engines": {
|
|
83
82
|
"node": ">=10.13.0"
|
|
84
83
|
},
|
|
85
|
-
"
|
|
86
|
-
|
|
84
|
+
"scripts": {
|
|
85
|
+
"preinstall": "node scripts/preinstall.js",
|
|
86
|
+
"debug": "tsc -w --sourceMap",
|
|
87
|
+
"test": "jest",
|
|
88
|
+
"build": "tsc"
|
|
89
|
+
},
|
|
90
|
+
"readme": "# ko\n\nbuild & lint library\n"
|
|
91
|
+
}
|
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);
|