@unpackjs/core 1.5.4 → 1.6.1

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 (238) hide show
  1. package/bin/openChrome.applescript +94 -0
  2. package/compiled/chokidar/index.d.ts +327 -0
  3. package/compiled/chokidar/index.js +1773 -0
  4. package/compiled/chokidar/license +21 -0
  5. package/compiled/chokidar/package.json +1 -0
  6. package/compiled/commander/index.d.ts +971 -0
  7. package/compiled/commander/index.js +2190 -0
  8. package/compiled/commander/license +22 -0
  9. package/compiled/commander/package.json +1 -0
  10. package/compiled/css-loader/api.js +85 -0
  11. package/compiled/css-loader/getUrl.js +26 -0
  12. package/compiled/css-loader/index.d.ts +1 -0
  13. package/compiled/css-loader/index.js +8004 -0
  14. package/compiled/css-loader/license +20 -0
  15. package/compiled/css-loader/noSourceMaps.js +5 -0
  16. package/compiled/css-loader/package.json +1 -0
  17. package/compiled/css-loader/sourceMaps.js +16 -0
  18. package/compiled/fast-glob/index.d.ts +237 -0
  19. package/compiled/fast-glob/index.js +5726 -0
  20. package/compiled/fast-glob/license +21 -0
  21. package/compiled/fast-glob/package.json +1 -0
  22. package/compiled/less-loader/index.d.ts +1 -0
  23. package/compiled/less-loader/index.js +340 -0
  24. package/compiled/less-loader/license +20 -0
  25. package/compiled/less-loader/package.json +1 -0
  26. package/compiled/line-diff/index.d.ts +1 -0
  27. package/compiled/line-diff/index.js +160 -0
  28. package/compiled/line-diff/license +21 -0
  29. package/compiled/line-diff/package.json +1 -0
  30. package/compiled/log-update/index.d.ts +1 -0
  31. package/compiled/log-update/index.js +1970 -0
  32. package/compiled/log-update/package.json +1 -0
  33. package/compiled/portfinder/index.d.ts +64 -0
  34. package/compiled/portfinder/index.js +3401 -0
  35. package/compiled/portfinder/license +22 -0
  36. package/compiled/portfinder/package.json +1 -0
  37. package/compiled/postcss-loader/index.d.ts +1 -0
  38. package/compiled/postcss-loader/index.js +94945 -0
  39. package/compiled/postcss-loader/license +20 -0
  40. package/compiled/postcss-loader/package.json +1 -0
  41. package/compiled/sass-loader/index.d.ts +961 -0
  42. package/compiled/sass-loader/index.js +5610 -0
  43. package/compiled/sass-loader/index1.js +65 -0
  44. package/compiled/sass-loader/license +20 -0
  45. package/compiled/sass-loader/package.json +1 -0
  46. package/compiled/sass-loader/sass.node.js +12 -0
  47. package/compiled/semver/index.d.ts +1 -0
  48. package/compiled/semver/index.js +1940 -0
  49. package/compiled/semver/license +15 -0
  50. package/compiled/semver/package.json +1 -0
  51. package/compiled/style-loader/index.d.ts +1 -0
  52. package/compiled/style-loader/index.js +370 -0
  53. package/compiled/style-loader/license +20 -0
  54. package/compiled/style-loader/package.json +1 -0
  55. package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
  56. package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
  57. package/compiled/style-loader/runtime/insertBySelector.js +34 -0
  58. package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
  59. package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
  60. package/compiled/style-loader/runtime/isOldIE.js +17 -0
  61. package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
  62. package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
  63. package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
  64. package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
  65. package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
  66. package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
  67. package/compiled/webpack-bundle-analyzer/index.d.ts +1 -0
  68. package/compiled/webpack-bundle-analyzer/index.js +13276 -0
  69. package/compiled/webpack-bundle-analyzer/license +20 -0
  70. package/compiled/webpack-bundle-analyzer/package.json +1 -0
  71. package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
  72. package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
  73. package/compiled/webpack-merge/index.d.ts +31 -0
  74. package/compiled/webpack-merge/index.js +1200 -0
  75. package/compiled/webpack-merge/license +20 -0
  76. package/compiled/webpack-merge/package.json +1 -0
  77. package/dist/bundleRequire.cjs +200 -0
  78. package/dist/bundleRequire.d.ts +5 -0
  79. package/dist/bundleRequire.d.ts.map +1 -0
  80. package/dist/bundleRequire.js +173 -0
  81. package/dist/bundler-config/chunkSplit.cjs +151 -0
  82. package/dist/bundler-config/chunkSplit.d.ts +6 -0
  83. package/dist/bundler-config/chunkSplit.d.ts.map +1 -0
  84. package/dist/bundler-config/chunkSplit.js +127 -0
  85. package/dist/bundler-config/css.cjs +167 -0
  86. package/dist/bundler-config/css.d.ts +6 -0
  87. package/dist/bundler-config/css.d.ts.map +1 -0
  88. package/dist/bundler-config/css.js +158 -0
  89. package/dist/bundler-config/experimentCss.cjs +166 -0
  90. package/dist/bundler-config/experimentCss.d.ts +6 -0
  91. package/dist/bundler-config/experimentCss.d.ts.map +1 -0
  92. package/dist/bundler-config/experimentCss.js +157 -0
  93. package/dist/bundler-config/helper.cjs +83 -0
  94. package/dist/bundler-config/helper.d.ts +8 -0
  95. package/dist/bundler-config/helper.d.ts.map +1 -0
  96. package/dist/bundler-config/helper.js +58 -0
  97. package/dist/bundler-config/index.cjs +204 -0
  98. package/dist/bundler-config/index.d.ts +3 -0
  99. package/dist/bundler-config/index.d.ts.map +1 -0
  100. package/dist/bundler-config/index.js +180 -0
  101. package/dist/colors.cjs +60 -0
  102. package/dist/colors.d.ts +6 -0
  103. package/dist/colors.d.ts.map +1 -0
  104. package/dist/colors.js +40 -0
  105. package/dist/{config/index.cjs → config.cjs} +21 -47
  106. package/dist/{config/index.d.ts → config.d.ts} +4 -3
  107. package/dist/config.d.ts.map +1 -0
  108. package/dist/{config/index.js → config.js} +18 -52
  109. package/dist/constants.cjs +86 -0
  110. package/dist/constants.d.ts +25 -0
  111. package/dist/constants.d.ts.map +1 -0
  112. package/dist/constants.js +61 -0
  113. package/dist/createUnpack.cjs +102 -0
  114. package/dist/createUnpack.d.ts +7 -0
  115. package/dist/createUnpack.d.ts.map +1 -0
  116. package/dist/createUnpack.js +78 -0
  117. package/dist/index.cjs +26 -48
  118. package/dist/index.d.ts +7 -7
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +8 -52
  121. package/dist/lightningcss/cache.cjs +36 -0
  122. package/dist/lightningcss/cache.d.ts +2 -0
  123. package/dist/lightningcss/cache.d.ts.map +1 -0
  124. package/dist/lightningcss/cache.js +22 -0
  125. package/dist/lightningcss/index.cjs +21 -0
  126. package/dist/lightningcss/index.d.ts +2 -0
  127. package/dist/lightningcss/index.d.ts.map +1 -0
  128. package/dist/lightningcss/index.js +10 -0
  129. package/dist/lightningcss/loader.cjs +56 -0
  130. package/dist/lightningcss/loader.d.ts +5 -0
  131. package/dist/lightningcss/loader.d.ts.map +1 -0
  132. package/dist/lightningcss/loader.js +36 -0
  133. package/dist/lightningcss/minimizer.cjs +114 -0
  134. package/dist/lightningcss/minimizer.d.ts +11 -0
  135. package/dist/lightningcss/minimizer.d.ts.map +1 -0
  136. package/dist/lightningcss/minimizer.js +90 -0
  137. package/dist/logger.cjs +103 -0
  138. package/dist/logger.d.ts +3 -0
  139. package/dist/logger.d.ts.map +1 -0
  140. package/dist/logger.js +79 -0
  141. package/dist/openBrowser.cjs +85 -0
  142. package/dist/openBrowser.d.ts +2 -0
  143. package/dist/openBrowser.d.ts.map +1 -0
  144. package/dist/openBrowser.js +61 -0
  145. package/dist/plugin-progress/rspack.cjs +74 -0
  146. package/dist/plugin-progress/rspack.d.ts +9 -0
  147. package/dist/plugin-progress/rspack.d.ts.map +1 -0
  148. package/dist/plugin-progress/rspack.js +50 -0
  149. package/dist/plugin-progress/webpack.cjs +84 -0
  150. package/dist/plugin-progress/webpack.d.ts +9 -0
  151. package/dist/plugin-progress/webpack.d.ts.map +1 -0
  152. package/dist/plugin-progress/webpack.js +60 -0
  153. package/dist/plugin.cjs +33 -0
  154. package/dist/plugin.d.ts +3 -0
  155. package/dist/plugin.d.ts.map +1 -0
  156. package/dist/plugin.js +19 -0
  157. package/dist/progressBar.cjs +70 -0
  158. package/dist/progressBar.d.ts +14 -0
  159. package/dist/progressBar.d.ts.map +1 -0
  160. package/dist/progressBar.js +46 -0
  161. package/dist/reporter.cjs +133 -0
  162. package/dist/reporter.d.ts +9 -0
  163. package/dist/reporter.d.ts.map +1 -0
  164. package/dist/reporter.js +109 -0
  165. package/dist/run/build.cjs +77 -0
  166. package/dist/run/build.d.ts +3 -0
  167. package/dist/run/build.d.ts.map +1 -0
  168. package/dist/run/build.js +53 -0
  169. package/dist/run/dev.cjs +107 -0
  170. package/dist/run/dev.d.ts +3 -0
  171. package/dist/run/dev.d.ts.map +1 -0
  172. package/dist/run/dev.js +83 -0
  173. package/dist/run/index.cjs +23 -0
  174. package/dist/run/index.d.ts +3 -0
  175. package/dist/run/index.d.ts.map +1 -0
  176. package/dist/run/index.js +11 -0
  177. package/dist/thread-loader/WorkerError.cjs +41 -0
  178. package/dist/thread-loader/WorkerError.js +31 -0
  179. package/dist/thread-loader/WorkerPool.cjs +407 -0
  180. package/dist/thread-loader/WorkerPool.js +387 -0
  181. package/dist/thread-loader/index.cjs +100 -0
  182. package/dist/thread-loader/index.js +85 -0
  183. package/dist/thread-loader/readBuffer.cjs +55 -0
  184. package/dist/thread-loader/readBuffer.js +45 -0
  185. package/dist/thread-loader/serializer.cjs +46 -0
  186. package/dist/thread-loader/serializer.js +31 -0
  187. package/dist/thread-loader/utils.cjs +84 -0
  188. package/dist/thread-loader/utils.js +60 -0
  189. package/dist/thread-loader/worker.cjs +377 -0
  190. package/dist/thread-loader/worker.js +382 -0
  191. package/dist/thread-loader/workerPools.cjs +57 -0
  192. package/dist/thread-loader/workerPools.js +33 -0
  193. package/dist/typed-css-modules/index.cjs +21 -0
  194. package/dist/typed-css-modules/index.d.ts +2 -0
  195. package/dist/typed-css-modules/index.d.ts.map +1 -0
  196. package/dist/typed-css-modules/index.js +10 -0
  197. package/dist/typed-css-modules/loader.cjs +195 -0
  198. package/dist/typed-css-modules/loader.d.ts +10 -0
  199. package/dist/typed-css-modules/loader.d.ts.map +1 -0
  200. package/dist/typed-css-modules/loader.js +170 -0
  201. package/dist/typed-css-modules/plugin.cjs +96 -0
  202. package/dist/typed-css-modules/plugin.d.ts +16 -0
  203. package/dist/typed-css-modules/plugin.d.ts.map +1 -0
  204. package/dist/typed-css-modules/plugin.js +72 -0
  205. package/dist/typed-css-modules/utils.cjs +45 -0
  206. package/dist/typed-css-modules/utils.d.ts +6 -0
  207. package/dist/typed-css-modules/utils.d.ts.map +1 -0
  208. package/dist/typed-css-modules/utils.js +31 -0
  209. package/dist/types/chunkSplit.cjs +15 -0
  210. package/dist/types/chunkSplit.d.ts +35 -0
  211. package/dist/types/chunkSplit.d.ts.map +1 -0
  212. package/dist/types/chunkSplit.js +9 -0
  213. package/dist/types/config.cjs +15 -0
  214. package/dist/types/config.d.ts +176 -0
  215. package/dist/types/config.d.ts.map +1 -0
  216. package/dist/types/config.js +9 -0
  217. package/dist/types/index.cjs +29 -0
  218. package/dist/types/index.d.ts +16 -0
  219. package/dist/types/index.d.ts.map +1 -0
  220. package/dist/types/index.js +14 -0
  221. package/dist/types/lightningcss.cjs +15 -0
  222. package/dist/types/lightningcss.d.ts +11 -0
  223. package/dist/types/lightningcss.d.ts.map +1 -0
  224. package/dist/types/lightningcss.js +9 -0
  225. package/dist/types/logger.cjs +35 -0
  226. package/dist/types/logger.d.ts +16 -0
  227. package/dist/types/logger.d.ts.map +1 -0
  228. package/dist/types/logger.js +21 -0
  229. package/dist/types/plugin.cjs +15 -0
  230. package/dist/types/plugin.d.ts +18 -0
  231. package/dist/types/plugin.d.ts.map +1 -0
  232. package/dist/types/plugin.js +9 -0
  233. package/dist/utils.cjs +286 -0
  234. package/dist/utils.d.ts +43 -0
  235. package/dist/utils.d.ts.map +1 -0
  236. package/dist/utils.js +235 -0
  237. package/package.json +95 -6
  238. package/dist/config/index.d.ts.map +0 -1
