@unpackjs/core 1.6.3 → 1.7.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.
Files changed (60) hide show
  1. package/compiled/css-loader/index.js +46 -46
  2. package/compiled/less-loader/index.js +8 -8
  3. package/compiled/postcss-loader/index.js +37 -37
  4. package/compiled/sass-loader/index.js +10 -8
  5. package/compiled/sass-loader/package.json +1 -1
  6. package/compiled/style-loader/index.js +10 -10
  7. package/dist/bundler-config/chunkSplit.cjs +39 -3
  8. package/dist/bundler-config/chunkSplit.d.ts.map +1 -1
  9. package/dist/bundler-config/chunkSplit.js +39 -3
  10. package/dist/bundler-config/helper.cjs +2 -2
  11. package/dist/bundler-config/helper.js +1 -1
  12. package/dist/bundler-config/index.cjs +13 -7
  13. package/dist/bundler-config/index.d.ts.map +1 -1
  14. package/dist/bundler-config/index.js +16 -10
  15. package/dist/constants.cjs +4 -1
  16. package/dist/constants.d.ts +1 -0
  17. package/dist/constants.d.ts.map +1 -1
  18. package/dist/constants.js +3 -1
  19. package/dist/createUnpack.cjs +6 -3
  20. package/dist/createUnpack.d.ts.map +1 -1
  21. package/dist/createUnpack.js +7 -4
  22. package/dist/index.cjs +3 -0
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +2 -0
  26. package/dist/plugin-progress/rspack.cjs +3 -1
  27. package/dist/plugin-progress/rspack.d.ts.map +1 -1
  28. package/dist/plugin-progress/rspack.js +3 -1
  29. package/dist/plugin-progress/webpack.cjs +3 -1
  30. package/dist/plugin-progress/webpack.d.ts.map +1 -1
  31. package/dist/plugin-progress/webpack.js +3 -1
  32. package/dist/prebundleDeps.cjs +340 -0
  33. package/dist/prebundleDeps.d.ts +5 -0
  34. package/dist/prebundleDeps.d.ts.map +1 -0
  35. package/dist/prebundleDeps.js +324 -0
  36. package/dist/run/dev.cjs +22 -39
  37. package/dist/run/dev.d.ts +1 -1
  38. package/dist/run/dev.d.ts.map +1 -1
  39. package/dist/run/dev.js +23 -40
  40. package/dist/thread-loader/worker.js +1 -1
  41. package/dist/typed-css-modules/plugin.cjs +2 -2
  42. package/dist/typed-css-modules/plugin.d.ts.map +1 -1
  43. package/dist/typed-css-modules/plugin.js +1 -1
  44. package/dist/types/chunkSplit.d.ts +1 -1
  45. package/dist/types/chunkSplit.d.ts.map +1 -1
  46. package/dist/types/config.d.ts +29 -6
  47. package/dist/types/config.d.ts.map +1 -1
  48. package/dist/utils.cjs +5 -10
  49. package/dist/utils.d.ts +2 -1
  50. package/dist/utils.d.ts.map +1 -1
  51. package/dist/utils.js +3 -8
  52. package/package.json +11 -18
  53. package/compiled/chokidar/index.d.ts +0 -327
  54. package/compiled/chokidar/index.js +0 -1773
  55. package/compiled/chokidar/license +0 -21
  56. package/compiled/chokidar/package.json +0 -1
  57. package/compiled/fast-glob/index.d.ts +0 -237
  58. package/compiled/fast-glob/index.js +0 -5726
  59. package/compiled/fast-glob/license +0 -21
  60. package/compiled/fast-glob/package.json +0 -1
@@ -4795,19 +4795,19 @@
4795
4795
  }
4796
4796
  });
4797
4797
  },
4798
- 522: (module, __unused_webpack_exports, __nccwpck_require__) => {
4798
+ 867: (module, __unused_webpack_exports, __nccwpck_require__) => {
4799
4799
  "use strict";
4800
- const loader = __nccwpck_require__(326);
4800
+ const loader = __nccwpck_require__(814);
4801
4801
  module.exports = loader.default;
4802
4802
  },
4803
- 326: (__unused_webpack_module, exports, __nccwpck_require__) => {
4803
+ 814: (__unused_webpack_module, exports, __nccwpck_require__) => {
4804
4804
  "use strict";
4805
4805
  Object.defineProperty(exports, "__esModule", { value: true });
4806
4806
  exports["default"] = void 0;
4807
4807
  var _url = _interopRequireDefault(__nccwpck_require__(310));
4808
4808
  var _path = _interopRequireDefault(__nccwpck_require__(17));
4809
- var _options = _interopRequireDefault(__nccwpck_require__(364));
4810
- var _utils = __nccwpck_require__(646);
4809
+ var _options = _interopRequireDefault(__nccwpck_require__(88));
4810
+ var _utils = __nccwpck_require__(52);
4811
4811
  function _interopRequireDefault(e) {
4812
4812
  return e && e.__esModule ? e : { default: e };
4813
4813
  }
@@ -4917,7 +4917,7 @@
4917
4917
  }
4918
4918
  var _default = (exports["default"] = loader);
4919
4919
  },
4920
- 646: (__unused_webpack_module, exports, __nccwpck_require__) => {
4920
+ 52: (__unused_webpack_module, exports, __nccwpck_require__) => {
4921
4921
  "use strict";
4922
4922
  Object.defineProperty(exports, "__esModule", { value: true });
4923
4923
  exports.errorFactory = errorFactory;
@@ -5469,6 +5469,8 @@
5469
5469
  webpackCompiler.hooks.shutdown.tap("sass-loader", () => {
5470
5470
  compiler.dispose();
5471
5471
  });
5472
+ } else {
5473
+ compiler.dispose();
5472
5474
  }
5473
5475
  }
5474
5476
  return sassModernCompilers
@@ -5575,7 +5577,7 @@
5575
5577
  "use strict";
5576
5578
  module.exports = require("url");
5577
5579
  },
