@unpackjs/core 1.7.4 → 1.7.6

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 (123) hide show
  1. package/compiled/css-loader/index.js +178 -178
  2. package/compiled/less-loader/index.js +11 -11
  3. package/compiled/line-diff/index.js +4 -4
  4. package/compiled/portfinder/index.js +37 -37
  5. package/compiled/postcss-loader/index.js +261 -256
  6. package/compiled/sass-loader/index.js +18 -18
  7. package/compiled/semver/index.js +188 -170
  8. package/compiled/semver/package.json +1 -1
  9. package/compiled/style-loader/index.js +13 -13
  10. package/compiled/webpack-bundle-analyzer/index.js +198 -198
  11. package/compiled/webpack-merge/index.js +29 -29
  12. package/dist/bundler-config/chunkSplit.cjs +169 -156
  13. package/dist/bundler-config/chunkSplit.d.ts +1 -1
  14. package/dist/bundler-config/chunkSplit.js +125 -134
  15. package/dist/bundler-config/css.cjs +181 -158
  16. package/dist/bundler-config/css.d.ts +1 -1
  17. package/dist/bundler-config/css.js +139 -151
  18. package/dist/bundler-config/experimentCss.cjs +203 -159
  19. package/dist/bundler-config/experimentCss.d.ts +1 -1
  20. package/dist/bundler-config/experimentCss.js +162 -152
  21. package/dist/bundler-config/helper.cjs +82 -78
  22. package/dist/bundler-config/helper.js +36 -55
  23. package/dist/bundler-config/index.cjs +260 -209
  24. package/dist/bundler-config/index.d.ts +1 -1
  25. package/dist/bundler-config/index.d.ts.map +1 -1
  26. package/dist/bundler-config/index.js +209 -182
  27. package/dist/bundler-config/jsMinify.cjs +114 -95
  28. package/dist/bundler-config/jsMinify.js +70 -73
  29. package/dist/colors.cjs +83 -56
  30. package/dist/colors.js +38 -37
  31. package/dist/config.cjs +107 -93
  32. package/dist/config.d.ts +1 -1
  33. package/dist/config.d.ts.map +1 -1
  34. package/dist/config.js +64 -70
  35. package/dist/constants.cjs +62 -62
  36. package/dist/constants.js +20 -38
  37. package/dist/createUnpack.cjs +111 -104
  38. package/dist/createUnpack.js +67 -82
  39. package/dist/global.cjs +36 -0
  40. package/dist/global.d.ts +2 -0
  41. package/dist/global.d.ts.map +1 -0
  42. package/dist/global.js +4 -0
  43. package/dist/index.cjs +174 -51
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +33 -15
  47. package/dist/lightningcss/cache.cjs +40 -32
  48. package/dist/lightningcss/cache.js +10 -20
  49. package/dist/lightningcss/loader.cjs +56 -53
  50. package/dist/lightningcss/loader.d.ts +1 -1
  51. package/dist/lightningcss/loader.js +25 -34
  52. package/dist/lightningcss/minimizer.cjs +90 -109
  53. package/dist/lightningcss/minimizer.d.ts +1 -1
  54. package/dist/lightningcss/minimizer.js +59 -87
  55. package/dist/logger.cjs +104 -98
  56. package/dist/logger.d.ts +1 -1
  57. package/dist/logger.js +59 -76
  58. package/dist/openBrowser.cjs +104 -81
  59. package/dist/openBrowser.js +56 -52
  60. package/dist/plugin-progress/rspack.cjs +104 -79
  61. package/dist/plugin-progress/rspack.d.ts +1 -1
  62. package/dist/plugin-progress/rspack.js +59 -57
  63. package/dist/plugin-progress/webpack.cjs +111 -89
  64. package/dist/plugin-progress/webpack.d.ts +1 -1
  65. package/dist/plugin-progress/webpack.js +65 -67
  66. package/dist/plugin.cjs +38 -29
  67. package/dist/plugin.js +8 -17
  68. package/dist/prebundleDeps.cjs +327 -337
  69. package/dist/prebundleDeps.d.ts.map +1 -1
  70. package/dist/prebundleDeps.js +278 -324
  71. package/dist/progressBar.cjs +82 -65
  72. package/dist/progressBar.js +38 -43
  73. package/dist/reporter.cjs +135 -120
  74. package/dist/reporter.js +88 -98
  75. package/dist/run/build.cjs +68 -67
  76. package/dist/run/build.d.ts +1 -1
  77. package/dist/run/build.js +24 -45
  78. package/dist/run/dev.cjs +96 -83
  79. package/dist/run/dev.d.ts +1 -1
  80. package/dist/run/dev.d.ts.map +1 -1
  81. package/dist/run/dev.js +50 -61
  82. package/dist/run/index.cjs +74 -21
  83. package/dist/run/index.js +2 -9
  84. package/dist/typed-css-modules/loader.cjs +179 -188
  85. package/dist/typed-css-modules/loader.d.ts +1 -1
  86. package/dist/typed-css-modules/loader.js +118 -151
  87. package/dist/typed-css-modules/plugin.cjs +113 -88
  88. package/dist/typed-css-modules/plugin.d.ts +1 -1
  89. package/dist/typed-css-modules/plugin.js +68 -66
  90. package/dist/typed-css-modules/utils.cjs +43 -42
  91. package/dist/typed-css-modules/utils.d.ts +1 -1
  92. package/dist/typed-css-modules/utils.js +13 -30
  93. package/dist/types/chunkSplit.cjs +19 -15
  94. package/dist/types/chunkSplit.d.ts +2 -10
  95. package/dist/types/chunkSplit.d.ts.map +1 -1
  96. package/dist/types/chunkSplit.js +2 -9
  97. package/dist/types/config.cjs +19 -15
  98. package/dist/types/config.d.ts +1 -5
  99. package/dist/types/config.d.ts.map +1 -1
  100. package/dist/types/config.js +2 -9
  101. package/dist/types/index.cjs +101 -27
  102. package/dist/types/index.js +2 -9
  103. package/dist/types/lightningcss.cjs +19 -15
  104. package/dist/types/lightningcss.js +2 -9
  105. package/dist/types/logger.cjs +43 -34
  106. package/dist/types/logger.js +13 -22
  107. package/dist/types/plugin.cjs +19 -15
  108. package/dist/types/plugin.js +2 -9
  109. package/dist/utils.cjs +280 -304
  110. package/dist/utils.js +195 -241
  111. package/dist/watchFiles.cjs +73 -0
  112. package/dist/watchFiles.d.ts +3 -0
  113. package/dist/watchFiles.d.ts.map +1 -0
  114. package/dist/watchFiles.js +27 -0
  115. package/package.json +14 -17
  116. package/compiled/commander/index.d.ts +0 -971
  117. package/compiled/commander/index.js +0 -2190
  118. package/compiled/commander/license +0 -22
  119. package/compiled/commander/package.json +0 -1
  120. package/dist/bundleRequire.cjs +0 -200
  121. package/dist/bundleRequire.d.ts +0 -5
  122. package/dist/bundleRequire.d.ts.map +0 -1
  123. package/dist/bundleRequire.js +0 -173
