@unpackjs/core 2.4.0 → 2.4.2

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 (195) hide show
  1. package/dist/index.cjs +2028 -196
  2. package/dist/index.js +1876 -39
  3. package/dist/lightningcssLoader.mjs +18 -0
  4. package/dist/typedCssModulesLoader.mjs +139 -0
  5. package/{dist → dist-types}/bundler-config/cache.d.ts +1 -1
  6. package/dist-types/bundler-config/cache.d.ts.map +1 -0
  7. package/{dist → dist-types}/bundler-config/chunkSplit.d.ts +1 -1
  8. package/dist-types/bundler-config/chunkSplit.d.ts.map +1 -0
  9. package/{dist → dist-types}/bundler-config/css.d.ts +1 -1
  10. package/dist-types/bundler-config/css.d.ts.map +1 -0
  11. package/{dist → dist-types}/bundler-config/experimentCss.d.ts +1 -1
  12. package/dist-types/bundler-config/experimentCss.d.ts.map +1 -0
  13. package/{dist → dist-types}/bundler-config/index.d.ts +1 -1
  14. package/dist-types/bundler-config/index.d.ts.map +1 -0
  15. package/{dist/lightningcss/loader.d.ts → dist-types/bundler-config/loaders/lightningcssLoader.d.ts} +2 -2
  16. package/dist-types/bundler-config/loaders/lightningcssLoader.d.ts.map +1 -0
  17. package/dist-types/bundler-config/loaders/typedCssModulesLoader.d.ts +6 -0
  18. package/dist-types/bundler-config/loaders/typedCssModulesLoader.d.ts.map +1 -0
  19. package/{dist/bundler-config → dist-types/bundler-config/plugins}/jsMinify.d.ts +1 -1
  20. package/dist-types/bundler-config/plugins/jsMinify.d.ts.map +1 -0
  21. package/{dist/lightningcss/minimizer.d.ts → dist-types/bundler-config/plugins/lightningcssMinify.d.ts} +2 -3
  22. package/dist-types/bundler-config/plugins/lightningcssMinify.d.ts.map +1 -0
  23. package/{dist/bundler-config/oxlint/plugin.d.ts → dist-types/bundler-config/plugins/oxlint/index.d.ts} +1 -1
  24. package/dist-types/bundler-config/plugins/oxlint/index.d.ts.map +1 -0
  25. package/dist-types/bundler-config/plugins/progress/helpers.d.ts.map +1 -0
  26. package/{dist/bundler-config → dist-types/bundler-config/plugins}/progress/rspack.d.ts +1 -1
  27. package/dist-types/bundler-config/plugins/progress/rspack.d.ts.map +1 -0
  28. package/{dist/bundler-config → dist-types/bundler-config/plugins}/progress/webpack.d.ts +1 -1
  29. package/dist-types/bundler-config/plugins/progress/webpack.d.ts.map +1 -0
  30. package/{dist/typed-css-modules/plugin.d.ts → dist-types/bundler-config/plugins/typedCssModules.d.ts} +2 -2
  31. package/dist-types/bundler-config/plugins/typedCssModules.d.ts.map +1 -0
  32. package/{dist → dist-types}/config.d.ts +1 -1
  33. package/dist-types/config.d.ts.map +1 -0
  34. package/{dist → dist-types}/createUnpack.d.ts +1 -1
  35. package/{dist → dist-types}/createUnpack.d.ts.map +1 -1
  36. package/{dist → dist-types}/index.d.ts +1 -1
  37. package/{dist → dist-types}/index.d.ts.map +1 -1
  38. package/dist-types/logger.d.ts +3 -0
  39. package/{dist → dist-types}/logger.d.ts.map +1 -1
  40. package/{dist → dist-types}/plugin.d.ts +1 -1
  41. package/{dist → dist-types}/plugin.d.ts.map +1 -1
  42. package/dist-types/run/build.d.ts +3 -0
  43. package/{dist → dist-types}/run/build.d.ts.map +1 -1
  44. package/{dist → dist-types}/run/dev.d.ts +1 -1
  45. package/{dist → dist-types}/run/dev.d.ts.map +1 -1
  46. package/{dist → dist-types}/types/config.d.ts +1 -1
  47. package/{dist → dist-types}/types/config.d.ts.map +1 -1
  48. package/{dist → dist-types}/types/index.d.ts +1 -0
  49. package/{dist → dist-types}/types/index.d.ts.map +1 -1
  50. package/{dist → dist-types}/utils.d.ts +5 -1
  51. package/dist-types/utils.d.ts.map +1 -0
  52. package/package.json +6 -37
  53. package/dist/bundler-config/cache.cjs +0 -114
  54. package/dist/bundler-config/cache.d.ts.map +0 -1
  55. package/dist/bundler-config/cache.js +0 -72
  56. package/dist/bundler-config/chunkSplit.cjs +0 -192
  57. package/dist/bundler-config/chunkSplit.d.ts.map +0 -1
  58. package/dist/bundler-config/chunkSplit.js +0 -150
  59. package/dist/bundler-config/css.cjs +0 -189
  60. package/dist/bundler-config/css.d.ts.map +0 -1
  61. package/dist/bundler-config/css.js +0 -149
  62. package/dist/bundler-config/experimentCss.cjs +0 -214
  63. package/dist/bundler-config/experimentCss.d.ts.map +0 -1
  64. package/dist/bundler-config/experimentCss.js +0 -175
  65. package/dist/bundler-config/helpers.cjs +0 -77
  66. package/dist/bundler-config/helpers.js +0 -31
  67. package/dist/bundler-config/index.cjs +0 -309
  68. package/dist/bundler-config/index.d.ts.map +0 -1
  69. package/dist/bundler-config/index.js +0 -262
  70. package/dist/bundler-config/jsMinify.cjs +0 -113
  71. package/dist/bundler-config/jsMinify.d.ts.map +0 -1
  72. package/dist/bundler-config/jsMinify.js +0 -71
  73. package/dist/bundler-config/oxlint/plugin.cjs +0 -143
  74. package/dist/bundler-config/oxlint/plugin.d.ts.map +0 -1
  75. package/dist/bundler-config/oxlint/plugin.js +0 -104
  76. package/dist/bundler-config/progress/helpers.cjs +0 -126
  77. package/dist/bundler-config/progress/helpers.d.ts.map +0 -1
  78. package/dist/bundler-config/progress/helpers.js +0 -81
  79. package/dist/bundler-config/progress/rspack.cjs +0 -70
  80. package/dist/bundler-config/progress/rspack.d.ts.map +0 -1
  81. package/dist/bundler-config/progress/rspack.js +0 -38
  82. package/dist/bundler-config/progress/webpack.cjs +0 -87
  83. package/dist/bundler-config/progress/webpack.d.ts.map +0 -1
  84. package/dist/bundler-config/progress/webpack.js +0 -45
  85. package/dist/colors.cjs +0 -82
  86. package/dist/colors.js +0 -40
  87. package/dist/config.cjs +0 -148
  88. package/dist/config.d.ts.map +0 -1
  89. package/dist/config.js +0 -101
  90. package/dist/constants.cjs +0 -122
  91. package/dist/constants.js +0 -51
  92. package/dist/createUnpack.cjs +0 -107
  93. package/dist/createUnpack.js +0 -75
  94. package/dist/fs.cjs +0 -91
  95. package/dist/fs.js +0 -34
  96. package/dist/global.cjs +0 -36
  97. package/dist/global.js +0 -4
  98. package/dist/lightningcss/loader.cjs +0 -57
  99. package/dist/lightningcss/loader.d.ts.map +0 -1
  100. package/dist/lightningcss/loader.js +0 -25
  101. package/dist/lightningcss/minimizer.cjs +0 -94
  102. package/dist/lightningcss/minimizer.d.ts.map +0 -1
  103. package/dist/lightningcss/minimizer.js +0 -59
  104. package/dist/loadEnv.cjs +0 -122
  105. package/dist/loadEnv.js +0 -80
  106. package/dist/loadingAnimation.cjs +0 -76
  107. package/dist/loadingAnimation.js +0 -44
  108. package/dist/logger.cjs +0 -116
  109. package/dist/logger.d.ts +0 -3
  110. package/dist/logger.js +0 -74
  111. package/dist/openBrowser.cjs +0 -89
  112. package/dist/openBrowser.js +0 -49
  113. package/dist/plugin.cjs +0 -42
  114. package/dist/plugin.js +0 -10
  115. package/dist/prebundleDeps.cjs +0 -349
  116. package/dist/prebundleDeps.js +0 -303
  117. package/dist/progressBar.cjs +0 -66
  118. package/dist/progressBar.js +0 -34
  119. package/dist/reporter.cjs +0 -164
  120. package/dist/reporter.js +0 -120
  121. package/dist/run/build.cjs +0 -68
  122. package/dist/run/build.d.ts +0 -3
  123. package/dist/run/build.js +0 -26
  124. package/dist/run/dev.cjs +0 -118
  125. package/dist/run/dev.js +0 -75
  126. package/dist/run/index.cjs +0 -69
  127. package/dist/run/index.js +0 -4
  128. package/dist/typed-css-modules/loader.cjs +0 -141
  129. package/dist/typed-css-modules/loader.d.ts +0 -8
  130. package/dist/typed-css-modules/loader.d.ts.map +0 -1
  131. package/dist/typed-css-modules/loader.js +0 -92
  132. package/dist/typed-css-modules/plugin.cjs +0 -117
  133. package/dist/typed-css-modules/plugin.d.ts.map +0 -1
  134. package/dist/typed-css-modules/plugin.js +0 -74
  135. package/dist/typed-css-modules/utils.cjs +0 -46
  136. package/dist/typed-css-modules/utils.d.ts +0 -6
  137. package/dist/typed-css-modules/utils.d.ts.map +0 -1
  138. package/dist/typed-css-modules/utils.js +0 -14
  139. package/dist/types/chunkSplit.cjs +0 -18
  140. package/dist/types/chunkSplit.js +0 -2
  141. package/dist/types/config.cjs +0 -18
  142. package/dist/types/config.js +0 -2
  143. package/dist/types/index.cjs +0 -96
  144. package/dist/types/index.js +0 -7
  145. package/dist/types/lightningcss.cjs +0 -18
  146. package/dist/types/lightningcss.js +0 -2
  147. package/dist/types/logger.cjs +0 -45
  148. package/dist/types/logger.js +0 -13
  149. package/dist/types/oxc.cjs +0 -18
  150. package/dist/types/oxc.js +0 -2
  151. package/dist/types/plugin.cjs +0 -18
  152. package/dist/types/plugin.js +0 -2
  153. package/dist/utils.cjs +0 -346
  154. package/dist/utils.d.ts.map +0 -1
  155. package/dist/utils.js +0 -204
  156. package/dist/watchFiles.cjs +0 -69
  157. package/dist/watchFiles.js +0 -27
  158. /package/dist/{bundler-config/oxlint/.oxlintrc.json → .oxlintrc.json} +0 -0
  159. /package/{dist → dist-types}/bundler-config/helpers.d.ts +0 -0
  160. /package/{dist → dist-types}/bundler-config/helpers.d.ts.map +0 -0
  161. /package/{dist/bundler-config → dist-types/bundler-config/plugins}/progress/helpers.d.ts +0 -0
  162. /package/{dist → dist-types}/colors.d.ts +0 -0
  163. /package/{dist → dist-types}/colors.d.ts.map +0 -0
  164. /package/{dist → dist-types}/constants.d.ts +0 -0
  165. /package/{dist → dist-types}/constants.d.ts.map +0 -0
  166. /package/{dist → dist-types}/fs.d.ts +0 -0
  167. /package/{dist → dist-types}/fs.d.ts.map +0 -0
  168. /package/{dist → dist-types}/global.d.ts +0 -0
  169. /package/{dist → dist-types}/global.d.ts.map +0 -0
  170. /package/{dist → dist-types}/loadEnv.d.ts +0 -0
  171. /package/{dist → dist-types}/loadEnv.d.ts.map +0 -0
  172. /package/{dist → dist-types}/loadingAnimation.d.ts +0 -0
  173. /package/{dist → dist-types}/loadingAnimation.d.ts.map +0 -0
  174. /package/{dist → dist-types}/openBrowser.d.ts +0 -0
  175. /package/{dist → dist-types}/openBrowser.d.ts.map +0 -0
  176. /package/{dist → dist-types}/prebundleDeps.d.ts +0 -0
  177. /package/{dist → dist-types}/prebundleDeps.d.ts.map +0 -0
  178. /package/{dist → dist-types}/progressBar.d.ts +0 -0
  179. /package/{dist → dist-types}/progressBar.d.ts.map +0 -0
  180. /package/{dist → dist-types}/reporter.d.ts +0 -0
  181. /package/{dist → dist-types}/reporter.d.ts.map +0 -0
  182. /package/{dist → dist-types}/run/index.d.ts +0 -0
  183. /package/{dist → dist-types}/run/index.d.ts.map +0 -0
  184. /package/{dist → dist-types}/types/chunkSplit.d.ts +0 -0
  185. /package/{dist → dist-types}/types/chunkSplit.d.ts.map +0 -0
  186. /package/{dist → dist-types}/types/lightningcss.d.ts +0 -0
  187. /package/{dist → dist-types}/types/lightningcss.d.ts.map +0 -0
  188. /package/{dist → dist-types}/types/logger.d.ts +0 -0
  189. /package/{dist → dist-types}/types/logger.d.ts.map +0 -0
  190. /package/{dist → dist-types}/types/oxc.d.ts +0 -0
  191. /package/{dist → dist-types}/types/oxc.d.ts.map +0 -0
  192. /package/{dist → dist-types}/types/plugin.d.ts +0 -0
  193. /package/{dist → dist-types}/types/plugin.d.ts.map +0 -0
  194. /package/{dist → dist-types}/watchFiles.d.ts +0 -0
  195. /package/{dist → dist-types}/watchFiles.d.ts.map +0 -0