5578
- 364: (module) => {
5580
+ 88: (module) => {
5579
5581
  "use strict";
5580
5582
  module.exports = JSON.parse(
5581
5583
  '{"title":"Sass Loader options","type":"object","properties":{"implementation":{"description":"The implementation of the sass to be used.","link":"https://github.com/webpack-contrib/sass-loader#implementation","anyOf":[{"type":"string"},{"type":"object"}]},"api":{"description":"Switch between old and modern API for `sass` (`Dart Sass`) and `Sass Embedded` implementations.","link":"https://github.com/webpack-contrib/sass-loader#sassoptions","enum":["legacy","modern","modern-compiler"]},"sassOptions":{"description":"Options for `node-sass` or `sass` (`Dart Sass`) implementation.","link":"https://github.com/webpack-contrib/sass-loader#sassoptions","anyOf":[{"type":"object","additionalProperties":true},{"instanceof":"Function"}]},"additionalData":{"description":"Prepends/Appends `Sass`/`SCSS` code before the actual entry file.","link":"https://github.com/webpack-contrib/sass-loader#additionaldata","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"sourceMap":{"description":"Enables/Disables generation of source maps.","link":"https://github.com/webpack-contrib/sass-loader#sourcemap","type":"boolean"},"webpackImporter":{"description":"Enables/Disables default `webpack` importer.","link":"https://github.com/webpack-contrib/sass-loader#webpackimporter","type":"boolean"},"warnRuleAsWarning":{"description":"Treats the \'@warn\' rule as a webpack warning.","link":"https://github.com/webpack-contrib/sass-loader#warnruleaswarning","type":"boolean"}},"additionalProperties":false}',
@@ -5605,6 +5607,6 @@
5605
5607
  }
5606
5608
  if (typeof __nccwpck_require__ !== "undefined")
5607
5609
  __nccwpck_require__.ab = __dirname + "/";
5608
- var __webpack_exports__ = __nccwpck_require__(522);
5610
+ var __webpack_exports__ = __nccwpck_require__(867);
5609
5611
  module.exports = __webpack_exports__;
5610
5612
  })();