package/dist/reporter.js CHANGED
@@ -1,109 +1,99 @@
1
- import { createRequire } from 'node:module';
2
- var require = createRequire(import.meta['url']);
3
-
4
- import path from "path";
5
- import { fileURLToPath } from "url";
6
- var getFilename = () => fileURLToPath(import.meta.url);
7
- var getDirname = () => path.dirname(getFilename());
8
- var __dirname = /* @__PURE__ */ getDirname();
9
- var __filename = /* @__PURE__ */ getFilename();
10
- import fs from "node:fs";
11
- import path2 from "node:path";
12
- import { promisify } from "node:util";
13
- import zlib from "node:zlib";
14
- import colors from "./colors.js";
1
+ import __rslib_shim_module__ from 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
5
+ import * as __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__ from "node:util";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_node_zlib_a5bb16fc__ from "node:zlib";
7
+ import * as __WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__ from "./colors.js";
15
8
  const chunkGroups = [
16
- { type: "HTML", color: "green", chunks: [] },
17
- { type: "CSS", color: "magenta", chunks: [] },
18
- { type: "JS", color: "cyan", chunks: [] }
9
+ {
10
+ type: 'HTML',
11
+ color: 'green',
12
+ chunks: []
13
+ },
14
+ {
15
+ type: 'CSS',
16
+ color: 'magenta',
17
+ chunks: []
18
+ },
19
+ {
20
+ type: 'JS',
21
+ color: 'cyan',
22
+ chunks: []
23
+ }
19
24
  ];
