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.
@@ -17,11 +17,12 @@ class Build extends creator_1.WebpackCreator {
17
17
  optimization: {
18
18
  minimizer: [
19
19
  !esbuild && new CssMinimizerPlugin(),
20
- esbuild && new esbuild_loader_1.ESBuildMinifyPlugin({
21
- target: 'es2015',
22
- css: true
23
- })
24
- ].filter(Boolean)
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) {
@@ -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
- disableHostCheck: true,
26
- compress: true,
27
- clientLogLevel: 'none',
24
+ allowedHosts: "all",
28
25
  hot: true,
29
- inline: true,
30
- publicPath: '/',
31
- watchOptions: {
32
- ignored: /node_modules/,
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(compiler, this.devSerConf());
80
+ const devServer = new webpack_dev_server_1.default(this.devSerConf(), compiler);
86
81
  let isFirstCompile = true;
87
- compiler.hooks.done.tap('done', (stats) => {
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.listen(port, host, (err) => {
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
@@ -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() {
@@ -24,7 +24,7 @@ describe('config instance', () => {
24
24
  dist: cwd + '/dist',
25
25
  public: cwd + '/public',
26
26
  html: cwd + '/public/index.html',
27
- tsconfig: cwd + '/tsconfig.json'
27
+ tsconfig: cwd + '/tsconfig.json',
28
28
  });
29
29
  });
30
30
  });
@@ -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: (0, loaders_1.default)(opts),
35
+ rules: loaders_1.default,
36
36
  },
37
- plugins: (0, plugins_1.default)(opts),
37
+ plugins: (0, plugins_1.default)(),
38
38
  resolve: {
39
39
  extensions,
40
40
  plugins: [
41
- ts && new tsconfig_paths_webpack_plugin_1.default({
42
- configFile: config_1.default.defaultPaths.tsconfig
43
- })
44
- ].filter(Boolean)
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
- function getLoaders(opts) {
10
- return [...style_1.default, ...asset_1.default, ...(0, script_1.default)(opts.ts)];
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
- function getScriptLoaders(supportTypescript) {
11
- let scriptLoader = [
12
- {
13
- test: /\.jsx?$/,
14
- include: config_1.default.defaultPaths.src,
15
- use: [
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
- if (supportTypescript) {
40
- const TS_LOADER = require.resolve('ts-loader');
41
- const typescriptLoader = {
42
- test: /\.tsx?$/,
43
- use: [
44
- THREAD_LOADER,
45
- {
46
- loader: TS_LOADER,
47
- options: {
48
- transpileOnly: true,
49
- happyPackMode: true,
50
- allowTsInNodeModules: true
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
- scriptLoader.push(typescriptLoader);
56
- }
57
- return scriptLoader;
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$/,
@@ -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(opts) {
12
- const { ts } = opts;
11
+ function getPlugins() {
13
12
  const { userConf, defaultPaths } = config_1.default;
14
- const publicPath = (userConf.output && userConf.output.publicPath) ? userConf.output.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.2.2",
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
- "autoprefixer": "^10.2.6",
46
- "babel-loader": "^8.2.2",
47
- "babel-preset-ko-app": "^1.0.0-alpha.1",
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": "3.0.0",
51
- "commander": "^8.1.0",
52
- "css-loader": "^5.2.6",
53
- "css-minimizer-webpack-plugin": "^3.0.1",
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.16.0",
56
- "fork-ts-checker-webpack-plugin": "^6.2.10",
57
- "html-webpack-plugin": "^5.3.1",
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.0.0",
62
- "mini-css-extract-plugin": "^1.6.0",
63
- "postcss": "^8.3.0",
64
- "postcss-loader": "^5.3.0",
65
- "react-dev-utils": "^11.0.4",
66
- "sass": "^1.34.0",
67
- "sass-loader": "^11.1.1",
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
- "ts-loader": "^9.2.2",
70
- "tsconfig-paths-webpack-plugin": "^3.5.1",
71
- "webpack": "^5.50.0",
72
- "webpack-bundle-analyzer": "^4.4.2",
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.1",
79
- "@types/inquirer": "^7.3.3",
80
- "@types/jest": "^27.0.2",
81
- "@types/mini-css-extract-plugin": "^2.2.0",
82
- "@types/react-dev-utils": "^9.0.7",
83
- "jest": "^27.2.5",
84
- "ts-jest": "^27.0.5",
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
- "gitHead": "3ce5dfb8cb7b50b758ebe6fa0ebfba7a89667a07"
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
+ }
@@ -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);