@@ -1 +1 @@
1
- {"name":"sass-loader","author":"J. Tangelder","version":"16.0.2","funding":{"type":"opencollective","url":"https://opencollective.com/webpack"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"sass-loader","author":"J. Tangelder","version":"16.0.3","funding":{"type":"opencollective","url":"https://opencollective.com/webpack"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -1,16 +1,16 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 994: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- const loader = __nccwpck_require__(170);
4
+ 151: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ const loader = __nccwpck_require__(118);
6
6
  module.exports = loader.default;
7
7
  },
8
- 170: (__unused_webpack_module, exports, __nccwpck_require__) => {
8
+ 118: (__unused_webpack_module, exports, __nccwpck_require__) => {
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports["default"] = void 0;
11
11
  var _path = _interopRequireDefault(__nccwpck_require__(17));
12
- var _utils = __nccwpck_require__(109);
13
- var _options = _interopRequireDefault(__nccwpck_require__(877));
12
+ var _utils = __nccwpck_require__(171);
13
+ var _options = _interopRequireDefault(__nccwpck_require__(861));
14
14
  function _interopRequireDefault(obj) {
15
15
  return obj && obj.__esModule ? obj : { default: obj };
16
16
  }
@@ -95,7 +95,7 @@
95
95
  };
96
96
  var _default = (exports["default"] = loader);
97
97
  },
98
- 962: (module) => {
98
+ 548: (module) => {
99
99
  function isEqualLocals(a, b, isNamedExport) {
100
100
  if ((!a && b) || (a && !b)) {
101
101
  return false;
@@ -121,7 +121,7 @@
121
121
  }
122
122
  module.exports = isEqualLocals;
123
123
  },
124
- 109: (__unused_webpack_module, exports, __nccwpck_require__) => {
124
+ 171: (__unused_webpack_module, exports, __nccwpck_require__) => {
125
125
  Object.defineProperty(exports, "__esModule", { value: true });
126
126
  exports.getExportLazyStyleCode = getExportLazyStyleCode;
127
127
  exports.getExportStyleCode = getExportStyleCode;
@@ -142,7 +142,7 @@
142
142
  exports.getdomAPI = getdomAPI;
143
143
  exports.stringifyRequest = stringifyRequest;
144
144
  var _path = _interopRequireDefault(__nccwpck_require__(17));
145
- var _isEqualLocals = _interopRequireDefault(__nccwpck_require__(962));
145
+ var _isEqualLocals = _interopRequireDefault(__nccwpck_require__(548));
146
146
  function _interopRequireDefault(obj) {
147
147
  return obj && obj.__esModule ? obj : { default: obj };
148
148
  }
@@ -337,7 +337,7 @@
337
337
  17: (module) => {
338
338
  module.exports = require("path");
339
339
  },
340
- 877: (module) => {
340
+ 861: (module) => {
341
341
  module.exports = JSON.parse(
342
342
  '{"title":"Style Loader options","type":"object","properties":{"injectType":{"description":"Allows to setup how styles will be injected into DOM.","link":"https://github.com/webpack-contrib/style-loader#injecttype","enum":["styleTag","singletonStyleTag","autoStyleTag","lazyStyleTag","lazySingletonStyleTag","lazyAutoStyleTag","linkTag"]},"attributes":{"description":"Adds custom attributes to tag.","link":"https://github.com/webpack-contrib/style-loader#attributes","type":"object"},"insert":{"description":"Inserts `<style>`/`<link>` at the given position.","link":"https://github.com/webpack-contrib/style-loader#insert","type":"string"},"base":{"description":"Sets module ID base for DLLPlugin.","link":"https://github.com/webpack-contrib/style-loader#base","type":"number"},"esModule":{"description":"Use the ES modules syntax.","link":"https://github.com/webpack-contrib/css-loader#esmodule","type":"boolean"},"styleTagTransform":{"description":"Transform tag and css when insert \'style\' tag into the DOM","link":"https://github.com/webpack-contrib/style-loader#styleTagTransform","type":"string"}},"additionalProperties":false}',
343
343
  );
@@ -365,6 +365,6 @@
365
365
  }
366
366
  if (typeof __nccwpck_require__ !== "undefined")
367
367
  __nccwpck_require__.ab = __dirname + "/";
368
- var __webpack_exports__ = __nccwpck_require__(994);
368
+ var __webpack_exports__ = __nccwpck_require__(151);
369
369
  module.exports = __webpack_exports__;
370
370
  })();
@@ -52,9 +52,9 @@ function splitByExperience(ctx) {
52
52
  const { defaultConfig, forceSplittingGroups } = ctx;
53
53
  const experienceCacheGroup = {};
54
54
  const packageRegExps = {
55
- axios: /node_modules[\\/]axios(-.+)?[\\/]/
55
+ axios: /node_modules[\\/]axios(-.+)?[\\/]/,
56
+ polyfill: /node_modules[\\/](?:tslib|core-js|@swc[\\/]helpers)[\\/]/
56
57
  };
57
- packageRegExps.polyfill = /node_modules[\\/](?:tslib|core-js|@swc[\\/]helpers)[\\/]/;
58
58
  for (const [name, test] of Object.entries(packageRegExps)) {
59
59
  const key = `lib-${name}`;
60
60
  experienceCacheGroup[key] = {
@@ -87,6 +87,35 @@ function splitBySize(ctx) {
87
87
  }
88
88
  };
89
89
  }
90
+ const MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/;
91
+ function getPackageNameFromModulePath(modulePath) {
92
+ const handleModuleContext = modulePath?.match(MODULE_PATH_REGEX);
93
+ if (!handleModuleContext) {
94
+ return void 0;
95
+ }
96
+ const [, scope, name] = handleModuleContext;
97
+ const packageName = ["npm", (scope ?? "").replace("@", ""), name].filter(Boolean).join(".");
98
+ return packageName;
99
+ }
100
+ function splitByModule(ctx) {
101
+ const { forceSplittingGroups, defaultConfig } = ctx;
102
+ return {
103
+ ...defaultConfig,
104
+ minSize: 0,
105
+ maxInitialRequests: Number.POSITIVE_INFINITY,
106
+ cacheGroups: {
107
+ ...defaultConfig.cacheGroups,
108
+ ...forceSplittingGroups,
109
+ vendors: {
110
+ priority: -9,
111
+ test: import_constants.NODE_MODULES_REGEX,
112
+ name(module2) {
113
+ return module2 ? getPackageNameFromModulePath(module2.context) : void 0;
114
+ }
115
+ }
116
+ }
117
+ };
118
+ }
90
119
  function splitCustom(ctx) {
91
120
  const { forceSplittingGroups, defaultConfig } = ctx;
92
121
  return {
@@ -98,6 +127,9 @@ function splitCustom(ctx) {
98
127
  }
99
128
  };
100
129
  }
130
+ function allInOne(_ctx) {
131
+ return false;
132
+ }
101
133
  function singleVendor(ctx) {
102
134
  const { defaultConfig, forceSplittingGroups } = ctx;
103
135
  const singleVendorCacheGroup = {
@@ -121,21 +153,25 @@ function singleVendor(ctx) {
121
153
  }
122
154
  const SPLIT_STRATEGY_DISPATCHER = {
123
155
  "split-by-experience": splitByExperience,
156
+ "split-by-module": splitByModule,
124
157
  "split-by-size": splitBySize,
125
158
  custom: splitCustom,
159
+ "all-in-one": allInOne,
126
160
  "single-vendor": singleVendor
127
161
  };
128
162
  const addChunkSplitSupport = ({
129
163
  config,
130
164
  unpackConfig
131
165
  }) => {
132
- const defaultConfig = {};
133
166
  const { chunkSplit } = unpackConfig.performance || {};
134
167
  if (chunkSplit?.strategy) {
135
168
  let forceSplittingGroups = {};
136
169
  if (chunkSplit?.forceSplitting) {
137
170
  forceSplittingGroups = getForceSplittingGroups(chunkSplit.forceSplitting);
138
171
  }
172
+ const defaultConfig = {
173
+ chunks: "all"
174
+ };
139
175
  const splitChunksOptions = SPLIT_STRATEGY_DISPATCHER[chunkSplit.strategy]({
140
176
  defaultConfig,
141
177
  forceSplittingGroups,
@@ -1 +1 @@
1
- {"version":3,"file":"chunkSplit.d.ts","sourceRoot":"","sources":["../../src/bundler-config/chunkSplit.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EAKpB,YAAY,EACb,MAAM,iBAAiB,CAAA;AAmIxB,eAAO,MAAM,oBAAoB,8BAG9B;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,oBAgBH,CAAA"}
1
+ {"version":3,"file":"chunkSplit.d.ts","sourceRoot":"","sources":["../../src/bundler-config/chunkSplit.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EAKpB,YAAY,EACb,MAAM,iBAAiB,CAAA;AA4KxB,eAAO,MAAM,oBAAoB,8BAG9B;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,oBAkBH,CAAA"}
@@ -29,9 +29,9 @@ function splitByExperience(ctx) {
29
29
  const { defaultConfig, forceSplittingGroups } = ctx;
30
30
  const experienceCacheGroup = {};
31
31
  const packageRegExps = {
32
- axios: /node_modules[\\/]axios(-.+)?[\\/]/
32
+ axios: /node_modules[\\/]axios(-.+)?[\\/]/,
33
+ polyfill: /node_modules[\\/](?:tslib|core-js|@swc[\\/]helpers)[\\/]/
33
34
  };
34
- packageRegExps.polyfill = /node_modules[\\/](?:tslib|core-js|@swc[\\/]helpers)[\\/]/;
35
35
  for (const [name, test] of Object.entries(packageRegExps)) {
36
36
  const key = `lib-${name}`;
37
37
  experienceCacheGroup[key] = {
@@ -64,6 +64,35 @@ function splitBySize(ctx) {
64
64
  }
65
65
  };
66
66
  }
67
+ const MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/;
68
+ function getPackageNameFromModulePath(modulePath) {
69
+ const handleModuleContext = modulePath?.match(MODULE_PATH_REGEX);
70
+ if (!handleModuleContext) {
71
+ return void 0;
72
+ }
73
+ const [, scope, name] = handleModuleContext;
74
+ const packageName = ["npm", (scope ?? "").replace("@", ""), name].filter(Boolean).join(".");
75
+ return packageName;
76
+ }
77
+ function splitByModule(ctx) {
78
+ const { forceSplittingGroups, defaultConfig } = ctx;
79
+ return {
80
+ ...defaultConfig,
81
+ minSize: 0,
82
+ maxInitialRequests: Number.POSITIVE_INFINITY,
83
+ cacheGroups: {
84
+ ...defaultConfig.cacheGroups,
85
+ ...forceSplittingGroups,
86
+ vendors: {
87
+ priority: -9,
88
+ test: NODE_MODULES_REGEX,
89
+ name(module) {
90
+ return module ? getPackageNameFromModulePath(module.context) : void 0;
91
+ }
92
+ }
93
+ }
94
+ };
95
+ }
67
96
  function splitCustom(ctx) {
68
97
  const { forceSplittingGroups, defaultConfig } = ctx;
69
98
  return {
@@ -75,6 +104,9 @@ function splitCustom(ctx) {
75
104
  }
76
105
  };
77
106
  }
107
+ function allInOne(_ctx) {
108
+ return false;
109
+ }
78
110
  function singleVendor(ctx) {
79
111
  const { defaultConfig, forceSplittingGroups } = ctx;
80
112
  const singleVendorCacheGroup = {
@@ -98,21 +130,25 @@ function singleVendor(ctx) {
98
130
  }
99
131
  const SPLIT_STRATEGY_DISPATCHER = {
100
132
  "split-by-experience": splitByExperience,
133
+ "split-by-module": splitByModule,
101
134
  "split-by-size": splitBySize,
102
135
  custom: splitCustom,
136
+ "all-in-one": allInOne,
103
137
  "single-vendor": singleVendor
104
138
  };
105
139
  const addChunkSplitSupport = ({
106
140
  config,
107
141
  unpackConfig
108
142
  }) => {
109
- const defaultConfig = {};
110
143
  const { chunkSplit } = unpackConfig.performance || {};
111
144
  if (chunkSplit?.strategy) {
112
145
  let forceSplittingGroups = {};
113
146
  if (chunkSplit?.forceSplitting) {
114
147
  forceSplittingGroups = getForceSplittingGroups(chunkSplit.forceSplitting);
115
148
  }
149
+ const defaultConfig = {
150
+ chunks: "all"
151
+ };
116
152
  const splitChunksOptions = SPLIT_STRATEGY_DISPATCHER[chunkSplit.strategy]({
117
153
  defaultConfig,
118
154
  forceSplittingGroups,
@@ -34,13 +34,13 @@ module.exports = __toCommonJS(helper_exports);
34
34
  var import_node_fs = __toESM(require("node:fs"));
35
35
  var import_node_path = __toESM(require("node:path"));
36
36
  var import_utils = require("../utils.cjs");
37
+ var import_tinyglobby = require("tinyglobby");
37
38
  var import_constants = require("../constants.cjs");
38
39
  var import_logger = require("../logger.cjs");
39
- const glob = require("../../compiled/fast-glob/index.js");
40
40
  async function getEntry(root, customEntry) {
41
41
  let entry = void 0;
42
42
  if (!customEntry) {
43
- const files = await glob("(index|Index).{js,ts,jsx,tsx}", {
43
+ const files = await (0, import_tinyglobby.glob)("(index|Index).{js,ts,jsx,tsx}", {
44
44
  cwd: import_node_path.default.join(root, "src"),
45
45
  absolute: true
46
46
  });
@@ -7,10 +7,10 @@ var getFilename = () => fileURLToPath(import.meta.url);
7
7
  var getDirname = () => path.dirname(getFilename());
8
8
  var __dirname = /* @__PURE__ */ getDirname();
9
9
  var __filename = /* @__PURE__ */ getFilename();
10
- const glob = require("../../compiled/fast-glob/index.js");
11
10
  import fs from "node:fs";
12
11
  import path2 from "node:path";
13
12
  import { isDev } from "../utils.js";
13
+ import { glob } from "tinyglobby";
14
14
  import { DEV_DEFAULT_FILENAME, PROD_DEFAULT_FILENAME } from "../constants.js";
15
15
  import { logger } from "../logger.js";
16
16
  async function getEntry(root, customEntry) {
@@ -108,7 +108,7 @@ async function getBundlerConfig(unpackConfig) {
108
108
  unpackConfig.define && definePlugin(unpackConfig.define),
109
109
  !unpackConfig.mpa && new import_html_webpack_plugin.default({
110
110
  template: unpackConfig.html?.template || "",
111
- templateContent: unpackConfig.html?.templateContent || import_constants.TEMPLATE_CONTENT,
111
+ templateContent: unpackConfig.html?.templateContent || !unpackConfig.html?.template && import_constants.TEMPLATE_CONTENT,
112
112
  templateParameters: {
113
113
  mountId: unpackConfig.html?.mountId,
114
114
  title: (0, import_utils.isFunction)(unpackConfig.html?.title) ? unpackConfig.html?.title({ entryName: "index" }) : unpackConfig.html?.title,
@@ -124,7 +124,7 @@ async function getBundlerConfig(unpackConfig) {
124
124
  contextRegExp: /moment$/
125
125
  }),
126
126
  unpackConfig.build?.copy && new CopyPlugin({ patterns: unpackConfig.build.copy }),
127
- (0, import_utils.isDev)() && isTs && new ForkTsCheckerWebpackPlugin({
127
+ unpackConfig.build?.typeCheck && (0, import_utils.isDev)() && isTs && new ForkTsCheckerWebpackPlugin({
128
128
  typescript: {
129
129
  // set 'readonly' to avoid emitting tsbuildinfo, as the generated tsbuildinfo will break fork-ts-checker
130
130
  mode: "readonly",
@@ -137,6 +137,10 @@ async function getBundlerConfig(unpackConfig) {
137
137
  paths: [unpackConfig.root]
138
138
  })
139
139
  },
140
+ issue: {
141
+ // ignore types errors from node_modules
142
+ exclude: [({ file = "" }) => import_constants.NODE_MODULES_REGEX.test(file)]
143
+ },
140
144
  logger: {
141
145
  log(message) {
142
146
  if (message.includes("Found")) {
@@ -148,7 +152,7 @@ async function getBundlerConfig(unpackConfig) {
148
152
  }
149
153
  }
150
154
  }),
151
- !(0, import_utils.isDevServer)() && new PluginProgress()
155
+ new PluginProgress()
152
156
  ].filter(Boolean),
153
157
  externals: unpackConfig.externals,
154
158
  resolve: {
@@ -160,15 +164,17 @@ async function getBundlerConfig(unpackConfig) {
160
164
  extensions: [".tsx", ".ts", ".jsx", ".js", ...unpackConfig.resolve?.extensions || []]
161
165
  },
162
166
  experiments: {
163
- lazyCompilation: (0, import_utils.isDevServer)(),
164
- css: false,
165
- ...isRspack && (0, import_utils.isDev)() ? { incremental: true } : {}
167
+ lazyCompilation: unpackConfig.dev?.lazyCompilation && (0, import_utils.isDevServer)(),
168
+ css: false
166
169
  },
167
170
  optimization: {
168
171
  moduleIds: (0, import_utils.isDev)() ? "named" : "deterministic",
169
172
  minimize: Boolean(unpackConfig.build?.minify),
170
173
  minimizer: [
171
- new import_esbuild_loader.EsbuildPlugin({ implementation: import_esbuild.default }),
174
+ new import_esbuild_loader.EsbuildPlugin({
175
+ implementation: import_esbuild.default,
176
+ target: import_constants.ESBUILD_TARGET
177
+ }),
172
178
  new import_minimizer.LightningcssMinifyPlugin(minifyOptions.lightningcss)
173
179
  ]
174
180
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler-config/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAqBzE,wBAAsB,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAoKhG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler-config/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAqBzE,wBAAsB,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA6KhG"}
@@ -10,7 +10,7 @@ var __filename = /* @__PURE__ */ getFilename();
10
10
  import fs from "node:fs";
11
11
  import path2 from "node:path";
12
12
  import { rspack } from "@rspack/core";
13
- import HtmlWebpackPlugin from "html-webpack-plugin";
13
+ import HtmlPlugin from "html-webpack-plugin";
14
14
  import { isDev, isDevServer, isFunction, isPlainObject, isProd, mergeConfig } from "../utils.js";
15
15
  const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
16
16
  const BundleAnalyzerPlugin = require("../../compiled/webpack-bundle-analyzer/index.js").BundleAnalyzerPlugin;
@@ -18,7 +18,7 @@ const CopyWebpackPlugin = require("copy-webpack-plugin");
18
18
  import esbuild from "esbuild";
19
19
  import { EsbuildPlugin } from "esbuild-loader";
20
20
  import json5 from "json5";
21
- import { TEMPLATE_CONTENT } from "../constants.js";
21
+ import { ESBUILD_TARGET, NODE_MODULES_REGEX, TEMPLATE_CONTENT } from "../constants.js";
22
22
  import { LightningcssMinifyPlugin } from "../lightningcss/minimizer.js";
23
23
  import { logger } from "../logger.js";
24
24
  import { getNormalizedPluginsByHook } from "../plugin.js";
@@ -83,9 +83,9 @@ async function getBundlerConfig(unpackConfig) {
83
83
  },
84
84
  plugins: [
85
85
  unpackConfig.define && definePlugin(unpackConfig.define),
86
- !unpackConfig.mpa && new HtmlWebpackPlugin({
86
+ !unpackConfig.mpa && new HtmlPlugin({
87
87
  template: unpackConfig.html?.template || "",
88
- templateContent: unpackConfig.html?.templateContent || TEMPLATE_CONTENT,
88
+ templateContent: unpackConfig.html?.templateContent || !unpackConfig.html?.template && TEMPLATE_CONTENT,
89
89
  templateParameters: {
90
90
  mountId: unpackConfig.html?.mountId,
91
91
  title: isFunction(unpackConfig.html?.title) ? unpackConfig.html?.title({ entryName: "index" }) : unpackConfig.html?.title,
@@ -101,7 +101,7 @@ async function getBundlerConfig(unpackConfig) {
101
101
  contextRegExp: /moment$/
102
102
  }),
103
103
  unpackConfig.build?.copy && new CopyPlugin({ patterns: unpackConfig.build.copy }),
104
- isDev() && isTs && new ForkTsCheckerWebpackPlugin({
104
+ unpackConfig.build?.typeCheck && isDev() && isTs && new ForkTsCheckerWebpackPlugin({
105
105
  typescript: {
106
106
  // set 'readonly' to avoid emitting tsbuildinfo, as the generated tsbuildinfo will break fork-ts-checker
107
107
  mode: "readonly",
@@ -114,6 +114,10 @@ async function getBundlerConfig(unpackConfig) {
114
114
  paths: [unpackConfig.root]
115
115
  })
116
116
  },
117
+ issue: {
118
+ // ignore types errors from node_modules
119
+ exclude: [({ file = "" }) => NODE_MODULES_REGEX.test(file)]
120
+ },
117
121
  logger: {
118
122
  log(message) {
119
123
  if (message.includes("Found")) {
@@ -125,7 +129,7 @@ async function getBundlerConfig(unpackConfig) {
125
129
  }
126
130
  }
127
131
  }),
128
- !isDevServer() && new PluginProgress()
132
+ new PluginProgress()
129
133
  ].filter(Boolean),
130
134
  externals: unpackConfig.externals,
131
135
  resolve: {
@@ -137,15 +141,17 @@ async function getBundlerConfig(unpackConfig) {
137
141
  extensions: [".tsx", ".ts", ".jsx", ".js", ...unpackConfig.resolve?.extensions || []]
138
142
  },
139
143
  experiments: {
140
- lazyCompilation: isDevServer(),
141
- css: false,
142
- ...isRspack && isDev() ? { incremental: true } : {}
144
+ lazyCompilation: unpackConfig.dev?.lazyCompilation && isDevServer(),
145
+ css: false
143
146
  },
144
147
  optimization: {
145
148
  moduleIds: isDev() ? "named" : "deterministic",
146
149
  minimize: Boolean(unpackConfig.build?.minify),
147
150
  minimizer: [
148
- new EsbuildPlugin({ implementation: esbuild }),
151
+ new EsbuildPlugin({
152
+ implementation: esbuild,
153
+ target: ESBUILD_TARGET
154
+ }),
149
155
  new LightningcssMinifyPlugin(minifyOptions.lightningcss)
150
156
  ]
151
157
  },
@@ -23,6 +23,7 @@ __export(constants_exports, {
23
23
  DEFAULT_BROWSERSLIST: () => DEFAULT_BROWSERSLIST,
24
24
  DEFAULT_DEV_HOST: () => DEFAULT_DEV_HOST,
25
25
  DEV_DEFAULT_FILENAME: () => DEV_DEFAULT_FILENAME,
26
+ ESBUILD_TARGET: () => ESBUILD_TARGET,
26
27
  EXPORT_LOCALS_CONVENTION: () => EXPORT_LOCALS_CONVENTION,
27
28
  NODE_MODULES_REGEX: () => NODE_MODULES_REGEX,
28
29
  PROD_DEFAULT_FILENAME: () => PROD_DEFAULT_FILENAME,
@@ -43,13 +44,14 @@ const PROD_DEFAULT_FILENAME = {
43
44
  };
44
45
  const EXPORT_LOCALS_CONVENTION = "camel-case-only";
45
46
  const TEMP_DIR = "node_modules/.unpack";
46
- const NODE_MODULES_REGEX = /node_modules[\\/]/;
47
+ const NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/;
47
48
  const CSS_NAMED_EXPORT = false;
48
49
  const THREAD_OPTIONS = {
49
50
  workers: 2
50
51
  };
51
52
  const DEFAULT_DEV_HOST = "0.0.0.0";
52
53
  const DEFAULT_BROWSERSLIST = ["chrome 87", "edge 88", "firefox 78", "safari 14"];
54
+ const ESBUILD_TARGET = DEFAULT_BROWSERSLIST.map((item) => item.replace(" ", ""));
53
55
  const TEMPLATE_CONTENT = ({ title = "", headTag = "", mountId }) => {
54
56
  return `<!DOCTYPE html>
55
57
  <html lang="en">
@@ -77,6 +79,7 @@ const TEMPLATE_CONTENT = ({ title = "", headTag = "", mountId }) => {
77
79
  DEFAULT_BROWSERSLIST,
78
80
  DEFAULT_DEV_HOST,
79
81
  DEV_DEFAULT_FILENAME,
82
+ ESBUILD_TARGET,
80
83
  EXPORT_LOCALS_CONVENTION,
81
84
  NODE_MODULES_REGEX,
82
85
  PROD_DEFAULT_FILENAME,
@@ -17,6 +17,7 @@ export declare const THREAD_OPTIONS: {
17
17
  };
18
18
  export declare const DEFAULT_DEV_HOST = "0.0.0.0";
19
19
  export declare const DEFAULT_BROWSERSLIST: string[];
20
+ export declare const ESBUILD_TARGET: string[];
20
21
  export declare const TEMPLATE_CONTENT: ({ title, headTag, mountId }: {
21
22
  title?: string;
22
23
  headTag?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,oCAAoC,CAAA;AAC7E,eAAO,MAAM,iBAAiB,QAAoB,CAAA;AAClD,eAAO,MAAM,oBAAoB;;;CAGhC,CAAA;AACD,eAAO,MAAM,qBAAqB;;;CAGjC,CAAA;AACD,eAAO,MAAM,wBAAwB,oBAAoB,CAAA;AACzD,eAAO,MAAM,QAAQ,yBAAyB,CAAA;AAC9C,eAAO,MAAM,kBAAkB,QAAsB,CAAA;AACrD,eAAO,MAAM,gBAAgB,QAAQ,CAAA;AACrC,eAAO,MAAM,cAAc;;CAE1B,CAAA;AACD,eAAO,MAAM,gBAAgB,YAAY,CAAA;AACzC,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAAwD,CAAA;AACjG,eAAO,MAAM,gBAAgB;;;;YAkB5B,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,oCAAoC,CAAA;AAC7E,eAAO,MAAM,iBAAiB,QAAoB,CAAA;AAClD,eAAO,MAAM,oBAAoB;;;CAGhC,CAAA;AACD,eAAO,MAAM,qBAAqB;;;CAGjC,CAAA;AACD,eAAO,MAAM,wBAAwB,oBAAoB,CAAA;AACzD,eAAO,MAAM,QAAQ,yBAAyB,CAAA;AAC9C,eAAO,MAAM,kBAAkB,QAA2B,CAAA;AAC1D,eAAO,MAAM,gBAAgB,QAAQ,CAAA;AACrC,eAAO,MAAM,cAAc;;CAE1B,CAAA;AACD,eAAO,MAAM,gBAAgB,YAAY,CAAA;AACzC,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAAwD,CAAA;AACjG,eAAO,MAAM,cAAc,EAAE,MAAM,EAA8D,CAAA;AACjG,eAAO,MAAM,gBAAgB;;;;YAkB5B,CAAA"}
package/dist/constants.js CHANGED
@@ -19,13 +19,14 @@ const PROD_DEFAULT_FILENAME = {
19
19
  };
20
20
  const EXPORT_LOCALS_CONVENTION = "camel-case-only";
21
21
  const TEMP_DIR = "node_modules/.unpack";
22
- const NODE_MODULES_REGEX = /node_modules[\\/]/;
22
+ const NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/;
23
23
  const CSS_NAMED_EXPORT = false;
24
24
  const THREAD_OPTIONS = {
25
25
  workers: 2
26
26
  };
27
27
  const DEFAULT_DEV_HOST = "0.0.0.0";
28
28
  const DEFAULT_BROWSERSLIST = ["chrome 87", "edge 88", "firefox 78", "safari 14"];
29
+ const ESBUILD_TARGET = DEFAULT_BROWSERSLIST.map((item) => item.replace(" ", ""));
29
30
  const TEMPLATE_CONTENT = ({ title = "", headTag = "", mountId }) => {
30
31
  return `<!DOCTYPE html>
31
32
  <html lang="en">
@@ -52,6 +53,7 @@ export {
52
53
  DEFAULT_BROWSERSLIST,
53
54
  DEFAULT_DEV_HOST,
54
55
  DEV_DEFAULT_FILENAME,
56
+ ESBUILD_TARGET,
55
57
  EXPORT_LOCALS_CONVENTION,
56
58
  NODE_MODULES_REGEX,
57
59
  PROD_DEFAULT_FILENAME,
@@ -45,7 +45,10 @@ function createUnpack() {
45
45
  sourceMap: (0, import_utils.isProd)() ? false : "cheap-module-source-map",
46
46
  parallel: !(0, import_utils.isDevServer)(),
47
47
  filenameHash: true,
48
- cache: (0, import_utils.isDev)()
48
+ typeCheck: true
49
+ },
50
+ dev: {
51
+ lazyCompilation: true
49
52
  },
50
53
  server: {
51
54
  port: 3e3
@@ -73,7 +76,7 @@ function createUnpack() {
73
76
  build: async (unpackConfig) => {
74
77
  (0, import_utils.setNodeEnv)("production");
75
78
  console.log(
76
- import_colors.default.rainbow(`unpack v${"1.6.3"}`),
79
+ import_colors.default.rainbow(`unpack v${"1.7.0"}`),
77
80
  import_colors.default.green("building for production...")
78
81
  );
79
82
  const config = await resolveConfig(unpackConfig);
@@ -89,7 +92,7 @@ function createUnpack() {
89
92
  watch: async (unpackConfig) => {
90
93
  (0, import_utils.setNodeEnv)("development");
91
94
  console.log(
92
- import_colors.default.rainbow(`unpack v${"1.6.3"}`),
95
+ import_colors.default.rainbow(`unpack v${"1.7.0"}`),
93
96
  import_colors.default.green("building for development...")
94
97
  );
95
98
  const config = await resolveConfig(unpackConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"createUnpack.d.ts","sourceRoot":"","sources":["../src/createUnpack.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAGjD,wBAAgB,YAAY;0BAoCI,YAAY;0BASZ,YAAY;0BAOZ,YAAY;EAU3C"}
1
+ {"version":3,"file":"createUnpack.d.ts","sourceRoot":"","sources":["../src/createUnpack.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAGjD,wBAAgB,YAAY;0BAuCI,YAAY;0BASZ,YAAY;0BAOZ,YAAY;EAU3C"}
@@ -10,7 +10,7 @@ var __filename = /* @__PURE__ */ getFilename();
10
10
  import colors from "./colors.js";
11
11
  import { getNormalizedPluginsByHook } from "./plugin.js";
12
12
  import { bundlerBuild, bundlerDev } from "./run/index.js";
13
- import { isDev, isDevServer, isProd, mergeConfig, setDevServer, setNodeEnv } from "./utils.js";
13
+ import { isDevServer, isProd, mergeConfig, setDevServer, setNodeEnv } from "./utils.js";
14
14
  function createUnpack() {
15
15
  const resolveConfig = async (unpackConfig) => {
16
16
  const defaultConfig = {
@@ -22,7 +22,10 @@ function createUnpack() {
22
22
  sourceMap: isProd() ? false : "cheap-module-source-map",
23
23
  parallel: !isDevServer(),
24
24
  filenameHash: true,
25
- cache: isDev()
25
+ typeCheck: true
26
+ },
27
+ dev: {
28
+ lazyCompilation: true
26
29
  },
27
30
  server: {
28
31
  port: 3e3
@@ -50,7 +53,7 @@ function createUnpack() {
50
53
  build: async (unpackConfig) => {
51
54
  setNodeEnv("production");
52
55
  console.log(
53
- colors.rainbow(`unpack v${"1.6.3"}`),
56
+ colors.rainbow(`unpack v${"1.7.0"}`),
54
57
  colors.green("building for production...")
55
58
  );
56
59
  const config = await resolveConfig(unpackConfig);
@@ -66,7 +69,7 @@ function createUnpack() {
66
69
  watch: async (unpackConfig) => {
67
70
  setNodeEnv("development");
68
71
  console.log(
69
- colors.rainbow(`unpack v${"1.6.3"}`),
72
+ colors.rainbow(`unpack v${"1.7.0"}`),
70
73
  colors.green("building for development...")
71
74
  );
72
75
  const config = await resolveConfig(unpackConfig);
package/dist/index.cjs CHANGED
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var src_exports = {};
30
30
  __export(src_exports, {
31
+ HtmlPlugin: () => import_html_webpack_plugin.default,
31
32
  colors: () => import_colors.default
32
33
  });
33
34
  module.exports = __toCommonJS(src_exports);
@@ -38,8 +39,10 @@ __reExport(src_exports, require("./constants.cjs"), module.exports);
38
39
  __reExport(src_exports, require("./createUnpack.cjs"), module.exports);
39
40
  __reExport(src_exports, require("./config.cjs"), module.exports);
40
41
  var import_colors = __toESM(require("./colors.cjs"));
42
+ var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
41
43
  // Annotate the CommonJS export names for ESM import in node:
42
44
  0 && (module.exports = {
45
+ HtmlPlugin,
43
46
  colors,
44
47
  ...require("./logger.cjs"),
45
48
  ...require("./types/index.cjs"),
package/dist/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export * from './constants';
5
5
  export * from './createUnpack';
6
6
  export * from './config';
7
7
  export { default as colors } from './colors';
8
+ export { default as HtmlPlugin } from 'html-webpack-plugin';
8
9
  //# sourceMappingURL=index.d.ts.map