20
- const chunkGroupMap = chunkGroups.reduce(
21
- (acc, cur) => {
25
+ const chunkGroupMap = chunkGroups.reduce((acc, cur)=>{
22
26
  acc[cur.type] = cur;
23
27
  return acc;
24
- },
25
- {}
26
- );
28
+ }, {});
27
29
  const chunkSizeLimit = 500;
28
- const gzip = promisify(zlib.gzip);
29
- const numberFormatter = new Intl.NumberFormat("en", {
30
- maximumFractionDigits: 2,
31
- minimumFractionDigits: 2
30
+ const gzip = (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(__WEBPACK_EXTERNAL_MODULE_node_zlib_a5bb16fc__["default"].gzip);
31
+ const numberFormatter = new Intl.NumberFormat('en', {
32
+ maximumFractionDigits: 2,
33
+ minimumFractionDigits: 2
32
34
  });
33
- const displaySize = (bytes) => {
34
- return `${numberFormatter.format(bytes / 1e3)} kB`;
35
- };
35
+ const displaySize = (bytes)=>`${numberFormatter.format(bytes / 1000)} kB`;
36
36
  async function getCompressedSize(content) {
37
- const data = await gzip(content);
38
- return data.length;
37
+ const data = await gzip(content);
38
+ return data.length;
39
39
  }
40
40
  async function printFileSize({ root, stats }) {
41
- const distPath = stats.compilation.outputOptions.path;
42
- const distFolder = path2.relative(root, distPath);
43
- const origin = stats.toJson({
44
- all: false,
45
- assets: true,
46
- cachedAssets: true,
47
- groupAssetsByInfo: false,
48
- groupAssetsByPath: false,
49
- groupAssetsByChunk: false,
50
- groupAssetsByExtension: false,
51
- groupAssetsByEmitStatus: false
52
- });
53
- let longest = 0;
54
- let biggestSize = 0;
55
- let biggestCompressSize = 0;
56
- await Promise.all(
57
- origin.assets.map(async (asset) => {
58
- const content = await fs.promises.readFile(path2.join(distPath, asset.name));
59
- const size = content.length;
60
- const compressedSize = await getCompressedSize(content);
61
- const chunk = {
62
- name: path2.basename(asset.name),
63
- path: `${distFolder}/${asset.name}`,
64
- size,
65
- compressedSize
66
- };
67
- if (chunk.path.length > longest) {
68
- longest = chunk.path.length;
69
- }
70
- if (size > biggestSize)
71
- biggestSize = size;
72
- if (compressedSize > biggestCompressSize)
73
- biggestCompressSize = compressedSize;
74
- const ext = path2.extname(asset.name);
75
- switch (ext) {
76
- case ".html":
77
- chunkGroupMap.HTML.chunks.push(chunk);
78
- break;
79
- case ".css":
80
- chunkGroupMap.CSS.chunks.push(chunk);
81
- break;
82
- case ".js":
83
- chunkGroupMap.JS.chunks.push(chunk);
84
- break;
85
- default:
86
- break;
87
- }
88
- })
89
- );
90
- const sizePad = displaySize(biggestSize).length;
91
- const compressPad = displaySize(biggestCompressSize).length;
92
- chunkGroups.forEach((group) => {
93
- group.chunks.sort((a, b) => a.size - b.size).forEach((chunk) => {
94
- const isLarge = group.type === "JS" && chunk.size / 1e3 > chunkSizeLimit;
95
- const sizeColor = isLarge ? "yellow" : "dim";
96
- const relativeOutDir = path2.dirname(chunk.path) + "/";
97
- let log = colors.dim(relativeOutDir);
98
- log += colors[group.color](chunk.name.padEnd(longest + 2 - relativeOutDir.length));
99
- log += colors[sizeColor](colors.bold(displaySize(chunk.size).padStart(sizePad)));
100
- if (chunk.compressedSize) {
101
- log += colors.dim(` │ gzip: ${displaySize(chunk.compressedSize).padStart(compressPad)}`);
102
- }
103
- console.log(log);
41
+ const distPath = stats.compilation.outputOptions.path;
42
+ const distFolder = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, distPath);
43
+ const origin = stats.toJson({
44
+ all: false,
45
+ assets: true,
46
+ cachedAssets: true,
47
+ groupAssetsByInfo: false,
48
+ groupAssetsByPath: false,
49
+ groupAssetsByChunk: false,
50
+ groupAssetsByExtension: false,
51
+ groupAssetsByEmitStatus: false
52
+ });
53
+ let longest = 0;
54
+ let biggestSize = 0;
55
+ let biggestCompressSize = 0;
56
+ await Promise.all(origin.assets.map(async (asset)=>{
57
+ const content = await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].promises.readFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(distPath, asset.name));
58
+ const size = content.length;
59
+ const compressedSize = await getCompressedSize(content);
60
+ const chunk = {
61
+ name: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(asset.name),
62
+ path: `${distFolder}/${asset.name}`,
63
+ size,
64
+ compressedSize
65
+ };
66
+ if (chunk.path.length > longest) longest = chunk.path.length;
67
+ if (size > biggestSize) biggestSize = size;
68
+ if (compressedSize > biggestCompressSize) biggestCompressSize = compressedSize;
69
+ const ext = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(asset.name);
70
+ switch(ext){
71
+ case '.html':
72
+ chunkGroupMap.HTML.chunks.push(chunk);
73
+ break;
74
+ case '.css':
75
+ chunkGroupMap.CSS.chunks.push(chunk);
76
+ break;
77
+ case '.js':
78
+ chunkGroupMap.JS.chunks.push(chunk);
79
+ break;
80
+ default:
81
+ break;
82
+ }
83
+ }));
84
+ const sizePad = displaySize(biggestSize).length;
85
+ const compressPad = displaySize(biggestCompressSize).length;
86
+ chunkGroups.forEach((group)=>{
87
+ group.chunks.sort((a, b)=>a.size - b.size).forEach((chunk)=>{
88
+ const isLarge = 'JS' === group.type && chunk.size / 1000 > chunkSizeLimit;
89
+ const sizeColor = isLarge ? 'yellow' : 'dim';
90
+ const relativeOutDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(chunk.path) + '/';
91
+ let log = __WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"].dim(relativeOutDir);
92
+ log += __WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"][group.color](chunk.name.padEnd(longest + 2 - relativeOutDir.length));
93
+ log += __WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"][sizeColor](__WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"].bold(displaySize(chunk.size).padStart(sizePad)));
94
+ if (chunk.compressedSize) log += __WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"].dim(` gzip: ${displaySize(chunk.compressedSize).padStart(compressPad)}`);
95
+ console.log(log);
96
+ });
104
97
  });
105
- });
106
98
  }