@@ -0,0 +1,83 @@
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 helper_exports = {};
29
+ __export(helper_exports, {
30
+ getEntry: () => getEntry,
31
+ getOutputFilename: () => getOutputFilename
32
+ });
33
+ module.exports = __toCommonJS(helper_exports);
34
+ var import_node_fs = __toESM(require("node:fs"));
35
+ var import_node_path = __toESM(require("node:path"));
36
+ var import_utils = require("../utils.cjs");
37
+ var import_constants = require("../constants.cjs");
38
+ var import_logger = require("../logger.cjs");
39
+ const glob = require("../../compiled/fast-glob/index.js");
40
+ async function getEntry(root, customEntry) {
41
+ let entry = void 0;
42
+ if (!customEntry) {
43
+ const files = await glob("(index|Index).{js,ts,jsx,tsx}", {
44
+ cwd: import_node_path.default.join(root, "src"),
45
+ absolute: true
46
+ });
47
+ entry = files[0];
48
+ } else {
49
+ entry = import_node_path.default.resolve(root, customEntry);
50
+ }
51
+ if (!import_node_fs.default.existsSync(entry)) {
52
+ import_logger.logger.error(new Error("Could not find entry file"));
53
+ process.exit(1);
54
+ }
55
+ return entry;
56
+ }
57
+ const getOutputFilename = ({ type, hash }) => {
58
+ const mode = (0, import_utils.isDev)() || hash === false ? "development" : "production";
59
+ const handles = {
60
+ js: {
61
+ development: () => {
62
+ return import_constants.DEV_DEFAULT_FILENAME.js;
63
+ },
64
+ production: () => {
65
+ return import_constants.PROD_DEFAULT_FILENAME.js;
66
+ }
67
+ },
68
+ css: {
69
+ development: () => {
70
+ return import_constants.DEV_DEFAULT_FILENAME.css;
71
+ },
72
+ production: () => {
73
+ return import_constants.PROD_DEFAULT_FILENAME.css;
74
+ }
75
+ }
76
+ };
77
+ return handles[type][mode]();
78
+ };
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ getEntry,
82
+ getOutputFilename
83
+ });
@@ -0,0 +1,8 @@
1
+ export declare function getEntry(root: string, customEntry: string): Promise<string>;
2
+ type OutputFilename = {
3
+ type: 'js' | 'css';
4
+ hash: boolean;
5
+ };
6
+ export declare const getOutputFilename: ({ type, hash }: OutputFilename) => string;
7
+ export {};
8
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/bundler-config/helper.ts"],"names":[],"mappings":"AAOA,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBjF;AAED,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,IAAI,GAAG,KAAK,CAAA;IAClB,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AACD,eAAO,MAAM,iBAAiB,mBAAoB,cAAc,WAqB/D,CAAA"}
@@ -0,0 +1,58 @@
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
+ const glob = require("../../compiled/fast-glob/index.js");
11
+ import fs from "node:fs";
12
+ import path2 from "node:path";
13
+ import { isDev } from "../utils.js";
14
+ import { DEV_DEFAULT_FILENAME, PROD_DEFAULT_FILENAME } from "../constants.js";
15
+ import { logger } from "../logger.js";
16
+ async function getEntry(root, customEntry) {
17
+ let entry = void 0;
18
+ if (!customEntry) {
19
+ const files = await glob("(index|Index).{js,ts,jsx,tsx}", {
20
+ cwd: path2.join(root, "src"),
21
+ absolute: true
22
+ });
23
+ entry = files[0];
24
+ } else {
25
+ entry = path2.resolve(root, customEntry);
26
+ }
27
+ if (!fs.existsSync(entry)) {
28
+ logger.error(new Error("Could not find entry file"));
29
+ process.exit(1);
30
+ }
31
+ return entry;
32
+ }
33
+ const getOutputFilename = ({ type, hash }) => {
34
+ const mode = isDev() || hash === false ? "development" : "production";
35
+ const handles = {
36
+ js: {
37
+ development: () => {
38
+ return DEV_DEFAULT_FILENAME.js;
39
+ },
40
+ production: () => {
41
+ return PROD_DEFAULT_FILENAME.js;
42
+ }
43
+ },
44
+ css: {
45
+ development: () => {
46
+ return DEV_DEFAULT_FILENAME.css;
47
+ },
48
+ production: () => {
49
+ return PROD_DEFAULT_FILENAME.css;
50
+ }
51
+ }
52
+ };
53
+ return handles[type][mode]();
54
+ };
55
+ export {
56
+ getEntry,
57
+ getOutputFilename
58
+ };
@@ -0,0 +1,204 @@
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 bundler_config_exports = {};
29
+ __export(bundler_config_exports, {
30
+ getBundlerConfig: () => getBundlerConfig
31
+ });
32
+ module.exports = __toCommonJS(bundler_config_exports);
33
+ var import_node_fs = __toESM(require("node:fs"));
34
+ var import_node_path = __toESM(require("node:path"));
35
+ var import_core = require("@rspack/core");
36
+ var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
37
+ var import_utils = require("../utils.cjs");
38
+ var import_esbuild = __toESM(require("esbuild"));
39
+ var import_esbuild_loader = require("esbuild-loader");
40
+ var import_json5 = __toESM(require("json5"));
41
+ var import_constants = require("../constants.cjs");
42
+ var import_lightningcss = require("../lightningcss/index.cjs");
43
+ var import_logger = require("../logger.cjs");
44
+ var import_plugin = require("../plugin.cjs");
45
+ var import_rspack = require("../plugin-progress/rspack.cjs");
46
+ var import_webpack = require("../plugin-progress/webpack.cjs");
47
+ var import_webpack2 = __toESM(require("webpack"));
48
+ var import_chunkSplit = require("./chunkSplit.cjs");
49
+ var import_css = require("./css.cjs");
50
+ var import_experimentCss = require("./experimentCss.cjs");
51
+ var import_helper = require("./helper.cjs");
52
+ const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
53
+ const BundleAnalyzerPlugin = require("../../compiled/webpack-bundle-analyzer/index.js").BundleAnalyzerPlugin;
54
+ const CopyWebpackPlugin = require("copy-webpack-plugin");
55
+ async function getBundlerConfig(unpackConfig) {
56
+ const isRspack = unpackConfig.bundler === "rspack";
57
+ const definePlugin = (define) => isRspack ? new import_core.rspack.DefinePlugin(define) : new import_esbuild_loader.EsbuildPlugin({ define, implementation: import_esbuild.default });
58
+ const JS_FILENAME = (0, import_helper.getOutputFilename)({ type: "js", hash: unpackConfig.build?.filenameHash });
59
+ const IgnorePlugin = isRspack ? import_core.rspack.IgnorePlugin : import_webpack2.default.IgnorePlugin;
60
+ const CopyPlugin = isRspack ? import_core.rspack.CopyRspackPlugin : CopyWebpackPlugin;
61
+ const tsconfigPath = import_node_path.default.resolve(unpackConfig.root, "tsconfig.json");
62
+ const isTs = import_node_fs.default.existsSync(tsconfigPath);
63
+ const getAliasFromTsconfig = () => {
64
+ const paths = import_json5.default.parse(import_node_fs.default.readFileSync(tsconfigPath, "utf-8"))?.compilerOptions?.paths;
65
+ return paths ? Object.keys(paths).reduce((acc, key) => {
66
+ acc[key.replace(/\/\*$/, "")] = import_node_path.default.resolve(
67
+ unpackConfig.root,
68
+ paths[key][0].replace(/\/\*$/, "")
69
+ );
70
+ return acc;
71
+ }, {}) : {};
72
+ };
73
+ const minifyOptions = (0, import_utils.isPlainObject)(unpackConfig.build?.minify) ? unpackConfig.build?.minify : {};
74
+ const PluginProgress = isRspack ? import_rspack.RspackPluginProgress : import_webpack.WebpackPluginProgress;
75
+ let config = {
76
+ context: unpackConfig.root,
77
+ mode: (0, import_utils.isDev)() ? "development" : "production",
78
+ entry: !unpackConfig.mpa ? {
79
+ main: await (0, import_helper.getEntry)(unpackConfig.root, unpackConfig.entry)
80
+ } : {},
81
+ stats: "errors-only",
82
+ output: {
83
+ clean: true,
84
+ path: import_node_path.default.resolve(unpackConfig.root, unpackConfig.build?.outDir),
85
+ filename: JS_FILENAME,
86
+ chunkFilename: JS_FILENAME,
87
+ crossOriginLoading: "anonymous",
88
+ pathinfo: false,
89
+ publicPath: unpackConfig.build?.publicPath
90
+ },
91
+ infrastructureLogging: {
92
+ level: "warn"
93
+ },
94
+ devtool: unpackConfig.build?.sourceMap,
95
+ module: {
96
+ rules: [
97
+ {
98
+ test: /\.(png|svg|jpg|jpeg|gif)$/i,
99
+ type: "asset/resource"
100
+ },
101
+ {
102
+ test: /\.(woff|woff2|eot|ttf|otf)$/i,
103
+ type: "asset/resource"
104
+ }
105
+ ]
106
+ },
107
+ plugins: [
108
+ unpackConfig.define && definePlugin(unpackConfig.define),
109
+ !unpackConfig.mpa && new import_html_webpack_plugin.default({
110
+ template: unpackConfig.html?.template || "",
111
+ templateContent: unpackConfig.html?.templateContent || import_constants.TEMPLATE_CONTENT,
112
+ templateParameters: {
113
+ mountId: unpackConfig.html?.mountId,
114
+ title: (0, import_utils.isFunction)(unpackConfig.html?.title) ? unpackConfig.html?.title({ entryName: "index" }) : unpackConfig.html?.title,
115
+ headTag: unpackConfig.html?.headTag,
116
+ ...unpackConfig.html?.templateParameters
117
+ },
118
+ minify: false,
119
+ chunks: ["main"]
120
+ }),
121
+ unpackConfig.performance?.bundleAnalyze && (0, import_utils.isProd)() && new BundleAnalyzerPlugin(),
122
+ unpackConfig.performance?.removeMomentLocale && new IgnorePlugin({
123
+ resourceRegExp: /^\.\/locale$/,
124
+ contextRegExp: /moment$/
125
+ }),
126
+ unpackConfig.build?.copy && new CopyPlugin({ patterns: unpackConfig.build.copy }),
127
+ (0, import_utils.isDev)() && isTs && new ForkTsCheckerWebpackPlugin({
128
+ typescript: {
129
+ // set 'readonly' to avoid emitting tsbuildinfo, as the generated tsbuildinfo will break fork-ts-checker
130
+ mode: "readonly",
131
+ // avoid OOM issue
132
+ memoryLimit: 8192,
133
+ // use tsconfig of user project
134
+ configFile: tsconfigPath,
135
+ // use typescript of user project
136
+ typescriptPath: require.resolve("typescript", {
137
+ paths: [unpackConfig.root]
138
+ })
139
+ },
140
+ logger: {
141
+ log(message) {
142
+ if (message.includes("Found")) {
143
+ console.log(message.split(" in ")[0]);
144
+ }
145
+ },
146
+ error(message) {
147
+ console.log(message.replace(/ERROR/g, "Type Error"));
148
+ }
149
+ }
150
+ }),
151
+ !(0, import_utils.isDevServer)() && new PluginProgress()
152
+ ].filter(Boolean),
153
+ externals: unpackConfig.externals,
154
+ resolve: {
155
+ alias: {
156
+ "@": import_node_path.default.resolve(unpackConfig.root, "src"),
157
+ ...isTs ? getAliasFromTsconfig() : {},
158
+ ...unpackConfig.resolve?.alias
159
+ },
160
+ extensions: [".tsx", ".ts", ".jsx", ".js", ...unpackConfig.resolve?.extensions || []]
161
+ },
162
+ experiments: {
163
+ lazyCompilation: (0, import_utils.isDevServer)(),
164
+ css: false
165
+ },
166
+ optimization: {
167
+ moduleIds: (0, import_utils.isDev)() ? "named" : "deterministic",
168
+ minimize: Boolean(unpackConfig.build?.minify),
169
+ minimizer: [
170
+ new import_esbuild_loader.EsbuildPlugin({ implementation: import_esbuild.default }),
171
+ new import_lightningcss.LightningcssMinifyPlugin(minifyOptions.lightningcss)
172
+ ]
173
+ },
174
+ cache: unpackConfig.build?.cache && unpackConfig.bundler === "webpack" ? {
175
+ type: "filesystem"
176
+ } : void 0
177
+ };
178
+ if (unpackConfig.experiments?.css)
179
+ import_logger.logger.warn("Experiments.css is not stable yet, please use with caution");
180
+ config = unpackConfig.experiments?.css ? (0, import_experimentCss.addExperimentCssSupport)({ config, unpackConfig }) : (0, import_css.addCssSupport)({ config, unpackConfig });
181
+ config = (0, import_chunkSplit.addChunkSplitSupport)({ config, unpackConfig });
182
+ for (const plugin of (0, import_plugin.getNormalizedPluginsByHook)("bundlerConfig", unpackConfig.plugins)) {
183
+ config = await plugin.bundlerConfig(config, {
184
+ unpackConfig,
185
+ mergeConfig: import_utils.mergeConfig,
186
+ bundler: import_webpack2.default
187
+ });
188
+ }
189
+ if (unpackConfig.bundlerConfig) {
190
+ if ((0, import_utils.isFunction)(unpackConfig.bundlerConfig)) {
191
+ config = await unpackConfig.bundlerConfig(config, {
192
+ bundler: unpackConfig.bundler,
193
+ mergeConfig: import_utils.mergeConfig
194
+ });
195
+ } else {
196
+ config = (0, import_utils.mergeConfig)(config, unpackConfig.bundlerConfig);
197
+ }
198
+ }
199
+ return config;
200
+ }
201
+ // Annotate the CommonJS export names for ESM import in node:
202
+ 0 && (module.exports = {
203
+ getBundlerConfig
204
+ });
@@ -0,0 +1,3 @@
1
+ import type { BundlerConfiguration, UnpackConfig } from '../types/index';
2
+ export declare function getBundlerConfig(unpackConfig: UnpackConfig): Promise<BundlerConfiguration>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler-config/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAqBzE,wBAAsB,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAmKhG"}
@@ -0,0 +1,180 @@
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 { rspack } from "@rspack/core";
13
+ import HtmlWebpackPlugin from "html-webpack-plugin";
14
+ import { isDev, isDevServer, isFunction, isPlainObject, isProd, mergeConfig } from "../utils.js";
15
+ const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
16
+ const BundleAnalyzerPlugin = require("../../compiled/webpack-bundle-analyzer/index.js").BundleAnalyzerPlugin;
17
+ const CopyWebpackPlugin = require("copy-webpack-plugin");
18
+ import esbuild from "esbuild";
19
+ import { EsbuildPlugin } from "esbuild-loader";
20
+ import json5 from "json5";
21
+ import { TEMPLATE_CONTENT } from "../constants.js";
22
+ import { LightningcssMinifyPlugin } from "../lightningcss/index.js";
23
+ import { logger } from "../logger.js";
24
+ import { getNormalizedPluginsByHook } from "../plugin.js";
25
+ import { RspackPluginProgress } from "../plugin-progress/rspack.js";
26
+ import { WebpackPluginProgress } from "../plugin-progress/webpack.js";
27
+ import webpack from "webpack";
28
+ import { addChunkSplitSupport } from "./chunkSplit.js";
29
+ import { addCssSupport } from "./css.js";
30
+ import { addExperimentCssSupport } from "./experimentCss.js";
31
+ import { getEntry, getOutputFilename } from "./helper.js";
32
+ async function getBundlerConfig(unpackConfig) {
33
+ const isRspack = unpackConfig.bundler === "rspack";
34
+ const definePlugin = (define) => isRspack ? new rspack.DefinePlugin(define) : new EsbuildPlugin({ define, implementation: esbuild });
35
+ const JS_FILENAME = getOutputFilename({ type: "js", hash: unpackConfig.build?.filenameHash });
36
+ const IgnorePlugin = isRspack ? rspack.IgnorePlugin : webpack.IgnorePlugin;
37
+ const CopyPlugin = isRspack ? rspack.CopyRspackPlugin : CopyWebpackPlugin;
38
+ const tsconfigPath = path2.resolve(unpackConfig.root, "tsconfig.json");
39
+ const isTs = fs.existsSync(tsconfigPath);
40
+ const getAliasFromTsconfig = () => {
41
+ const paths = json5.parse(fs.readFileSync(tsconfigPath, "utf-8"))?.compilerOptions?.paths;
42
+ return paths ? Object.keys(paths).reduce((acc, key) => {
43
+ acc[key.replace(/\/\*$/, "")] = path2.resolve(
44
+ unpackConfig.root,
45
+ paths[key][0].replace(/\/\*$/, "")
46
+ );
47
+ return acc;
48
+ }, {}) : {};
49
+ };
50
+ const minifyOptions = isPlainObject(unpackConfig.build?.minify) ? unpackConfig.build?.minify : {};
51
+ const PluginProgress = isRspack ? RspackPluginProgress : WebpackPluginProgress;
52
+ let config = {
53
+ context: unpackConfig.root,
54
+ mode: isDev() ? "development" : "production",
55
+ entry: !unpackConfig.mpa ? {
56
+ main: await getEntry(unpackConfig.root, unpackConfig.entry)
57
+ } : {},
58
+ stats: "errors-only",
59
+ output: {
60
+ clean: true,
61
+ path: path2.resolve(unpackConfig.root, unpackConfig.build?.outDir),
62
+ filename: JS_FILENAME,
63
+ chunkFilename: JS_FILENAME,
64
+ crossOriginLoading: "anonymous",
65
+ pathinfo: false,
66
+ publicPath: unpackConfig.build?.publicPath
67
+ },
68
+ infrastructureLogging: {
69
+ level: "warn"
70
+ },
71
+ devtool: unpackConfig.build?.sourceMap,
72
+ module: {
73
+ rules: [
74
+ {
75
+ test: /\.(png|svg|jpg|jpeg|gif)$/i,
76
+ type: "asset/resource"
77
+ },
78
+ {
79
+ test: /\.(woff|woff2|eot|ttf|otf)$/i,
80
+ type: "asset/resource"
81
+ }
82
+ ]
83
+ },
84
+ plugins: [
85
+ unpackConfig.define && definePlugin(unpackConfig.define),
86
+ !unpackConfig.mpa && new HtmlWebpackPlugin({
87
+ template: unpackConfig.html?.template || "",
88
+ templateContent: unpackConfig.html?.templateContent || TEMPLATE_CONTENT,
89
+ templateParameters: {
90
+ mountId: unpackConfig.html?.mountId,
91
+ title: isFunction(unpackConfig.html?.title) ? unpackConfig.html?.title({ entryName: "index" }) : unpackConfig.html?.title,
92
+ headTag: unpackConfig.html?.headTag,
93
+ ...unpackConfig.html?.templateParameters
94
+ },
95
+ minify: false,
96
+ chunks: ["main"]
97
+ }),
98
+ unpackConfig.performance?.bundleAnalyze && isProd() && new BundleAnalyzerPlugin(),
99
+ unpackConfig.performance?.removeMomentLocale && new IgnorePlugin({
100
+ resourceRegExp: /^\.\/locale$/,
101
+ contextRegExp: /moment$/
102
+ }),
103
+ unpackConfig.build?.copy && new CopyPlugin({ patterns: unpackConfig.build.copy }),
104
+ isDev() && isTs && new ForkTsCheckerWebpackPlugin({
105
+ typescript: {
106
+ // set 'readonly' to avoid emitting tsbuildinfo, as the generated tsbuildinfo will break fork-ts-checker
107
+ mode: "readonly",
108
+ // avoid OOM issue
109
+ memoryLimit: 8192,
110
+ // use tsconfig of user project
111
+ configFile: tsconfigPath,
112
+ // use typescript of user project
113
+ typescriptPath: require.resolve("typescript", {
114
+ paths: [unpackConfig.root]
115
+ })
116
+ },
117
+ logger: {
118
+ log(message) {
119
+ if (message.includes("Found")) {
120
+ console.log(message.split(" in ")[0]);
121
+ }
122
+ },
123
+ error(message) {
124
+ console.log(message.replace(/ERROR/g, "Type Error"));
125
+ }
126
+ }
127
+ }),
128
+ !isDevServer() && new PluginProgress()
129
+ ].filter(Boolean),
130
+ externals: unpackConfig.externals,
131
+ resolve: {
132
+ alias: {
133
+ "@": path2.resolve(unpackConfig.root, "src"),
134
+ ...isTs ? getAliasFromTsconfig() : {},
135
+ ...unpackConfig.resolve?.alias
136
+ },
137
+ extensions: [".tsx", ".ts", ".jsx", ".js", ...unpackConfig.resolve?.extensions || []]
138
+ },
139
+ experiments: {
140
+ lazyCompilation: isDevServer(),
141
+ css: false
142
+ },
143
+ optimization: {
144
+ moduleIds: isDev() ? "named" : "deterministic",
145
+ minimize: Boolean(unpackConfig.build?.minify),
146
+ minimizer: [
147
+ new EsbuildPlugin({ implementation: esbuild }),
148
+ new LightningcssMinifyPlugin(minifyOptions.lightningcss)
149
+ ]
150
+ },
151
+ cache: unpackConfig.build?.cache && unpackConfig.bundler === "webpack" ? {
152
+ type: "filesystem"
153
+ } : void 0
154
+ };
155
+ if (unpackConfig.experiments?.css)
156
+ logger.warn("Experiments.css is not stable yet, please use with caution");
157
+ config = unpackConfig.experiments?.css ? addExperimentCssSupport({ config, unpackConfig }) : addCssSupport({ config, unpackConfig });
158
+ config = addChunkSplitSupport({ config, unpackConfig });
159
+ for (const plugin of getNormalizedPluginsByHook("bundlerConfig", unpackConfig.plugins)) {
160
+ config = await plugin.bundlerConfig(config, {
161
+ unpackConfig,
162
+ mergeConfig,
163
+ bundler: webpack
164
+ });
165
+ }
166
+ if (unpackConfig.bundlerConfig) {
167
+ if (isFunction(unpackConfig.bundlerConfig)) {
168
+ config = await unpackConfig.bundlerConfig(config, {
169
+ bundler: unpackConfig.bundler,
170
+ mergeConfig
171
+ });
172
+ } else {
173
+ config = mergeConfig(config, unpackConfig.bundlerConfig);
174
+ }
175
+ }
176
+ return config;
177
+ }
178
+ export {
179
+ getBundlerConfig
180
+ };
@@ -0,0 +1,60 @@
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 colors_exports = {};
29
+ __export(colors_exports, {
30
+ default: () => colors_default
31
+ });
32
+ module.exports = __toCommonJS(colors_exports);
33
+ var import_picocolors = __toESM(require("picocolors"));
34
+ const colors = {
35
+ ...import_picocolors.default,
36
+ rainbow: (input) => {
37
+ const startColor = [48, 112, 198];
38
+ const endColor = [97, 193, 198];
39
+ const isWord = (char) => !/[\s\n]/.test(char);
40
+ const chars = [...input];
41
+ const steps = chars.filter(isWord).length;
42
+ let r = startColor[0];
43
+ let g = startColor[1];
44
+ let b = startColor[2];
45
+ const rStep = (endColor[0] - r) / steps;
46
+ const gStep = (endColor[1] - g) / steps;
47
+ const bStep = (endColor[2] - b) / steps;
48
+ let output = "";
49
+ for (const char of chars) {
50
+ if (isWord(char)) {
51
+ r += rStep;
52
+ g += gStep;
53
+ b += bStep;
54
+ }
55
+ output += `\x1B[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1B[39m`;
56
+ }
57
+ return output;
58
+ }
59
+ };
60
+ var colors_default = colors;
@@ -0,0 +1,6 @@
1
+ import type { Colors } from 'picocolors/types';
2
+ declare const colors: Colors & {
3
+ rainbow: (input: string) => string;
4
+ };
5
+ export default colors;
6
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAE9C,QAAA,MAAM,MAAM,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;CAyB1D,CAAA;AACD,eAAe,MAAM,CAAA"}
package/dist/colors.js ADDED
@@ -0,0 +1,40 @@
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 picocolors from "picocolors";
11
+ const colors = {
12
+ ...picocolors,
13
+ rainbow: (input) => {
14
+ const startColor = [48, 112, 198];
15
+ const endColor = [97, 193, 198];
16
+ const isWord = (char) => !/[\s\n]/.test(char);
17
+ const chars = [...input];
18
+ const steps = chars.filter(isWord).length;
19
+ let r = startColor[0];
20
+ let g = startColor[1];
21
+ let b = startColor[2];
22
+ const rStep = (endColor[0] - r) / steps;
23
+ const gStep = (endColor[1] - g) / steps;
24
+ const bStep = (endColor[2] - b) / steps;
25
+ let output = "";
26
+ for (const char of chars) {
27
+ if (isWord(char)) {
28
+ r += rStep;
29
+ g += gStep;
30
+ b += bStep;
31
+ }
32
+ output += `\x1B[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1B[39m`;
33
+ }
34
+ return output;
35
+ }
36
+ };
37
+ var colors_default = colors;
38
+ export {
39
+ colors_default as default
40
+ };