@unpackjs/core 1.7.5 → 1.7.7

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 (116) hide show
  1. package/compiled/css-loader/index.js +180 -178
  2. package/compiled/less-loader/index.js +11 -11
  3. package/compiled/line-diff/index.js +4 -4
  4. package/compiled/line-diff/license +1 -1
  5. package/compiled/line-diff/package.json +1 -1
  6. package/compiled/portfinder/index.js +37 -37
  7. package/compiled/postcss-loader/index.js +261 -256
  8. package/compiled/sass-loader/index.js +24 -20
  9. package/compiled/sass-loader/package.json +1 -1
  10. package/compiled/semver/index.js +188 -170
  11. package/compiled/semver/package.json +1 -1
  12. package/compiled/style-loader/index.js +13 -13
  13. package/compiled/webpack-bundle-analyzer/index.js +198 -198
  14. package/compiled/webpack-merge/index.js +29 -29
  15. package/dist/bundler-config/chunkSplit.cjs +169 -156
  16. package/dist/bundler-config/chunkSplit.js +125 -134
  17. package/dist/bundler-config/css.cjs +181 -158
  18. package/dist/bundler-config/css.js +139 -151
  19. package/dist/bundler-config/experimentCss.cjs +203 -159
  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.map +1 -1
  25. package/dist/bundler-config/index.js +209 -182
  26. package/dist/bundler-config/jsMinify.cjs +114 -95
  27. package/dist/bundler-config/jsMinify.js +70 -73
  28. package/dist/colors.cjs +83 -56
  29. package/dist/colors.js +38 -37
  30. package/dist/config.cjs +107 -93
  31. package/dist/config.d.ts.map +1 -1
  32. package/dist/config.js +64 -70
  33. package/dist/constants.cjs +65 -62
  34. package/dist/constants.d.ts +1 -0
  35. package/dist/constants.d.ts.map +1 -1
  36. package/dist/constants.js +22 -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/loader.cjs +56 -53
  48. package/dist/lightningcss/loader.d.ts.map +1 -1
  49. package/dist/lightningcss/loader.js +25 -34
  50. package/dist/lightningcss/minimizer.cjs +90 -109
  51. package/dist/lightningcss/minimizer.d.ts.map +1 -1
  52. package/dist/lightningcss/minimizer.js +59 -87
  53. package/dist/logger.cjs +104 -98
  54. package/dist/logger.js +59 -76
  55. package/dist/openBrowser.cjs +104 -81
  56. package/dist/openBrowser.js +56 -52
  57. package/dist/plugin-progress/rspack.cjs +104 -79
  58. package/dist/plugin-progress/rspack.js +59 -57
  59. package/dist/plugin-progress/webpack.cjs +111 -89
  60. package/dist/plugin-progress/webpack.js +65 -67
  61. package/dist/plugin.cjs +38 -29
  62. package/dist/plugin.js +8 -17
  63. package/dist/prebundleDeps.cjs +327 -337
  64. package/dist/prebundleDeps.d.ts.map +1 -1
  65. package/dist/prebundleDeps.js +278 -324
  66. package/dist/progressBar.cjs +82 -65
  67. package/dist/progressBar.js +38 -43
  68. package/dist/reporter.cjs +149 -124
  69. package/dist/reporter.d.ts.map +1 -1
  70. package/dist/reporter.js +102 -102
  71. package/dist/run/build.cjs +68 -67
  72. package/dist/run/build.js +24 -45
  73. package/dist/run/dev.cjs +96 -83
  74. package/dist/run/dev.d.ts.map +1 -1
  75. package/dist/run/dev.js +50 -61
  76. package/dist/run/index.cjs +74 -21
  77. package/dist/run/index.js +2 -9
  78. package/dist/typed-css-modules/loader.cjs +179 -188
  79. package/dist/typed-css-modules/loader.js +118 -151
  80. package/dist/typed-css-modules/plugin.cjs +113 -88
  81. package/dist/typed-css-modules/plugin.js +68 -66
  82. package/dist/typed-css-modules/utils.cjs +43 -42
  83. package/dist/typed-css-modules/utils.js +13 -30
  84. package/dist/types/chunkSplit.cjs +19 -15
  85. package/dist/types/chunkSplit.d.ts +2 -10
  86. package/dist/types/chunkSplit.d.ts.map +1 -1
  87. package/dist/types/chunkSplit.js +2 -9
  88. package/dist/types/config.cjs +19 -15
  89. package/dist/types/config.js +2 -9
  90. package/dist/types/index.cjs +101 -27
  91. package/dist/types/index.js +2 -9
  92. package/dist/types/lightningcss.cjs +19 -15
  93. package/dist/types/lightningcss.js +2 -9
  94. package/dist/types/logger.cjs +43 -34
  95. package/dist/types/logger.js +13 -22
  96. package/dist/types/plugin.cjs +19 -15
  97. package/dist/types/plugin.js +2 -9
  98. package/dist/utils.cjs +280 -304
  99. package/dist/utils.js +195 -241
  100. package/dist/watchFiles.cjs +73 -0
  101. package/dist/watchFiles.d.ts +3 -0
  102. package/dist/watchFiles.d.ts.map +1 -0
  103. package/dist/watchFiles.js +27 -0
  104. package/package.json +18 -21
  105. package/compiled/commander/index.d.ts +0 -1047
  106. package/compiled/commander/index.js +0 -2428
  107. package/compiled/commander/license +0 -22
  108. package/compiled/commander/package.json +0 -1
  109. package/dist/bundleRequire.cjs +0 -200
  110. package/dist/bundleRequire.d.ts +0 -5
  111. package/dist/bundleRequire.d.ts.map +0 -1
  112. package/dist/bundleRequire.js +0 -173
  113. package/dist/lightningcss/cache.cjs +0 -36
  114. package/dist/lightningcss/cache.d.ts +0 -2
  115. package/dist/lightningcss/cache.d.ts.map +0 -1
  116. package/dist/lightningcss/cache.js +0 -22