107
- export {
108
- printFileSize
109
- };
99
+ export { printFileSize };
@@ -1,71 +1,72 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var build_exports = {};
29
- __export(build_exports, {
30
- bundlerBuild: () => bundlerBuild
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = function(module) {
5
+ var getter = module && module.__esModule ? function() {
6
+ return module['default'];
7
+ } : function() {
8
+ return module;
9
+ };
10
+ __webpack_require__.d(getter, {
11
+ a: getter
12
+ });
13
+ return getter;
14
+ };
15
+ })();
16
+ (()=>{
17
+ __webpack_require__.d = function(exports1, definition) {
18
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
19
+ enumerable: true,
20
+ get: definition[key]
21
+ });
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = function(obj, prop) {
26
+ return Object.prototype.hasOwnProperty.call(obj, prop);
27
+ };
28
+ })();
29
+ (()=>{
30
+ __webpack_require__.r = function(exports1) {
31
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
32
+ value: 'Module'
33
+ });
34
+ Object.defineProperty(exports1, '__esModule', {
35
+ value: true
36
+ });
37
+ };
38
+ })();
39
+ var __webpack_exports__ = {};
40
+ __webpack_require__.r(__webpack_exports__);
41
+ __webpack_require__.d(__webpack_exports__, {
42
+ bundlerBuild: ()=>bundlerBuild
31
43
  });
