ko 5.3.0 → 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.
@@ -21,13 +21,17 @@ class Dev extends creator_1.WebpackCreator {
21
21
  port,
22
22
  host,
23
23
  historyApiFallback: true,
24
- allowedHosts: "all",
24
+ allowedHosts: 'all',
25
25
  hot: true,
26
26
  static: {
27
27
  directory: config_1.default.defaultPaths.dist,
28
28
  publicPath: '/',
29
29
  watch: true,
30
30
  },
31
+ client: {
32
+ overlay: false,
33
+ },
34
+ setupExitSignals: true,
31
35
  open: true,
32
36
  };
33
37
  return { ...defaultDevServerConfig, ...userDefinedDevServerConfig };
@@ -35,10 +39,7 @@ class Dev extends creator_1.WebpackCreator {
35
39
  config() {
36
40
  const conf = {
37
41
  devtool: 'cheap-module-source-map',
38
- plugins: [
39
- new webpack_1.default.HotModuleReplacementPlugin(),
40
- this.opts.analyzer && new BundleAnalyzerPlugin(),
41
- ].filter(Boolean),
42
+ plugins: [this.opts.analyzer && new BundleAnalyzerPlugin()].filter(Boolean),
42
43
  };
43
44
  return this.mergeConfig([this.baseConfig, conf]);
44
45
  }
@@ -78,23 +79,8 @@ class Dev extends creator_1.WebpackCreator {
78
79
  return;
79
80
  const compiler = (0, webpack_1.default)(this.config());
80
81
  const devServer = new webpack_dev_server_1.default(this.devSerConf(), compiler);
81
- let isFirstCompile = true;
82
- compiler.hooks.done.tap('done', stats => {
83
- if (isFirstCompile) {
84
- isFirstCompile = false;
85
- this.successStdout('development server has been started');
86
- console.log(`server starts at: ${this.linkStdout(this.getUrlHost(host) + ':' + port)}`);
87
- }
88
- if (stats.hasErrors()) {
89
- console.log(stats.toString({
90
- colors: true,
91
- }));
92
- }
93
- });
94
- compiler.hooks.invalid.tap('invalid', () => {
95
- console.log('Compiling...');
96
- });
97
- devServer.start();
82
+ console.log(`dev server start at ${this.getUrlHost(host)}:${newPort}`);
83
+ await devServer.start();
98
84
  }
99
85
  }
100
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();
@@ -36,6 +35,4 @@ program
36
35
  const devInstance = new dev_1.default(opts);
37
36
  devInstance.action();
38
37
  });
39
- //attach lint features to program
40
- (0, ko_lints_1.default)(program);
41
38
  program.parse();
@@ -4,22 +4,23 @@ const path_1 = require("path");
4
4
  const fs_1 = require("fs");
5
5
  class Config {
6
6
  constructor() {
7
+ this.babelPlugins = [];
7
8
  this.cwd = process.cwd();
8
9
  }
9
10
  static getInstance() {
10
11
  if (!Config.instance) {
11
- Config.instance = new Config();
12
+ Config.instance = Object.freeze(new Config());
12
13
  }
13
14
  return Config.instance;
14
15
  }
15
16
  getFileRealPath(path) {
16
17
  return (0, path_1.isAbsolute)(path) ? path : (0, path_1.resolve)(this.cwd, path);
17
18
  }
18
- //TODO: define userConf
19
19
  get userConf() {
20
20
  const userConfPath = this.getFileRealPath('ko.config.js');
21
21
  if ((0, fs_1.existsSync)(userConfPath)) {
22
- return userConfPath ? require(userConfPath) : {};
22
+ const userConf = require(userConfPath);
23
+ return userConf;
23
24
  }
24
25
  else {
25
26
  throw new Error('user config file not exist, please check it!');
@@ -8,6 +8,13 @@ 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
10
  const scriptLoader = [
11
+ {
12
+ test: /\.worker.[jt]s$/,
13
+ loader: 'worker-loader',
14
+ options: {
15
+ inline: 'fallback',
16
+ },
17
+ },
11
18
  {
12
19
  test: /\.(t|j)sx?$/,
13
20
  exclude: {
@@ -24,9 +31,11 @@ const scriptLoader = [
24
31
  require.resolve('babel-preset-ko-app'),
25
32
  {
26
33
  useAbsoluteRuntime: true,
34
+ customizePlugins: config_1.default.babelPlugins,
27
35
  },
28
36
  ],
29
37
  ],
38
+ plugins: [require.resolve('react-refresh/babel')],
30
39
  babelrc: false,
31
40
  configFile: false,
32
41
  cacheIdentifier: (0, getCacheIdentifier_1.default)(config_1.default.isProductionEnv ? 'production' : '', ['babel-preset-ko-app', 'react-dev-utils', 'ko']),
@@ -7,6 +7,8 @@ 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
13
  function getPlugins() {
12
14
  const { userConf, defaultPaths } = config_1.default;
@@ -18,7 +20,6 @@ function getPlugins() {
18
20
  resourceRegExp: /^\.\/locale$/,
19
21
  contextRegExp: /moment$/,
20
22
  }),
21
- new webpack_1.ProgressPlugin(),
22
23
  //TODO: check if mini-css-extract-plugin should use base name if enable HMR
23
24
  new mini_css_extract_plugin_1.default({
24
25
  filename: 'css/[name].[contenthash].css',
@@ -33,6 +34,8 @@ function getPlugins() {
33
34
  },
34
35
  inject: 'body',
35
36
  }),
37
+ new react_refresh_webpack_plugin_1.default(),
38
+ new webpackbar_1.default(),
36
39
  ];
37
40
  plugins = plugins.concat(userConf.plugins || []);
38
41
  if (config_1.default.isProductionEnv) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ko",
3
- "version": "5.3.0",
3
+ "version": "5.3.1",
4
4
  "description": "build & lint library",
5
5
  "keywords": [
6
6
  "ko",
@@ -50,7 +50,6 @@
50
50
  "esbuild-loader": "^2.18.0",
51
51
  "html-webpack-plugin": "^5.5.0",
52
52
  "inquirer": "^8.2.0",
53
- "ko-lints": "^1.0.0",
54
53
  "less": "^3.13.1",
55
54
  "less-loader": "^9.1.0",
56
55
  "mini-css-extract-plugin": "^2.5.3",
@@ -65,7 +64,9 @@
65
64
  "webpack": "^5.69.1",
66
65
  "webpack-bundle-analyzer": "^4.5.0",
67
66
  "webpack-dev-server": "^4.7.4",
68
- "webpack-merge": "^5.8.0"
67
+ "webpack-merge": "^5.8.0",
68
+ "webpackbar": "^5.0.2",
69
+ "worker-loader": "^3.0.8"
69
70
  },
70
71
  "devDependencies": {
71
72
  "@types/case-sensitive-paths-webpack-plugin": "^2.1.6",