package/dist/reporter.js CHANGED
@@ -1,109 +1,109 @@
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";
15
- const chunkGroups = [
16
- { type: "HTML", color: "green", chunks: [] },
17
- { type: "CSS", color: "magenta", chunks: [] },
18
- { type: "JS", color: "cyan", chunks: [] }
19
- ];
20
- const chunkGroupMap = chunkGroups.reduce(
21
- (acc, cur) => {
22
- acc[cur.type] = cur;
23
- return acc;
24
- },
25
- {}
26
- );
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";
8
+ import * as __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__ from "./utils.js";
27
9
  const chunkSizeLimit = 500;
28
- const gzip = promisify(zlib.gzip);
29
- const numberFormatter = new Intl.NumberFormat("en", {
30
- maximumFractionDigits: 2,
31
- minimumFractionDigits: 2
10
+ const gzip = (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(__WEBPACK_EXTERNAL_MODULE_node_zlib_a5bb16fc__["default"].gzip);
11
+ const numberFormatter = new Intl.NumberFormat('en', {
12
+ maximumFractionDigits: 2,
13
+ minimumFractionDigits: 2
32
14
  });
33
- const displaySize = (bytes) => {
34
- return `${numberFormatter.format(bytes / 1e3)} kB`;
35
- };
15
+ const displaySize = (bytes)=>`${numberFormatter.format(bytes / 1000)} kB`;
36
16
  async function getCompressedSize(content) {
37
- const data = await gzip(content);
38
- return data.length;
17
+ const data = await gzip(content);
18
+ return data.length;
39
19
  }
40
20
  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);
21
+ const chunkGroups = [
22
+ {
23
+ type: 'HTML',
24
+ color: 'green',
25
+ chunks: []
26
+ },
27
+ {
28
+ type: 'CSS',
29
+ color: 'magenta',
30
+ chunks: []
31
+ },
32
+ {
33
+ type: 'JS',
34
+ color: 'cyan',
35
+ chunks: []
36
+ }
37
+ ];
38
+ const chunkGroupMap = chunkGroups.reduce((acc, cur)=>{
39
+ acc[cur.type] = cur;
40
+ return acc;
41
+ }, {});
42
+ let compressedCount = 0;
43
+ (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.logUpdate)('computing gzip size (0)...');
44
+ const distPath = stats.compilation.outputOptions.path;
45
+ const distFolder = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, distPath);
46
+ const origin = stats.toJson({
47
+ all: false,
48
+ assets: true,
49
+ cachedAssets: true,
50
+ groupAssetsByInfo: false,
51
+ groupAssetsByPath: false,
52
+ groupAssetsByChunk: false,
53
+ groupAssetsByExtension: false,
54
+ groupAssetsByEmitStatus: false
104
55
  });
105
- });
56
+ let longest = 0;
57
+ let totalSize = 0;
58
+ let totalCompressedSize = 0;
59
+ await Promise.all(origin.assets.map(async (asset)=>{
60
+ const content = await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].promises.readFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(distPath, asset.name));
61
+ const size = content.length;
62
+ const compressedSize = await getCompressedSize(content);
63
+ totalSize += size;
64
+ totalCompressedSize += compressedSize;
65
+ compressedCount++;
66
+ (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.logUpdate)(`computing gzip size (${compressedCount})...`);
67
+ if (compressedCount === origin.assets.length) console.log();
68
+ const chunk = {
69
+ name: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(asset.name),
70
+ path: `${distFolder}/${asset.name}`,
71
+ size,
72
+ compressedSize
73
+ };
74
+ if (chunk.path.length > longest) longest = chunk.path.length;
75
+ const ext = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(asset.name);
76
+ switch(ext){
77
+ case '.html':
78
+ chunkGroupMap.HTML.chunks.push(chunk);
79
+ break;
80
+ case '.css':
81
+ chunkGroupMap.CSS.chunks.push(chunk);
82
+ break;
83
+ case '.js':
84
+ chunkGroupMap.JS.chunks.push(chunk);
85
+ break;
86
+ default:
87
+ break;
88
+ }
89
+ }));
90
+ const sizePad = displaySize(totalSize).length;
91
+ const compressPad = displaySize(totalCompressedSize).length;
92
+ chunkGroups.forEach((group)=>{
93
+ group.chunks.sort((a, b)=>a.size - b.size).forEach((chunk)=>{
94
+ const isLarge = 'JS' === group.type && chunk.size / 1000 > chunkSizeLimit;
95
+ const sizeColor = isLarge ? 'yellow' : 'dim';
96
+ const relativeOutDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(chunk.path) + '/';
97
+ let log = __WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"].dim(relativeOutDir);
98
+ log += __WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"][group.color](chunk.name.padEnd(longest + 2 - relativeOutDir.length));
99
+ log += __WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"][sizeColor](__WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"].bold(displaySize(chunk.size).padStart(sizePad)));
100
+ if (chunk.compressedSize) log += __WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"].dim(` │ gzip: ${displaySize(chunk.compressedSize).padStart(compressPad)}`);
101
+ console.log(log);
102
+ });
103
+ });
104
+ let log = __WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"].blue(__WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"].bold('Total'.padEnd(longest + 2)));
105
+ log += __WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"].blue(__WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"].bold(displaySize(totalSize)));
106
+ log += __WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"].dim(` │ gzip: ${displaySize(totalCompressedSize)}`);
107
+ console.log(log);
106
108
  }
107
- export {
108
- printFileSize
109
- };
109
+ 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
  });
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.7`)} ${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.5"}`)} ${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
  });
@@ -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"}