@@ -1,66 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- ProgressBar: ()=>ProgressBar
28
- });
29
- const external_colors_cjs_namespaceObject = require("./colors.cjs");
30
- const external_loadingAnimation_cjs_namespaceObject = require("./loadingAnimation.cjs");
31
- const external_utils_cjs_namespaceObject = require("./utils.cjs");
32
- function _define_property(obj, key, value) {
33
- if (key in obj) Object.defineProperty(obj, key, {
34
- value: value,
35
- enumerable: true,
36
- configurable: true,
37
- writable: true
38
- });
39
- else obj[key] = value;
40
- return obj;
41
- }
42
- class ProgressBar {
43
- update({ current: originalCurrent, message = '' }) {
44
- if ((0, external_utils_cjs_namespaceObject.isCI)()) return;
45
- const { columns: terminalWidth } = process.stdout;
46
- let current = originalCurrent;
47
- if (originalCurrent >= 0.98) current = 1;
48
- const loadingChar = this.loadingAnimation.getCurrentChar();
49
- const messageWidth = terminalWidth - this.prefix.length - (1 === current ? 10 : 9);
50
- (0, external_utils_cjs_namespaceObject.logUpdate)(`${loadingChar} ${this.prefix} (${Math.floor(100 * current)}%) ${external_colors_cjs_namespaceObject.colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`);
51
- }
52
- done() {
53
- console.log();
54
- }
55
- constructor(){
56
- _define_property(this, "prefix", 'transforming');
57
- _define_property(this, "loadingAnimation", new external_loadingAnimation_cjs_namespaceObject.LoadingAnimation());
58
- }
59
- }
60
- exports.ProgressBar = __webpack_exports__.ProgressBar;
61
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
62
- "ProgressBar"
63
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
64
- Object.defineProperty(exports, '__esModule', {
65
- value: true
66
- });
@@ -1,34 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import { colors } from "./colors.js";
4
- import { LoadingAnimation } from "./loadingAnimation.js";
5
- import { isCI, logUpdate } from "./utils.js";
6
- function _define_property(obj, key, value) {
7
- if (key in obj) Object.defineProperty(obj, key, {
8
- value: value,
9
- enumerable: true,
10
- configurable: true,
11
- writable: true
12
- });
13
- else obj[key] = value;
14
- return obj;
15
- }
16
- class ProgressBar {
17
- update({ current: originalCurrent, message = '' }) {
18
- if (isCI()) return;
19
- const { columns: terminalWidth } = process.stdout;
20
- let current = originalCurrent;
21
- if (originalCurrent >= 0.98) current = 1;
22
- const loadingChar = this.loadingAnimation.getCurrentChar();
23
- const messageWidth = terminalWidth - this.prefix.length - (1 === current ? 10 : 9);
24
- logUpdate(`${loadingChar} ${this.prefix} (${Math.floor(100 * current)}%) ${colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`);
25
- }
26
- done() {
27
- console.log();
28
- }
29
- constructor(){
30
- _define_property(this, "prefix", 'transforming');
31
- _define_property(this, "loadingAnimation", new LoadingAnimation());
32
- }
33
- }
34
- export { ProgressBar };
package/dist/reporter.cjs DELETED
@@ -1,164 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- printFileSize: ()=>printFileSize
37
- });
38
- const external_node_fs_namespaceObject = require("node:fs");
39
- var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
40
- const external_node_path_namespaceObject = require("node:path");
41
- var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
42
- const external_node_util_namespaceObject = require("node:util");
43
- const external_node_zlib_namespaceObject = require("node:zlib");
44
- var external_node_zlib_default = /*#__PURE__*/ __webpack_require__.n(external_node_zlib_namespaceObject);
45
- const external_colors_cjs_namespaceObject = require("./colors.cjs");
46
- const external_loadingAnimation_cjs_namespaceObject = require("./loadingAnimation.cjs");
47
- const external_utils_cjs_namespaceObject = require("./utils.cjs");
48
- const chunkSizeLimit = 500;
49
- const gzip = (0, external_node_util_namespaceObject.promisify)(external_node_zlib_default().gzip);
50
- const numberFormatter = new Intl.NumberFormat('en', {
51
- maximumFractionDigits: 2,
52
- minimumFractionDigits: 2
53
- });
54
- const displaySize = (bytes)=>`${numberFormatter.format(bytes / 1000)} kB`;
55
- async function getCompressedSize(content) {
56
- const data = await gzip(content);
57
- return data.length;
58
- }
59
- async function printFileSize({ root, stats }) {
60
- const chunkGroups = [
61
- {
62
- type: 'HTML',
63
- color: 'green',
64
- chunks: []
65
- },
66
- {
67
- type: 'Assets',
68
- color: 'yellow',
69
- chunks: []
70
- },
71
- {
72
- type: 'CSS',
73
- color: 'magenta',
74
- chunks: []
75
- },
76
- {
77
- type: 'JS',
78
- color: 'cyan',
79
- chunks: []
80
- }
81
- ];
82
- const chunkGroupMap = chunkGroups.reduce((acc, cur)=>{
83
- acc[cur.type] = cur;
84
- return acc;
85
- }, {});
86
- let compressedCount = 0;
87
- const loadingAnimation = new external_loadingAnimation_cjs_namespaceObject.LoadingAnimation();
88
- (0, external_utils_cjs_namespaceObject.logUpdate)(`${loadingAnimation.getCurrentChar()} computing gzip size (0)...`);
89
- const distPath = stats.compilation.outputOptions.path;
90
- const distFolder = external_node_path_default().relative(root, distPath);
91
- const origin = stats.toJson({
92
- all: false,
93
- assets: true,
94
- cachedAssets: true,
95
- groupAssetsByInfo: false,
96
- groupAssetsByPath: false,
97
- groupAssetsByChunk: false,
98
- groupAssetsByExtension: false,
99
- groupAssetsByEmitStatus: false
100
- });
101
- let longest = 0;
102
- let totalSize = 0;
103
- let totalCompressedSize = 0;
104
- await Promise.all(origin.assets.map(async (asset)=>{
105
- const content = await external_node_fs_default().promises.readFile(external_node_path_default().join(distPath, asset.name));
106
- const size = content.length;
107
- const compressedSize = await getCompressedSize(content);
108
- totalSize += size;
109
- totalCompressedSize += compressedSize;
110
- compressedCount++;
111
- (0, external_utils_cjs_namespaceObject.logUpdate)(`${loadingAnimation.getCurrentChar()} computing gzip size (${compressedCount})...`);
112
- if (compressedCount === origin.assets.length) {
113
- (0, external_utils_cjs_namespaceObject.logUpdate)(`\u{2713} computed gzip size (${compressedCount})`);
114
- console.log();
115
- }
116
- const chunk = {
117
- name: external_node_path_default().basename(asset.name),
118
- path: `${distFolder}/${asset.name}`,
119
- size,
120
- compressedSize
121
- };
122
- if (chunk.path.length > longest) longest = chunk.path.length;
123
- const ext = external_node_path_default().extname(asset.name);
124
- switch(ext){
125
- case '.html':
126
- chunkGroupMap.HTML.chunks.push(chunk);
127
- break;
128
- case '.css':
129
- chunkGroupMap.CSS.chunks.push(chunk);
130
- break;
131
- case '.js':
132
- chunkGroupMap.JS.chunks.push(chunk);
133
- break;
134
- default:
135
- chunkGroupMap.Assets.chunks.push(chunk);
136
- break;
137
- }
138
- }));
139
- const sizePad = displaySize(totalSize).length;
140
- const compressPad = displaySize(totalCompressedSize).length;
141
- chunkGroups.forEach((group)=>{
142
- group.chunks.sort((a, b)=>a.size - b.size).forEach((chunk)=>{
143
- const isLarge = 'JS' === group.type && chunk.size / 1000 > chunkSizeLimit;
144
- const sizeColor = isLarge ? 'yellow' : 'dim';
145
- const relativeOutDir = external_node_path_default().dirname(chunk.path) + '/';
146
- let log = external_colors_cjs_namespaceObject.colors.dim(relativeOutDir);
147
- log += external_colors_cjs_namespaceObject.colors[group.color](chunk.name.padEnd(longest + 2 - relativeOutDir.length));
148
- log += external_colors_cjs_namespaceObject.colors[sizeColor](displaySize(chunk.size).padStart(sizePad));
149
- if (chunk.compressedSize) log += external_colors_cjs_namespaceObject.colors.dim(` \u{2502} gzip: ${displaySize(chunk.compressedSize).padStart(compressPad)}`);
150
- console.log(log);
151
- });
152
- });
153
- let log = external_colors_cjs_namespaceObject.colors.blue('Total'.padEnd(longest + 2));
154
- log += external_colors_cjs_namespaceObject.colors.blue(displaySize(totalSize));
155
- log += external_colors_cjs_namespaceObject.colors.dim(` \u{2502} gzip: ${displaySize(totalCompressedSize)}`);
156
- console.log(log);
157
- }
158
- exports.printFileSize = __webpack_exports__.printFileSize;
159
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
160
- "printFileSize"
161
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
162
- Object.defineProperty(exports, '__esModule', {
163
- value: true
164
- });
package/dist/reporter.js DELETED
@@ -1,120 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import node_fs from "node:fs";
4
- import node_path from "node:path";
5
- import { promisify } from "node:util";
6
- import node_zlib from "node:zlib";
7
- import { colors } from "./colors.js";
8
- import { LoadingAnimation } from "./loadingAnimation.js";
9
- import { logUpdate } from "./utils.js";
10
- const chunkSizeLimit = 500;
11
- const gzip = promisify(node_zlib.gzip);
12
- const numberFormatter = new Intl.NumberFormat('en', {
13
- maximumFractionDigits: 2,
14
- minimumFractionDigits: 2
15
- });
16
- const displaySize = (bytes)=>`${numberFormatter.format(bytes / 1000)} kB`;
17
- async function getCompressedSize(content) {
18
- const data = await gzip(content);
19
- return data.length;
20
- }
21
- async function printFileSize({ root, stats }) {
22
- const chunkGroups = [
23
- {
24
- type: 'HTML',
25
- color: 'green',
26
- chunks: []
27
- },
28
- {
29
- type: 'Assets',
30
- color: 'yellow',
31
- chunks: []
32
- },
33
- {
34
- type: 'CSS',
35
- color: 'magenta',
36
- chunks: []
37
- },
38
- {
39
- type: 'JS',
40
- color: 'cyan',
41
- chunks: []
42
- }
43
- ];
44
- const chunkGroupMap = chunkGroups.reduce((acc, cur)=>{
45
- acc[cur.type] = cur;
46
- return acc;
47
- }, {});
48
- let compressedCount = 0;
49
- const loadingAnimation = new LoadingAnimation();
50
- logUpdate(`${loadingAnimation.getCurrentChar()} computing gzip size (0)...`);
51
- const distPath = stats.compilation.outputOptions.path;
52
- const distFolder = node_path.relative(root, distPath);
53
- const origin = stats.toJson({
54
- all: false,
55
- assets: true,
56
- cachedAssets: true,
57
- groupAssetsByInfo: false,
58
- groupAssetsByPath: false,
59
- groupAssetsByChunk: false,
60
- groupAssetsByExtension: false,
61
- groupAssetsByEmitStatus: false
62
- });
63
- let longest = 0;
64
- let totalSize = 0;
65
- let totalCompressedSize = 0;
66
- await Promise.all(origin.assets.map(async (asset)=>{
67
- const content = await node_fs.promises.readFile(node_path.join(distPath, asset.name));
68
- const size = content.length;
69
- const compressedSize = await getCompressedSize(content);
70
- totalSize += size;
71
- totalCompressedSize += compressedSize;
72
- compressedCount++;
73
- logUpdate(`${loadingAnimation.getCurrentChar()} computing gzip size (${compressedCount})...`);
74
- if (compressedCount === origin.assets.length) {
75
- logUpdate(`\u{2713} computed gzip size (${compressedCount})`);
76
- console.log();
77
- }
78
- const chunk = {
79
- name: node_path.basename(asset.name),
80
- path: `${distFolder}/${asset.name}`,
81
- size,
82
- compressedSize
83
- };
84
- if (chunk.path.length > longest) longest = chunk.path.length;
85
- const ext = node_path.extname(asset.name);
86
- switch(ext){
87
- case '.html':
88
- chunkGroupMap.HTML.chunks.push(chunk);
89
- break;
90
- case '.css':
91
- chunkGroupMap.CSS.chunks.push(chunk);
92
- break;
93
- case '.js':
94
- chunkGroupMap.JS.chunks.push(chunk);
95
- break;
96
- default:
97
- chunkGroupMap.Assets.chunks.push(chunk);
98
- break;
99
- }
100
- }));
101
- const sizePad = displaySize(totalSize).length;
102
- const compressPad = displaySize(totalCompressedSize).length;
103
- chunkGroups.forEach((group)=>{
104
- group.chunks.sort((a, b)=>a.size - b.size).forEach((chunk)=>{
105
- const isLarge = 'JS' === group.type && chunk.size / 1000 > chunkSizeLimit;
106
- const sizeColor = isLarge ? 'yellow' : 'dim';
107
- const relativeOutDir = node_path.dirname(chunk.path) + '/';
108
- let log = colors.dim(relativeOutDir);
109
- log += colors[group.color](chunk.name.padEnd(longest + 2 - relativeOutDir.length));
110
- log += colors[sizeColor](displaySize(chunk.size).padStart(sizePad));
111
- if (chunk.compressedSize) log += colors.dim(` \u{2502} gzip: ${displaySize(chunk.compressedSize).padStart(compressPad)}`);
112
- console.log(log);
113
- });
114
- });
115
- let log = colors.blue('Total'.padEnd(longest + 2));
116
- log += colors.blue(displaySize(totalSize));
117
- log += colors.dim(` \u{2502} gzip: ${displaySize(totalCompressedSize)}`);
118
- console.log(log);
119
- }
120
- export { printFileSize };
@@ -1,68 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- unpackBuild: ()=>unpackBuild
37
- });
38
- const core_namespaceObject = require("@rspack/core");
39
- const external_utils_cjs_namespaceObject = require("../utils.cjs");
40
- const external_webpack_namespaceObject = require("webpack");
41
- var external_webpack_default = /*#__PURE__*/ __webpack_require__.n(external_webpack_namespaceObject);
42
- const index_cjs_namespaceObject = require("../bundler-config/index.cjs");
43
- async function unpackBuild(unpackConfig) {
44
- const bundler = 'rspack' === unpackConfig.bundler ? core_namespaceObject.rspack : external_webpack_default();
45
- const config = await (0, index_cjs_namespaceObject.getBundlerConfig)(unpackConfig);
46
- const compiler = bundler(config);
47
- const handler = (err, stats)=>{
48
- if (err) {
49
- console.error(err.stack || err);
50
- if (err.details) console.error(err.details);
51
- return;
52
- }
53
- if (null == stats ? void 0 : stats.hasErrors()) console.log(stats.toString({
54
- colors: true,
55
- preset: 'errors-only'
56
- }));
57
- if (!(0, external_utils_cjs_namespaceObject.isWatch)()) compiler.close(()=>{});
58
- };
59
- if ((0, external_utils_cjs_namespaceObject.isWatch)()) compiler.watch({}, handler);
60
- else compiler.run(handler);
61
- }
62
- exports.unpackBuild = __webpack_exports__.unpackBuild;
63
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
64
- "unpackBuild"
65
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
66
- Object.defineProperty(exports, '__esModule', {
67
- value: true
68
- });
@@ -1,3 +0,0 @@
1
- import type { UnpackConfig } from '../types/index';
2
- export declare function unpackBuild(unpackConfig: UnpackConfig): Promise<void>;
3
- //# sourceMappingURL=build.d.ts.map
package/dist/run/build.js DELETED
@@ -1,26 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import { rspack } from "@rspack/core";
4
- import { isWatch } from "../utils.js";
5
- import webpack from "webpack";
6
- import { getBundlerConfig } from "../bundler-config/index.js";
7
- async function unpackBuild(unpackConfig) {
8
- const bundler = 'rspack' === unpackConfig.bundler ? rspack : webpack;
9
- const config = await 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 (!isWatch()) compiler.close(()=>{});
22
- };
23
- if (isWatch()) compiler.watch({}, handler);
24
- else compiler.run(handler);
25
- }
26
- export { unpackBuild };
package/dist/run/dev.cjs DELETED
@@ -1,118 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- unpackDev: ()=>unpackDev
37
- });
38
- const core_namespaceObject = require("@rspack/core");
39
- const external_colors_cjs_namespaceObject = require("../colors.cjs");
40
- const external_global_cjs_namespaceObject = require("../global.cjs");
41
- const external_logger_cjs_namespaceObject = require("../logger.cjs");
42
- const external_openBrowser_cjs_namespaceObject = require("../openBrowser.cjs");
43
- const external_prebundleDeps_cjs_namespaceObject = require("../prebundleDeps.cjs");
44
- const external_utils_cjs_namespaceObject = require("../utils.cjs");
45
- const external_webpack_namespaceObject = require("webpack");
46
- var external_webpack_default = /*#__PURE__*/ __webpack_require__.n(external_webpack_namespaceObject);
47
- const external_webpack_dev_server_namespaceObject = require("webpack-dev-server");
48
- var external_webpack_dev_server_default = /*#__PURE__*/ __webpack_require__.n(external_webpack_dev_server_namespaceObject);
49
- const index_cjs_namespaceObject = require("../bundler-config/index.cjs");
50
- async function unpackDev(originalUnpackConfig) {
51
- var _unpackConfig_dev, _unpackConfig_server, _unpackConfig_server1, _unpackConfig_dev1, _unpackConfig_server2;
52
- let unpackConfig = originalUnpackConfig;
53
- const isRspack = 'rspack' === unpackConfig.bundler;
54
- const bundler = isRspack ? core_namespaceObject.rspack : external_webpack_default();
55
- if (null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.prebundle) unpackConfig = await (0, external_prebundleDeps_cjs_namespaceObject.prebundleDeps)({
56
- unpackConfig
57
- });
58
- const config = await (0, index_cjs_namespaceObject.getBundlerConfig)(unpackConfig);
59
- const compiler = bundler(config);
60
- const port = await (0, external_utils_cjs_namespaceObject.getPort)(null == (_unpackConfig_server = unpackConfig.server) ? void 0 : _unpackConfig_server.port);
61
- let proxyConfig = null == (_unpackConfig_server1 = unpackConfig.server) ? void 0 : _unpackConfig_server1.proxy;
62
- if ((0, external_utils_cjs_namespaceObject.isPlainObject)(proxyConfig)) proxyConfig = Object.entries(proxyConfig).map(([contextStr, target])=>({
63
- context: contextStr.split(','),
64
- target,
65
- changeOrigin: true
66
- }));
67
- const devServerOptions = {
68
- hot: true,
69
- port,
70
- open: false,
71
- client: {
72
- overlay: false
73
- },
74
- proxy: proxyConfig,
75
- devMiddleware: {
76
- writeToDisk: null == (_unpackConfig_dev1 = unpackConfig.dev) ? void 0 : _unpackConfig_dev1.writeToDisk
77
- }
78
- };
79
- devServerOptions.setupMiddlewares = (middlewares)=>{
80
- middlewares.unshift((req, _, next)=>{
81
- var _req_headers_accept;
82
- if (null == (_req_headers_accept = req.headers.accept) ? void 0 : _req_headers_accept.includes('html')) req.url = '/index.html';
83
- next();
84
- });
85
- if (isRspack) middlewares.unshift(core_namespaceObject.experiments.lazyCompilationMiddleware(compiler));
86
- return middlewares;
87
- };
88
- const server = new (external_webpack_dev_server_default())(devServerOptions, compiler);
89
- await server.start();
90
- external_logger_cjs_namespaceObject.logger.greet(` ${external_colors_cjs_namespaceObject.colors.green(`${external_colors_cjs_namespaceObject.colors.bold(unpackConfig._context.callerName.toUpperCase())} v2.4.0`)} ${external_colors_cjs_namespaceObject.colors.dim(`ready in ${external_colors_cjs_namespaceObject.colors.reset(Math.ceil(performance.now() - global.__unpack_start_time))}ms`)}\n`);
91
- printAddressUrls(port);
92
- external_logger_cjs_namespaceObject.logger.wait('building...');
93
- global.__unpack_dev_server_started = true;
94
- external_global_cjs_namespaceObject.restartCleaners.push(async ()=>await server.stop(), ()=>new Promise((resolve)=>compiler.close(()=>resolve())), ()=>{
95
- global.__unpack_dev_server_started = false;
96
- });
97
- const open = null == (_unpackConfig_server2 = unpackConfig.server) ? void 0 : _unpackConfig_server2.open;
98
- if (open) {
99
- const url = (0, external_utils_cjs_namespaceObject.isString)(open) ? open : `http://localhost:${port}`;
100
- await (0, external_openBrowser_cjs_namespaceObject.openBrowser)(url);
101
- }
102
- }
103
- function printAddressUrls(port) {
104
- const addressUrls = (0, external_utils_cjs_namespaceObject.getAddressUrls)({
105
- port
106
- });
107
- const colorUrl = (url)=>external_colors_cjs_namespaceObject.colors.cyan(url.replace(/:(\d+)\//, (_, port)=>`:${external_colors_cjs_namespaceObject.colors.bold(port)}/`));
108
- addressUrls.forEach((addr)=>{
109
- console.log(` ${external_colors_cjs_namespaceObject.colors.green(external_colors_cjs_namespaceObject.colors.dim("\u279C"))} ${external_colors_cjs_namespaceObject.colors.dim(addr.label)}${colorUrl(addr.url)}`);
110
- });
111
- }
112
- exports.unpackDev = __webpack_exports__.unpackDev;
113
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
114
- "unpackDev"
115
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
116
- Object.defineProperty(exports, '__esModule', {
117
- value: true
118
- });
package/dist/run/dev.js DELETED
@@ -1,75 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import { experiments, rspack } from "@rspack/core";
4
- import { colors } from "../colors.js";
5
- import { restartCleaners } from "../global.js";
6
- import { logger } from "../logger.js";
7
- import { openBrowser } from "../openBrowser.js";
8
- import { prebundleDeps } from "../prebundleDeps.js";
9
- import { getAddressUrls, getPort, isPlainObject, isString } from "../utils.js";
10
- import webpack from "webpack";
11
- import webpack_dev_server from "webpack-dev-server";
12
- import { getBundlerConfig } from "../bundler-config/index.js";
13
- async function unpackDev(originalUnpackConfig) {
14
- var _unpackConfig_dev, _unpackConfig_server, _unpackConfig_server1, _unpackConfig_dev1, _unpackConfig_server2;
15
- let unpackConfig = originalUnpackConfig;
16
- const isRspack = 'rspack' === unpackConfig.bundler;
17
- const bundler = isRspack ? rspack : webpack;
18
- if (null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.prebundle) unpackConfig = await prebundleDeps({
19
- unpackConfig
20
- });
21
- const config = await getBundlerConfig(unpackConfig);
22
- const compiler = bundler(config);
23
- const port = await getPort(null == (_unpackConfig_server = unpackConfig.server) ? void 0 : _unpackConfig_server.port);
24
- let proxyConfig = null == (_unpackConfig_server1 = unpackConfig.server) ? void 0 : _unpackConfig_server1.proxy;
25
- if (isPlainObject(proxyConfig)) proxyConfig = Object.entries(proxyConfig).map(([contextStr, target])=>({
26
- context: contextStr.split(','),
27
- target,
28
- changeOrigin: true
29
- }));
30
- const devServerOptions = {
31
- hot: true,
32
- port,
33
- open: false,
34
- client: {
35
- overlay: false
36
- },
37
- proxy: proxyConfig,
38
- devMiddleware: {
39
- writeToDisk: null == (_unpackConfig_dev1 = unpackConfig.dev) ? void 0 : _unpackConfig_dev1.writeToDisk
40
- }
41
- };
42
- devServerOptions.setupMiddlewares = (middlewares)=>{
43
- middlewares.unshift((req, _, next)=>{
44
- var _req_headers_accept;
45
- if (null == (_req_headers_accept = req.headers.accept) ? void 0 : _req_headers_accept.includes('html')) req.url = '/index.html';
46
- next();
47
- });
48
- if (isRspack) middlewares.unshift(experiments.lazyCompilationMiddleware(compiler));
49
- return middlewares;
50
- };
51
- const server = new webpack_dev_server(devServerOptions, compiler);
52
- await server.start();
53
- logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v2.4.0`)} ${colors.dim(`ready in ${colors.reset(Math.ceil(performance.now() - global.__unpack_start_time))}ms`)}\n`);
54
- printAddressUrls(port);
55
- logger.wait('building...');
56
- global.__unpack_dev_server_started = true;
57
- restartCleaners.push(async ()=>await server.stop(), ()=>new Promise((resolve)=>compiler.close(()=>resolve())), ()=>{
58
- global.__unpack_dev_server_started = false;
59
- });
60
- const open = null == (_unpackConfig_server2 = unpackConfig.server) ? void 0 : _unpackConfig_server2.open;
61
- if (open) {
62
- const url = isString(open) ? open : `http://localhost:${port}`;
63
- await openBrowser(url);
64
- }
65
- }
66
- function printAddressUrls(port) {
67
- const addressUrls = getAddressUrls({
68
- port
69
- });
70
- const colorUrl = (url)=>colors.cyan(url.replace(/:(\d+)\//, (_, port)=>`:${colors.bold(port)}/`));
71
- addressUrls.forEach((addr)=>{
72
- console.log(` ${colors.green(colors.dim("\u279C"))} ${colors.dim(addr.label)}${colorUrl(addr.url)}`);
73
- });
74
- }
75
- export { unpackDev };