32
- module.exports = __toCommonJS(build_exports);
33
- var import_core = require("@rspack/core");
34
- var import_utils = require("../utils.cjs");
35
- var import_webpack = __toESM(require("webpack"));
36
- var import_bundler_config = require("../bundler-config/index.cjs");
44
+ const core_namespaceObject = require("@rspack/core");
45
+ const external_utils_cjs_namespaceObject = require("../utils.cjs");
46
+ const external_webpack_namespaceObject = require("webpack");
47
+ var external_webpack_default = /*#__PURE__*/ __webpack_require__.n(external_webpack_namespaceObject);
48
+ const index_cjs_namespaceObject = require("../bundler-config/index.cjs");
37
49
  async function bundlerBuild(unpackConfig) {
38
- const bundler = unpackConfig.bundler === "rspack" ? import_core.rspack : import_webpack.default;
39
- const config = await (0, import_bundler_config.getBundlerConfig)(unpackConfig);
40
- const compiler = bundler(config);
41
- const handler = (err, stats) => {
42
- if (err) {
43
- console.error(err.stack || err);
44
- if (err.details) {
45
- console.error(err.details);
46
- }
47
- return;
48
- }
49
- if (stats?.hasErrors()) {
50
- console.log(
51
- stats.toString({
52
- colors: true,
53
- preset: "errors-only"
54
- })
55
- );
56
- }
57
- if (!(0, import_utils.isWatch)()) {
58
- compiler.close(() => {
59
- });
60
- }
61
- };
62
- if ((0, import_utils.isWatch)()) {
63
- compiler.watch({}, handler);
64
- } else {
65
- compiler.run(handler);
66
- }
50
+ const bundler = 'rspack' === unpackConfig.bundler ? core_namespaceObject.rspack : external_webpack_default();
51
+ const config = await (0, index_cjs_namespaceObject.getBundlerConfig)(unpackConfig);
52
+ const compiler = bundler(config);
53
+ const handler = (err, stats)=>{
54
+ if (err) {
55
+ console.error(err.stack || err);
56
+ if (err.details) console.error(err.details);
57
+ return;
58
+ }
59
+ if (null == stats ? void 0 : stats.hasErrors()) console.log(stats.toString({
60
+ colors: true,
61
+ preset: 'errors-only'
62
+ }));
63
+ if (!(0, external_utils_cjs_namespaceObject.isWatch)()) compiler.close(()=>{});
64
+ };
65
+ if ((0, external_utils_cjs_namespaceObject.isWatch)()) compiler.watch({}, handler);
66
+ else compiler.run(handler);
67
67
  }
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
70
- bundlerBuild
68
+ var __webpack_export_target__ = exports;
69
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
70
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
71
+ value: true
71
72
  });
@@ -1,3 +1,3 @@
1
- import type { UnpackConfig } from '../types/index';
1
+ import type { UnpackConfig } from 'src/types/index';
2
2
  export declare function bundlerBuild(unpackConfig: UnpackConfig): Promise<void>;
3
3
  //# sourceMappingURL=build.d.ts.map
