@unpackjs/core 1.5.4 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +168 -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 +167 -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 +81 -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 +56 -0
  97. package/dist/bundler-config/index.cjs +206 -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 +190 -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} +26 -20
  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} +19 -21
  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/createService.cjs +65 -0
  114. package/dist/createService.d.ts +8 -0
  115. package/dist/createService.d.ts.map +1 -0
  116. package/dist/createService.js +41 -0
  117. package/dist/index.cjs +27 -48
  118. package/dist/index.d.ts +7 -7
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +8 -51
  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 +8 -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 +293 -0
  234. package/dist/utils.d.ts +39 -0
  235. package/dist/utils.d.ts.map +1 -0
  236. package/dist/utils.js +242 -0
  237. package/package.json +95 -6
  238. package/dist/config/index.d.ts.map +0 -1
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Juho Vepsalainen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ {"name":"webpack-merge","author":"Juho Vepsalainen <bebraw@gmail.com>","version":"6.0.1","license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -0,0 +1,200 @@
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 bundleRequire_exports = {};
29
+ __export(bundleRequire_exports, {
30
+ bundleRequire: () => bundleRequire,
31
+ isBuiltin: () => isBuiltin,
32
+ isFilePathESM: () => isFilePathESM,
33
+ isNodeBuiltin: () => isNodeBuiltin
34
+ });
35
+ module.exports = __toCommonJS(bundleRequire_exports);
36
+ var import_node_fs = __toESM(require("node:fs"));
37
+ var import_node_module = require("node:module");
38
+ var import_node_path = __toESM(require("node:path"));
39
+ var import_node_url = require("node:url");
40
+ var import_node_util = require("node:util");
41
+ var import_esbuild = require("esbuild");
42
+ const promisifiedRealpath = (0, import_node_util.promisify)(import_node_fs.default.realpath);
43
+ async function bundleRequire(resolvedPath) {
44
+ const isESM = isFilePathESM(resolvedPath);
45
+ const bundled = await bundleConfigFile(resolvedPath, isESM);
46
+ const userConfig = await loadConfigFromBundledFile(resolvedPath, bundled.code, isESM);
47
+ return userConfig;
48
+ }
49
+ async function bundleConfigFile(fileName, isESM) {
50
+ const dirnameVarName = "__injected_original_dirname";
51
+ const filenameVarName = "__injected_original_filename";
52
+ const importMetaUrlVarName = "__injected_original_import_meta_url";
53
+ const result = await (0, import_esbuild.build)({
54
+ absWorkingDir: process.cwd(),
55
+ entryPoints: [fileName],
56
+ write: false,
57
+ target: ["node18"],
58
+ platform: "node",
59
+ bundle: true,
60
+ format: isESM ? "esm" : "cjs",
61
+ mainFields: ["main"],
62
+ sourcemap: "inline",
63
+ metafile: true,
64
+ define: {
65
+ __dirname: dirnameVarName,
66
+ __filename: filenameVarName,
67
+ "import.meta.url": importMetaUrlVarName,
68
+ "import.meta.dirname": dirnameVarName,
69
+ "import.meta.filename": filenameVarName
70
+ },
71
+ plugins: [
72
+ {
73
+ name: "externalize-deps",
74
+ setup(build2) {
75
+ build2.onResolve({ filter: /^[^.].*/ }, async ({ path: id, kind }) => {
76
+ if (kind === "entry-point" || import_node_path.default.isAbsolute(id) || isNodeBuiltin(id)) {
77
+ return;
78
+ }
79
+ if (isBuiltin(id)) {
80
+ return { external: true };
81
+ }
82
+ const isImport = isESM || kind === "dynamic-import";
83
+ let idFsPath;
84
+ if (!isImport) {
85
+ const canResolveWithImport = false;
86
+ if (canResolveWithImport) {
87
+ throw new Error(
88
+ `Failed to resolve ${JSON.stringify(
89
+ id
90
+ )}. This package is ESM only but it was tried to load by \`require\`.`
91
+ );
92
+ }
93
+ }
94
+ if (idFsPath && isImport) {
95
+ idFsPath = (0, import_node_url.pathToFileURL)(idFsPath).href;
96
+ }
97
+ if (idFsPath && !isImport && isFilePathESM(idFsPath)) {
98
+ throw new Error(
99
+ `${JSON.stringify(
100
+ id
101
+ )} resolved to an ESM file. ESM file cannot be loaded by \`require\`.`
102
+ );
103
+ }
104
+ return {
105
+ path: idFsPath,
106
+ external: true
107
+ };
108
+ });
109
+ }
110
+ },
111
+ {
112
+ name: "inject-file-scope-variables",
113
+ setup(build2) {
114
+ build2.onLoad({ filter: /\.[cm]?[jt]s$/ }, async (args) => {
115
+ const contents = import_node_fs.default.readFileSync(args.path, "utf-8");
116
+ const injectValues = `const ${dirnameVarName} = ${JSON.stringify(import_node_path.default.dirname(args.path))};const ${filenameVarName} = ${JSON.stringify(args.path)};const ${importMetaUrlVarName} = ${JSON.stringify((0, import_node_url.pathToFileURL)(args.path).href)};`;
117
+ return {
118
+ loader: args.path.endsWith("ts") ? "ts" : "js",
119
+ contents: injectValues + contents
120
+ };
121
+ });
122
+ }
123
+ }
124
+ ]
125
+ });
126
+ const { text } = result.outputFiles[0];
127
+ return {
128
+ code: text,
129
+ dependencies: result.metafile ? Object.keys(result.metafile.inputs) : []
130
+ };
131
+ }
132
+ async function loadConfigFromBundledFile(fileName, bundledCode, isESM) {
133
+ if (isESM) {
134
+ const fileBase = `${fileName}.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`;
135
+ const fileNameTmp = `${fileBase}.mjs`;
136
+ const fileUrl = `${(0, import_node_url.pathToFileURL)(fileBase)}.mjs`;
137
+ import_node_fs.default.writeFileSync(fileNameTmp, bundledCode);
138
+ try {
139
+ return (await import(fileUrl)).default;
140
+ } finally {
141
+ import_node_fs.default.unlink(fileNameTmp, () => {
142
+ });
143
+ }
144
+ } else {
145
+ const extension = import_node_path.default.extname(fileName);
146
+ const realFileName = await promisifiedRealpath(fileName);
147
+ const loaderExt = extension in require.extensions ? extension : ".js";
148
+ const defaultLoader = require.extensions[loaderExt];
149
+ require.extensions[loaderExt] = (module2, filename) => {
150
+ if (filename === realFileName) {
151
+ ;
152
+ module2._compile(bundledCode, filename);
153
+ } else {
154
+ defaultLoader(module2, filename);
155
+ }
156
+ };
157
+ delete require.cache[require.resolve(fileName)];
158
+ const raw = require(fileName);
159
+ require.extensions[loaderExt] = defaultLoader;
160
+ return raw.__esModule ? raw.default : raw;
161
+ }
162
+ }
163
+ function isFilePathESM(filePath) {
164
+ if (/\.m[jt]s$/.test(filePath)) {
165
+ return true;
166
+ }
167
+ if (/\.c[jt]s$/.test(filePath)) {
168
+ return false;
169
+ }
170
+ try {
171
+ const pkgPath = import_node_path.default.join(import_node_path.default.dirname(filePath), "package.json");
172
+ const pkgData = JSON.parse(import_node_fs.default.readFileSync(pkgPath, "utf-8"));
173
+ return pkgData.type === "module";
174
+ } catch {
175
+ return false;
176
+ }
177
+ }
178
+ const NODE_BUILTIN_NAMESPACE = "node:";
179
+ const NPM_BUILTIN_NAMESPACE = "npm:";
180
+ const BUN_BUILTIN_NAMESPACE = "bun:";
181
+ const nodeBuiltins = import_node_module.builtinModules.filter((id) => !id.includes(":"));
182
+ function isBuiltin(id) {
183
+ if (process.versions.deno && id.startsWith(NPM_BUILTIN_NAMESPACE))
184
+ return true;
185
+ if (process.versions.bun && id.startsWith(BUN_BUILTIN_NAMESPACE))
186
+ return true;
187
+ return isNodeBuiltin(id);
188
+ }
189
+ function isNodeBuiltin(id) {
190
+ if (id.startsWith(NODE_BUILTIN_NAMESPACE))
191
+ return true;
192
+ return nodeBuiltins.includes(id);
193
+ }
194
+ // Annotate the CommonJS export names for ESM import in node:
195
+ 0 && (module.exports = {
196
+ bundleRequire,
197
+ isBuiltin,
198
+ isFilePathESM,
199
+ isNodeBuiltin
200
+ });
@@ -0,0 +1,5 @@
1
+ export declare function bundleRequire(resolvedPath: string): Promise<any>;
2
+ export declare function isFilePathESM(filePath: string): boolean;
3
+ export declare function isBuiltin(id: string): boolean;
4
+ export declare function isNodeBuiltin(id: string): boolean;
5
+ //# sourceMappingURL=bundleRequire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundleRequire.d.ts","sourceRoot":"","sources":["../src/bundleRequire.ts"],"names":[],"mappings":"AAQA,wBAAsB,aAAa,CAAC,YAAY,EAAE,MAAM,gBAKvD;AAgJD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAevD;AAWD,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAI7C;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAGjD"}
@@ -0,0 +1,173 @@
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 { builtinModules } from "node:module";
12
+ import path2 from "node:path";
13
+ import { pathToFileURL } from "node:url";
14
+ import { promisify } from "node:util";
15
+ import { build } from "esbuild";
16
+ const promisifiedRealpath = promisify(fs.realpath);
17
+ async function bundleRequire(resolvedPath) {
18
+ const isESM = isFilePathESM(resolvedPath);
19
+ const bundled = await bundleConfigFile(resolvedPath, isESM);
20
+ const userConfig = await loadConfigFromBundledFile(resolvedPath, bundled.code, isESM);
21
+ return userConfig;
22
+ }
23
+ async function bundleConfigFile(fileName, isESM) {
24
+ const dirnameVarName = "__injected_original_dirname";
25
+ const filenameVarName = "__injected_original_filename";
26
+ const importMetaUrlVarName = "__injected_original_import_meta_url";
27
+ const result = await build({
28
+ absWorkingDir: process.cwd(),
29
+ entryPoints: [fileName],
30
+ write: false,
31
+ target: ["node18"],
32
+ platform: "node",
33
+ bundle: true,
34
+ format: isESM ? "esm" : "cjs",
35
+ mainFields: ["main"],
36
+ sourcemap: "inline",
37
+ metafile: true,
38
+ define: {
39
+ __dirname: dirnameVarName,
40
+ __filename: filenameVarName,
41
+ "import.meta.url": importMetaUrlVarName,
42
+ "import.meta.dirname": dirnameVarName,
43
+ "import.meta.filename": filenameVarName
44
+ },
45
+ plugins: [
46
+ {
47
+ name: "externalize-deps",
48
+ setup(build2) {
49
+ build2.onResolve({ filter: /^[^.].*/ }, async ({ path: id, kind }) => {
50
+ if (kind === "entry-point" || path2.isAbsolute(id) || isNodeBuiltin(id)) {
51
+ return;
52
+ }
53
+ if (isBuiltin(id)) {
54
+ return { external: true };
55
+ }
56
+ const isImport = isESM || kind === "dynamic-import";
57
+ let idFsPath;
58
+ if (!isImport) {
59
+ const canResolveWithImport = false;
60
+ if (canResolveWithImport) {
61
+ throw new Error(
62
+ `Failed to resolve ${JSON.stringify(
63
+ id
64
+ )}. This package is ESM only but it was tried to load by \`require\`.`
65
+ );
66
+ }
67
+ }
68
+ if (idFsPath && isImport) {
69
+ idFsPath = pathToFileURL(idFsPath).href;
70
+ }
71
+ if (idFsPath && !isImport && isFilePathESM(idFsPath)) {
72
+ throw new Error(
73
+ `${JSON.stringify(
74
+ id
75
+ )} resolved to an ESM file. ESM file cannot be loaded by \`require\`.`
76
+ );
77
+ }
78
+ return {
79
+ path: idFsPath,
80
+ external: true
81
+ };
82
+ });
83
+ }
84
+ },
85
+ {
86
+ name: "inject-file-scope-variables",
87
+ setup(build2) {
88
+ build2.onLoad({ filter: /\.[cm]?[jt]s$/ }, async (args) => {
89
+ const contents = fs.readFileSync(args.path, "utf-8");
90
+ const injectValues = `const ${dirnameVarName} = ${JSON.stringify(path2.dirname(args.path))};const ${filenameVarName} = ${JSON.stringify(args.path)};const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(args.path).href)};`;
91
+ return {
92
+ loader: args.path.endsWith("ts") ? "ts" : "js",
93
+ contents: injectValues + contents
94
+ };
95
+ });
96
+ }
97
+ }
98
+ ]
99
+ });
100
+ const { text } = result.outputFiles[0];
101
+ return {
102
+ code: text,
103
+ dependencies: result.metafile ? Object.keys(result.metafile.inputs) : []
104
+ };
105
+ }
106
+ async function loadConfigFromBundledFile(fileName, bundledCode, isESM) {
107
+ if (isESM) {
108
+ const fileBase = `${fileName}.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`;
109
+ const fileNameTmp = `${fileBase}.mjs`;
110
+ const fileUrl = `${pathToFileURL(fileBase)}.mjs`;
111
+ fs.writeFileSync(fileNameTmp, bundledCode);
112
+ try {
113
+ return (await import(fileUrl)).default;
114
+ } finally {
115
+ fs.unlink(fileNameTmp, () => {
116
+ });
117
+ }
118
+ } else {
119
+ const extension = path2.extname(fileName);
120
+ const realFileName = await promisifiedRealpath(fileName);
121
+ const loaderExt = extension in require.extensions ? extension : ".js";
122
+ const defaultLoader = require.extensions[loaderExt];
123
+ require.extensions[loaderExt] = (module, filename) => {
124
+ if (filename === realFileName) {
125
+ ;
126
+ module._compile(bundledCode, filename);
127
+ } else {
128
+ defaultLoader(module, filename);
129
+ }
130
+ };
131
+ delete require.cache[require.resolve(fileName)];
132
+ const raw = require(fileName);
133
+ require.extensions[loaderExt] = defaultLoader;
134
+ return raw.__esModule ? raw.default : raw;
135
+ }
136
+ }
137
+ function isFilePathESM(filePath) {
138
+ if (/\.m[jt]s$/.test(filePath)) {
139
+ return true;
140
+ }
141
+ if (/\.c[jt]s$/.test(filePath)) {
142
+ return false;
143
+ }
144
+ try {
145
+ const pkgPath = path2.join(path2.dirname(filePath), "package.json");
146
+ const pkgData = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
147
+ return pkgData.type === "module";
148
+ } catch {
149
+ return false;
150
+ }
151
+ }
152
+ const NODE_BUILTIN_NAMESPACE = "node:";
153
+ const NPM_BUILTIN_NAMESPACE = "npm:";
154
+ const BUN_BUILTIN_NAMESPACE = "bun:";
155
+ const nodeBuiltins = builtinModules.filter((id) => !id.includes(":"));
156
+ function isBuiltin(id) {
157
+ if (process.versions.deno && id.startsWith(NPM_BUILTIN_NAMESPACE))
158
+ return true;
159
+ if (process.versions.bun && id.startsWith(BUN_BUILTIN_NAMESPACE))
160
+ return true;
161
+ return isNodeBuiltin(id);
162
+ }
163
+ function isNodeBuiltin(id) {
164
+ if (id.startsWith(NODE_BUILTIN_NAMESPACE))
165
+ return true;
166
+ return nodeBuiltins.includes(id);
167
+ }
168
+ export {
169
+ bundleRequire,
170
+ isBuiltin,
171
+ isFilePathESM,
172
+ isNodeBuiltin
173
+ };
@@ -0,0 +1,151 @@
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 chunkSplit_exports = {};
29
+ __export(chunkSplit_exports, {
30
+ addChunkSplitSupport: () => addChunkSplitSupport
31
+ });
32
+ module.exports = __toCommonJS(chunkSplit_exports);
33
+ var import_node_assert = __toESM(require("node:assert"));
34
+ var import_constants = require("../constants.cjs");
35
+ var import_utils = require("../utils.cjs");
36
+ function getForceSplittingGroups(forceSplitting) {
37
+ const cacheGroups = {};
38
+ const pairs = Array.isArray(forceSplitting) ? forceSplitting.map((regexp, index) => [`force-split-${index}`, regexp]) : Object.entries(forceSplitting);
39
+ for (const [key, regexp] of pairs) {
40
+ cacheGroups[key] = {
41
+ test: regexp,
42
+ name: key,
43
+ chunks: "all",
44
+ priority: 0,
45
+ // Ignore minimum size, minimum chunks and maximum requests and always create chunks.
46
+ enforce: true
47
+ };
48
+ }
49
+ return cacheGroups;
50
+ }
51
+ function splitByExperience(ctx) {
52
+ const { defaultConfig, forceSplittingGroups } = ctx;
53
+ const experienceCacheGroup = {};
54
+ const packageRegExps = {
55
+ axios: /node_modules[\\/]axios(-.+)?[\\/]/
56
+ };
57
+ packageRegExps.polyfill = /node_modules[\\/](?:tslib|core-js|@swc[\\/]helpers)[\\/]/;
58
+ for (const [name, test] of Object.entries(packageRegExps)) {
59
+ const key = `lib-${name}`;
60
+ experienceCacheGroup[key] = {
61
+ test,
62
+ priority: 0,
63
+ name: key
64
+ };
65
+ }
66
+ return {
67
+ ...defaultConfig,
68
+ // @ts-ignore
69
+ cacheGroups: {
70
+ ...defaultConfig.cacheGroups,
71
+ ...experienceCacheGroup,
72
+ ...forceSplittingGroups
73
+ }
74
+ };
75
+ }
76
+ function splitBySize(ctx) {
77
+ const { forceSplittingGroups, defaultConfig, chunkSplit } = ctx;
78
+ (0, import_node_assert.default)(chunkSplit.strategy === "split-by-size");
79
+ return {
80
+ ...defaultConfig,
81
+ minSize: chunkSplit.minSize ?? 0,
82
+ maxSize: chunkSplit.maxSize ?? Number.POSITIVE_INFINITY,
83
+ // @ts-ignore
84
+ cacheGroups: {
85
+ ...defaultConfig.cacheGroups,
86
+ ...forceSplittingGroups
87
+ }
88
+ };
89
+ }
90
+ function splitCustom(ctx) {
91
+ const { forceSplittingGroups, defaultConfig } = ctx;
92
+ return {
93
+ ...defaultConfig,
94
+ // @ts-ignore
95
+ cacheGroups: {
96
+ ...defaultConfig.cacheGroups,
97
+ ...forceSplittingGroups
98
+ }
99
+ };
100
+ }
101
+ function singleVendor(ctx) {
102
+ const { defaultConfig, forceSplittingGroups } = ctx;
103
+ const singleVendorCacheGroup = {
104
+ singleVendor: {
105
+ test: import_constants.NODE_MODULES_REGEX,
106
+ priority: 0,
107
+ chunks: "all",
108
+ name: "vendor",
109
+ enforce: true
110
+ }
111
+ };
112
+ return {
113
+ ...defaultConfig,
114
+ // @ts-ignore
115
+ cacheGroups: {
116
+ ...defaultConfig.cacheGroups,
117
+ ...singleVendorCacheGroup,
118
+ ...forceSplittingGroups
119
+ }
120
+ };
121
+ }
122
+ const SPLIT_STRATEGY_DISPATCHER = {
123
+ "split-by-experience": splitByExperience,
124
+ "split-by-size": splitBySize,
125
+ custom: splitCustom,
126
+ "single-vendor": singleVendor
127
+ };
128
+ const addChunkSplitSupport = ({
129
+ config,
130
+ unpackConfig
131
+ }) => {
132
+ const defaultConfig = {};
133
+ const { chunkSplit } = unpackConfig.performance || {};
134
+ if (chunkSplit?.strategy) {
135
+ let forceSplittingGroups = {};
136
+ if (chunkSplit?.forceSplitting) {
137
+ forceSplittingGroups = getForceSplittingGroups(chunkSplit.forceSplitting);
138
+ }
139
+ const splitChunksOptions = SPLIT_STRATEGY_DISPATCHER[chunkSplit.strategy]({
140
+ defaultConfig,
141
+ forceSplittingGroups,
142
+ chunkSplit
143
+ });
144
+ (0, import_utils.setValueByPath)(config, ["optimization", "splitChunks"], splitChunksOptions);
145
+ }
146
+ return config;
147
+ };
148
+ // Annotate the CommonJS export names for ESM import in node:
149
+ 0 && (module.exports = {
150
+ addChunkSplitSupport
151
+ });
@@ -0,0 +1,6 @@
1
+ import type { BundlerConfiguration, UnpackConfig } from '../types/index';
2
+ export declare const addChunkSplitSupport: ({ config, unpackConfig, }: {
3
+ config: BundlerConfiguration;
4
+ unpackConfig: UnpackConfig;
5
+ }) => BundlerConfiguration;
6
+ //# sourceMappingURL=chunkSplit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunkSplit.d.ts","sourceRoot":"","sources":["../../src/bundler-config/chunkSplit.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EAKpB,YAAY,EACb,MAAM,iBAAiB,CAAA;AAmIxB,eAAO,MAAM,oBAAoB,8BAG9B;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,oBAgBH,CAAA"}
@@ -0,0 +1,127 @@
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 assert from "node:assert";
11
+ import { NODE_MODULES_REGEX } from "../constants.js";
12
+ import { setValueByPath } from "../utils.js";
13
+ function getForceSplittingGroups(forceSplitting) {
14
+ const cacheGroups = {};
15
+ const pairs = Array.isArray(forceSplitting) ? forceSplitting.map((regexp, index) => [`force-split-${index}`, regexp]) : Object.entries(forceSplitting);
16
+ for (const [key, regexp] of pairs) {
17
+ cacheGroups[key] = {
18
+ test: regexp,
19
+ name: key,
20
+ chunks: "all",
21
+ priority: 0,
22
+ // Ignore minimum size, minimum chunks and maximum requests and always create chunks.
23
+ enforce: true
24
+ };
25
+ }
26
+ return cacheGroups;
27
+ }
28
+ function splitByExperience(ctx) {
29
+ const { defaultConfig, forceSplittingGroups } = ctx;
30
+ const experienceCacheGroup = {};
31
+ const packageRegExps = {
32
+ axios: /node_modules[\\/]axios(-.+)?[\\/]/
33
+ };
34
+ packageRegExps.polyfill = /node_modules[\\/](?:tslib|core-js|@swc[\\/]helpers)[\\/]/;
35
+ for (const [name, test] of Object.entries(packageRegExps)) {
36
+ const key = `lib-${name}`;
37
+ experienceCacheGroup[key] = {
38
+ test,
39
+ priority: 0,
40
+ name: key
41
+ };
42
+ }
43
+ return {
44
+ ...defaultConfig,
45
+ // @ts-ignore
46
+ cacheGroups: {
47
+ ...defaultConfig.cacheGroups,
48
+ ...experienceCacheGroup,
49
+ ...forceSplittingGroups
50
+ }
51
+ };
52
+ }
53
+ function splitBySize(ctx) {
54
+ const { forceSplittingGroups, defaultConfig, chunkSplit } = ctx;
55
+ assert(chunkSplit.strategy === "split-by-size");
56
+ return {
57
+ ...defaultConfig,
58
+ minSize: chunkSplit.minSize ?? 0,
59
+ maxSize: chunkSplit.maxSize ?? Number.POSITIVE_INFINITY,
60
+ // @ts-ignore
61
+ cacheGroups: {
62
+ ...defaultConfig.cacheGroups,
63
+ ...forceSplittingGroups
64
+ }
65
+ };
66
+ }
67
+ function splitCustom(ctx) {
68
+ const { forceSplittingGroups, defaultConfig } = ctx;
69
+ return {
70
+ ...defaultConfig,
71
+ // @ts-ignore
72
+ cacheGroups: {
73
+ ...defaultConfig.cacheGroups,
74
+ ...forceSplittingGroups
75
+ }
76
+ };
77
+ }
78
+ function singleVendor(ctx) {
79
+ const { defaultConfig, forceSplittingGroups } = ctx;
80
+ const singleVendorCacheGroup = {
81
+ singleVendor: {
82
+ test: NODE_MODULES_REGEX,
83
+ priority: 0,
84
+ chunks: "all",
85
+ name: "vendor",
86
+ enforce: true
87
+ }
88
+ };
89
+ return {
90
+ ...defaultConfig,
91
+ // @ts-ignore
92
+ cacheGroups: {
93
+ ...defaultConfig.cacheGroups,
94
+ ...singleVendorCacheGroup,
95
+ ...forceSplittingGroups
96
+ }
97
+ };
98
+ }
99
+ const SPLIT_STRATEGY_DISPATCHER = {
100
+ "split-by-experience": splitByExperience,
101
+ "split-by-size": splitBySize,
102
+ custom: splitCustom,
103
+ "single-vendor": singleVendor
104
+ };
105
+ const addChunkSplitSupport = ({
106
+ config,
107
+ unpackConfig
108
+ }) => {
109
+ const defaultConfig = {};
110
+ const { chunkSplit } = unpackConfig.performance || {};
111
+ if (chunkSplit?.strategy) {
112
+ let forceSplittingGroups = {};
113
+ if (chunkSplit?.forceSplitting) {
114
+ forceSplittingGroups = getForceSplittingGroups(chunkSplit.forceSplitting);
115
+ }
116
+ const splitChunksOptions = SPLIT_STRATEGY_DISPATCHER[chunkSplit.strategy]({
117
+ defaultConfig,
118
+ forceSplittingGroups,
119
+ chunkSplit
120
+ });
121
+ setValueByPath(config, ["optimization", "splitChunks"], splitChunksOptions);
122
+ }
123
+ return config;
124
+ };
125
+ export {
126
+ addChunkSplitSupport
127
+ };