package/dist/run/build.js CHANGED
@@ -1,47 +1,26 @@
1
- import { createRequire } from 'node:module';
2
- var require = createRequire(import.meta['url']);
3
-
4
- import path from "path";
5
- import { fileURLToPath } from "url";
6
- var getFilename = () => fileURLToPath(import.meta.url);
7
- var getDirname = () => path.dirname(getFilename());
8
- var __dirname = /* @__PURE__ */ getDirname();
9
- var __filename = /* @__PURE__ */ getFilename();
10
- import { rspack } from "@rspack/core";
11
- import { isWatch } from "../utils.js";
12
- import webpack from "webpack";
13
- import { getBundlerConfig } from "../bundler-config/index.js";
1
+ import __rslib_shim_module__ from 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ import * as __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__ from "@rspack/core";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__ from "../utils.js";
5
+ import * as __WEBPACK_EXTERNAL_MODULE_webpack__ from "webpack";
6
+ import * as __WEBPACK_EXTERNAL_MODULE__bundler_config_index_js_e76188c2__ from "../bundler-config/index.js";
14
7
  async function bundlerBuild(unpackConfig) {
15
- const bundler = unpackConfig.bundler === "rspack" ? rspack : webpack;
16
- const config = await getBundlerConfig(unpackConfig);
17
- const compiler = bundler(config);
18
- const handler = (err, stats) => {
19
- if (err) {
20
- console.error(err.stack || err);
21
- if (err.details) {
22
- console.error(err.details);
23
- }
24
- return;
25
- }
26
- if (stats?.hasErrors()) {
27
- console.log(
28
- stats.toString({
29
- colors: true,
30
- preset: "errors-only"
31
- })
32
- );
33
- }
34
- if (!isWatch()) {
35
- compiler.close(() => {
36
- });
37
- }
38
- };
39
- if (isWatch()) {
40
- compiler.watch({}, handler);
41
- } else {
42
- compiler.run(handler);
43
- }
8
+ const bundler = 'rspack' === unpackConfig.bundler ? __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack : __WEBPACK_EXTERNAL_MODULE_webpack__["default"];
9
+ const config = await (0, __WEBPACK_EXTERNAL_MODULE__bundler_config_index_js_e76188c2__.getBundlerConfig)(unpackConfig);
10
+ const compiler = bundler(config);
11
+ const handler = (err, stats)=>{
12
+ if (err) {
13
+ console.error(err.stack || err);
14
+ if (err.details) console.error(err.details);
15
+ return;
16
+ }
17
+ if (null == stats ? void 0 : stats.hasErrors()) console.log(stats.toString({
18
+ colors: true,
19
+ preset: 'errors-only'
20
+ }));
21
+ if (!(0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.isWatch)()) compiler.close(()=>{});
22
+ };
23
+ if ((0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.isWatch)()) compiler.watch({}, handler);
24
+ else compiler.run(handler);
44
25
  }
45
- export {
46
- bundlerBuild
47
- };
26
+ export { bundlerBuild };
package/dist/run/dev.cjs CHANGED
@@ -1,90 +1,103 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var dev_exports = {};
29
- __export(dev_exports, {
30
- bundlerDev: () => bundlerDev
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = function(module) {
5
+ var getter = module && module.__esModule ? function() {
6
+ return module['default'];
7
+ } : function() {
8
+ return module;
9
+ };
10
+ __webpack_require__.d(getter, {
11
+ a: getter
12
+ });
13
+ return getter;
14
+ };
15
+ })();
16
+ (()=>{
17
+ __webpack_require__.d = function(exports1, definition) {
18
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
19
+ enumerable: true,
20
+ get: definition[key]
21
+ });
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = function(obj, prop) {
26
+ return Object.prototype.hasOwnProperty.call(obj, prop);
27
+ };
28
+ })();
29
+ (()=>{
30
+ __webpack_require__.r = function(exports1) {
31
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
32
+ value: 'Module'
33
+ });
34
+ Object.defineProperty(exports1, '__esModule', {
35
+ value: true
36
+ });
37
+ };
38
+ })();
39
+ var __webpack_exports__ = {};
40
+ __webpack_require__.r(__webpack_exports__);
41
+ __webpack_require__.d(__webpack_exports__, {
42
+ bundlerDev: ()=>bundlerDev
31
43
  });
32
- module.exports = __toCommonJS(dev_exports);
33
- var import_core = require("@rspack/core");
34
- var import_colors = __toESM(require("../colors.cjs"));
35
- var import_logger = require("../logger.cjs");
36
- var import_openBrowser = require("../openBrowser.cjs");
37
- var import_prebundleDeps = require("../prebundleDeps.cjs");
38
- var import_utils = require("../utils.cjs");
39
- var import_webpack = __toESM(require("webpack"));
40
- var import_webpack_dev_server = __toESM(require("webpack-dev-server"));
41
- var import_bundler_config = require("../bundler-config/index.cjs");
44
+ const core_namespaceObject = require("@rspack/core");
45
+ const external_colors_cjs_namespaceObject = require("../colors.cjs");
46
+ var external_colors_cjs_default = /*#__PURE__*/ __webpack_require__.n(external_colors_cjs_namespaceObject);
47
+ const external_global_cjs_namespaceObject = require("../global.cjs");
48
+ const external_logger_cjs_namespaceObject = require("../logger.cjs");
49
+ const external_openBrowser_cjs_namespaceObject = require("../openBrowser.cjs");
50
+ const external_prebundleDeps_cjs_namespaceObject = require("../prebundleDeps.cjs");
51
+ const external_utils_cjs_namespaceObject = require("../utils.cjs");
52
+ const external_webpack_namespaceObject = require("webpack");
53
+ var external_webpack_default = /*#__PURE__*/ __webpack_require__.n(external_webpack_namespaceObject);
54
+ const external_webpack_dev_server_namespaceObject = require("webpack-dev-server");
55
+ var external_webpack_dev_server_default = /*#__PURE__*/ __webpack_require__.n(external_webpack_dev_server_namespaceObject);
56
+ const index_cjs_namespaceObject = require("../bundler-config/index.cjs");
42
57
  async function bundlerDev(originalUnpackConfig) {
43
- let unpackConfig = originalUnpackConfig;
44
- const bundler = unpackConfig.bundler === "rspack" ? import_core.rspack : import_webpack.default;
45
- if (unpackConfig.dev?.prebundle) {
46
- unpackConfig = await (0, import_prebundleDeps.prebundleDeps)({ unpackConfig });
47
- }
48
- const config = await (0, import_bundler_config.getBundlerConfig)(unpackConfig);
49
- const compiler = bundler(config);
50
- const port = await (0, import_utils.getPort)(unpackConfig.server?.port);
51
- const devServerOptions = {
52
- hot: true,
53
- port,
54
- open: false,
55
- client: {
56
- overlay: false
57
- },
58
- proxy: unpackConfig.server?.proxy,
59
- devMiddleware: {
60
- writeToDisk: unpackConfig.dev?.writeToDisk
58
+ var _unpackConfig_dev, _unpackConfig_server, _unpackConfig_server1, _unpackConfig_dev1;
59
+ let unpackConfig = originalUnpackConfig;
60
+ const bundler = 'rspack' === unpackConfig.bundler ? core_namespaceObject.rspack : external_webpack_default();
61
+ if (null === (_unpackConfig_dev = unpackConfig.dev) || void 0 === _unpackConfig_dev ? void 0 : _unpackConfig_dev.prebundle) unpackConfig = await (0, external_prebundleDeps_cjs_namespaceObject.prebundleDeps)({
62
+ unpackConfig
63
+ });
64
+ const config = await (0, index_cjs_namespaceObject.getBundlerConfig)(unpackConfig);
65
+ const compiler = bundler(config);
66
+ const port = await (0, external_utils_cjs_namespaceObject.getPort)(null === (_unpackConfig_server = unpackConfig.server) || void 0 === _unpackConfig_server ? void 0 : _unpackConfig_server.port);
67
+ const devServerOptions = {
68
+ hot: true,
69
+ port,
70
+ open: false,
71
+ client: {
72
+ overlay: false
73
+ },
74
+ proxy: null === (_unpackConfig_server1 = unpackConfig.server) || void 0 === _unpackConfig_server1 ? void 0 : _unpackConfig_server1.proxy,
75
+ devMiddleware: {
76
+ writeToDisk: null === (_unpackConfig_dev1 = unpackConfig.dev) || void 0 === _unpackConfig_dev1 ? void 0 : _unpackConfig_dev1.writeToDisk
77
+ }
78
+ };
79
+ const server = new (external_webpack_dev_server_default())(devServerOptions, compiler);
80
+ external_logger_cjs_namespaceObject.logger.greet(` ${external_colors_cjs_default().green(`${external_colors_cjs_default().bold('UNPACK')} v1.7.6`)} ${external_colors_cjs_default().dim(`ready in ${external_colors_cjs_default().reset(external_colors_cjs_default().bold(Math.ceil(performance.now() - global.__unpack_start_time)))}ms`)}\n`);
81
+ printAddressUrls(port);
82
+ await server.start();
83
+ external_global_cjs_namespaceObject.restartCleaners.push(async ()=>await server.stop(), ()=>new Promise((resolve)=>compiler.close(()=>resolve())));
84
+ const { open } = unpackConfig.server;
85
+ if (open) {
86
+ const url = (0, external_utils_cjs_namespaceObject.isString)(open) ? open : `http://localhost:${port}`;
87
+ await (0, external_openBrowser_cjs_namespaceObject.openBrowser)(url);
61
88
  }
62
- };
63
- const server = new import_webpack_dev_server.default(devServerOptions, compiler);
64
- import_logger.logger.greet(
65
- ` ${import_colors.default.green(`${import_colors.default.bold("UNPACK")} v${"1.7.4"}`)} ${import_colors.default.dim(
66
- `ready in ${import_colors.default.reset(
67
- import_colors.default.bold(Math.ceil(performance.now() - global.__unpack_start_time))
68
- )}ms`
69
- )}
70
- `
71
- );
72
- printAddressUrls(port);
73
- await server.start();
74
- const { open } = unpackConfig.server;
75
- if (open) {
76
- const url = (0, import_utils.isString)(open) ? open : `http://localhost:${port}`;
77
- await (0, import_openBrowser.openBrowser)(url);
78
- }
79
89
  }
80
90
  function printAddressUrls(port) {
81
- const addressUrls = (0, import_utils.getAddressUrls)({ port });
82
- const colorUrl = (url) => import_colors.default.cyan(url.replace(/:(\d+)\//, (_, port2) => `:${import_colors.default.bold(port2)}/`));
83
- addressUrls.forEach((addr) => {
84
- console.log(` ${import_colors.default.green("➜")} ${import_colors.default.bold(addr.label)}${colorUrl(addr.url)}`);
85
- });
91
+ const addressUrls = (0, external_utils_cjs_namespaceObject.getAddressUrls)({
92
+ port
93
+ });
94
+ const colorUrl = (url)=>external_colors_cjs_default().cyan(url.replace(/:(\d+)\//, (_, port)=>`:${external_colors_cjs_default().bold(port)}/`));
95
+ addressUrls.forEach((addr)=>{
96
+ console.log(` ${external_colors_cjs_default().green('➜')} ${external_colors_cjs_default().bold(addr.label)}${colorUrl(addr.url)}`);
97
+ });
86
98
  }
87
- // Annotate the CommonJS export names for ESM import in node:
88
- 0 && (module.exports = {
89
- bundlerDev
99
+ var __webpack_export_target__ = exports;
100
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
101
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
102
+ value: true
90
103
  });
package/dist/run/dev.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { UnpackConfig } from '../types/index';
1
+ import type { UnpackConfig } from 'src/types/index';
2
2
  export declare function bundlerDev(originalUnpackConfig: UnpackConfig): Promise<void>;
3
3
  //# sourceMappingURL=dev.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/run/dev.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAMnD,wBAAsB,UAAU,CAAC,oBAAoB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAqClF"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/run/dev.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAMnD,wBAAsB,UAAU,CAAC,oBAAoB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAyClF"}