@unpackjs/core 1.6.4 → 1.7.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 (40) hide show
  1. package/compiled/css-loader/index.js +46 -46
  2. package/compiled/less-loader/index.js +8 -8
  3. package/compiled/postcss-loader/index.js +11 -11
  4. package/compiled/sass-loader/index.js +8 -8
  5. package/dist/bundler-config/index.cjs +9 -6
  6. package/dist/bundler-config/index.d.ts.map +1 -1
  7. package/dist/bundler-config/index.js +12 -9
  8. package/dist/createUnpack.cjs +6 -3
  9. package/dist/createUnpack.d.ts.map +1 -1
  10. package/dist/createUnpack.js +7 -4
  11. package/dist/index.cjs +3 -0
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +2 -0
  15. package/dist/plugin-progress/rspack.cjs +3 -1
  16. package/dist/plugin-progress/rspack.d.ts.map +1 -1
  17. package/dist/plugin-progress/rspack.js +3 -1
  18. package/dist/plugin-progress/webpack.cjs +3 -1
  19. package/dist/plugin-progress/webpack.d.ts.map +1 -1
  20. package/dist/plugin-progress/webpack.js +3 -1
  21. package/dist/prebundleDeps.cjs +340 -0
  22. package/dist/prebundleDeps.d.ts +5 -0
  23. package/dist/prebundleDeps.d.ts.map +1 -0
  24. package/dist/prebundleDeps.js +324 -0
  25. package/dist/run/dev.cjs +22 -39
  26. package/dist/run/dev.d.ts +1 -1
  27. package/dist/run/dev.d.ts.map +1 -1
  28. package/dist/run/dev.js +23 -40
  29. package/dist/thread-loader/worker.js +1 -1
  30. package/dist/types/config.d.ts +29 -6
  31. package/dist/types/config.d.ts.map +1 -1
  32. package/dist/utils.cjs +2 -0
  33. package/dist/utils.d.ts +2 -0
  34. package/dist/utils.d.ts.map +1 -1
  35. package/dist/utils.js +1 -0
  36. package/package.json +5 -8
  37. package/compiled/chokidar/index.d.ts +0 -327
  38. package/compiled/chokidar/index.js +0 -1773
  39. package/compiled/chokidar/license +0 -21
  40. package/compiled/chokidar/package.json +0 -1
@@ -10,7 +10,7 @@ var __filename = /* @__PURE__ */ getFilename();
10
10
  import colors from "./colors.js";
11
11
  import { getNormalizedPluginsByHook } from "./plugin.js";
12
12
  import { bundlerBuild, bundlerDev } from "./run/index.js";
13
- import { isDev, isDevServer, isProd, mergeConfig, setDevServer, setNodeEnv } from "./utils.js";
13
+ import { isDevServer, isProd, mergeConfig, setDevServer, setNodeEnv } from "./utils.js";
14
14
  function createUnpack() {
15
15
  const resolveConfig = async (unpackConfig) => {
16
16
  const defaultConfig = {
@@ -22,7 +22,10 @@ function createUnpack() {
22
22
  sourceMap: isProd() ? false : "cheap-module-source-map",
23
23
  parallel: !isDevServer(),
24
24
  filenameHash: true,
25
- cache: isDev()
25
+ typeCheck: true
26
+ },
27
+ dev: {
28
+ lazyCompilation: true
26
29
  },
27
30
  server: {
28
31
  port: 3e3
@@ -50,7 +53,7 @@ function createUnpack() {
50
53
  build: async (unpackConfig) => {
51
54
  setNodeEnv("production");
52
55
  console.log(
53
- colors.rainbow(`unpack v${"1.6.4"}`),
56
+ colors.rainbow(`unpack v${"1.7.0"}`),
54
57
  colors.green("building for production...")
55
58
  );
56
59
  const config = await resolveConfig(unpackConfig);
@@ -66,7 +69,7 @@ function createUnpack() {
66
69
  watch: async (unpackConfig) => {
67
70
  setNodeEnv("development");
68
71
  console.log(
69
- colors.rainbow(`unpack v${"1.6.4"}`),
72
+ colors.rainbow(`unpack v${"1.7.0"}`),
70
73
  colors.green("building for development...")
71
74
  );
72
75
  const config = await resolveConfig(unpackConfig);
package/dist/index.cjs CHANGED
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var src_exports = {};
30
30
  __export(src_exports, {
31
+ HtmlPlugin: () => import_html_webpack_plugin.default,
31
32
  colors: () => import_colors.default
32
33
  });
33
34
  module.exports = __toCommonJS(src_exports);
@@ -38,8 +39,10 @@ __reExport(src_exports, require("./constants.cjs"), module.exports);
38
39
  __reExport(src_exports, require("./createUnpack.cjs"), module.exports);
39
40
  __reExport(src_exports, require("./config.cjs"), module.exports);
40
41
  var import_colors = __toESM(require("./colors.cjs"));
42
+ var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
41
43
  // Annotate the CommonJS export names for ESM import in node:
42
44
  0 && (module.exports = {
45
+ HtmlPlugin,
43
46
  colors,
44
47
  ...require("./logger.cjs"),
45
48
  ...require("./types/index.cjs"),
package/dist/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export * from './constants';
5
5
  export * from './createUnpack';
6
6
  export * from './config';
7
7
  export { default as colors } from './colors';
8
+ export { default as HtmlPlugin } from 'html-webpack-plugin';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -14,6 +14,8 @@ export * from "./constants.js";
14
14
  export * from "./createUnpack.js";
15
15
  export * from "./config.js";
16
16
  import { default as default2 } from "./colors.js";
17
+ import { default as default3 } from "html-webpack-plugin";
17
18
  export {
19
+ default3 as HtmlPlugin,
18
20
  default2 as colors
19
21
  };
@@ -63,7 +63,9 @@ class RspackPluginProgress extends import_core.rspack.ProgressPlugin {
63
63
  await (0, import_reporter.printFileSize)({ root: compiler.options.context, stats });
64
64
  console.log(import_colors.default.green(`✓ built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`));
65
65
  } else {
66
- import_logger.logger.ready(`built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`);
66
+ import_logger.logger.ready(
67
+ `built in ${(0, import_utils.prettyTime)(compileTime)} (${stats.compilation.modules.size} modules)`
68
+ );
67
69
  }
68
70
  }
69
71
  });
@@ -1 +1 @@
1
- {"version":3,"file":"rspack.d.ts","sourceRoot":"","sources":["../../src/plugin-progress/rspack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAGpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAK7C,qBAAa,oBAAqB,SAAQ,MAAM,CAAC,cAAc;IAC7D,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAY;IACxC,WAAW,cAAoB;;IAO/B,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAsBhC"}
1
+ {"version":3,"file":"rspack.d.ts","sourceRoot":"","sources":["../../src/plugin-progress/rspack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAGpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAK7C,qBAAa,oBAAqB,SAAQ,MAAM,CAAC,cAAc;IAC7D,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAY;IACxC,WAAW,cAAoB;;IAO/B,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAwBhC"}
@@ -40,7 +40,9 @@ class RspackPluginProgress extends rspack.ProgressPlugin {
40
40
  await printFileSize({ root: compiler.options.context, stats });
41
41
  console.log(colors.green(`✓ built in ${colors.bold(prettyTime(compileTime))}`));
42
42
  } else {
43
- logger.ready(`built in ${colors.bold(prettyTime(compileTime))}`);
43
+ logger.ready(
44
+ `built in ${prettyTime(compileTime)} (${stats.compilation.modules.size} modules)`
45
+ );
44
46
  }
45
47
  }
46
48
  });
@@ -73,7 +73,9 @@ class WebpackPluginProgress extends import_webpack.default.ProgressPlugin {
73
73
  await (0, import_reporter.printFileSize)({ root: compiler.options.context, stats });
74
74
  console.log(import_colors.default.green(`✓ built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`));
75
75
  } else {
76
- import_logger.logger.ready(`built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`);
76
+ import_logger.logger.ready(
77
+ `built in ${(0, import_utils.prettyTime)(compileTime)} (${stats.compilation.modules.size} modules)`
78
+ );
77
79
  }
78
80
  }
79
81
  });
@@ -1 +1 @@
1
- {"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../../src/plugin-progress/webpack.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAG7C,OAAO,OAAO,MAAM,SAAS,CAAA;AAG7B,qBAAa,qBAAsB,SAAQ,OAAO,CAAC,cAAc;IAC/D,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAY;IACxC,WAAW,cAAoB;;IAiB/B,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,GAAG,IAAI;CAsBxC"}
1
+ {"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../../src/plugin-progress/webpack.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAG7C,OAAO,OAAO,MAAM,SAAS,CAAA;AAG7B,qBAAa,qBAAsB,SAAQ,OAAO,CAAC,cAAc;IAC/D,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAY;IACxC,WAAW,cAAoB;;IAiB/B,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,GAAG,IAAI;CAwBxC"}
@@ -50,7 +50,9 @@ class WebpackPluginProgress extends webpack.ProgressPlugin {
50
50
  await printFileSize({ root: compiler.options.context, stats });
51
51
  console.log(colors.green(`✓ built in ${colors.bold(prettyTime(compileTime))}`));
52
52
  } else {
53
- logger.ready(`built in ${colors.bold(prettyTime(compileTime))}`);
53
+ logger.ready(
54
+ `built in ${prettyTime(compileTime)} (${stats.compilation.modules.size} modules)`
55
+ );
54
56
  }
55
57
  }
56
58
  });
@@ -0,0 +1,340 @@
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 prebundleDeps_exports = {};
29
+ __export(prebundleDeps_exports, {
30
+ prebundleDeps: () => prebundleDeps
31
+ });
32
+ module.exports = __toCommonJS(prebundleDeps_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_cors = __toESM(require("cors"));
37
+ var import_express = __toESM(require("express"));
38
+ var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
39
+ var import_tinyglobby = require("tinyglobby");
40
+ var import_colors = __toESM(require("./colors.cjs"));
41
+ var import_constants = require("./constants.cjs");
42
+ var import_logger = require("./logger.cjs");
43
+ var import_utils = require("./utils.cjs");
44
+ const app = (0, import_express.default)();
45
+ app.use((0, import_cors.default)());
46
+ const CACHE_DIR = "umd";
47
+ const externalAlias = {
48
+ react: "React",
49
+ "react-dom": "ReactDOM",
50
+ "react-router": "ReactRouter",
51
+ "react-router-dom": "ReactRouterDOM"
52
+ };
53
+ const count = {
54
+ total: 0,
55
+ bundled: 0
56
+ };
57
+ const failedDeps = [];
58
+ const noEntryDeps = [];
59
+ const updateProgress = () => {
60
+ (0, import_utils.logUpdate)(
61
+ `${import_colors.default.magenta(import_colors.default.bold("»"))} Optimizing dependencies (${count.bundled}/${count.total})`
62
+ );
63
+ if (count.total === count.bundled + failedDeps.length) {
64
+ console.log();
65
+ }
66
+ };
67
+ const getExternalLibraryName = (pkgName) => {
68
+ return externalAlias[pkgName] || pkgName;
69
+ };
70
+ const getExternalValue = (pkgName) => {
71
+ return `var window['${getExternalLibraryName(pkgName)}']`;
72
+ };
73
+ const bundleDep = ({
74
+ root,
75
+ name,
76
+ entry,
77
+ version
78
+ }) => {
79
+ return new Promise((resolve) => {
80
+ const outDir = import_node_path.default.resolve(root, import_constants.TEMP_DIR, CACHE_DIR, name, version);
81
+ const getResult = () => {
82
+ const assets = (0, import_tinyglobby.globSync)("**/index.{js,css}", {
83
+ cwd: outDir,
84
+ absolute: true
85
+ });
86
+ return {
87
+ name,
88
+ assets
89
+ };
90
+ };
91
+ if (import_node_fs.default.existsSync(outDir)) {
92
+ return resolve(getResult());
93
+ }
94
+ count.total++;
95
+ updateProgress();
96
+ const getSwcOptions = ({ tsx }) => {
97
+ return {
98
+ jsc: {
99
+ parser: {
100
+ tsx,
101
+ syntax: "typescript",
102
+ dynamicImport: true,
103
+ decorators: true
104
+ },
105
+ transform: {
106
+ react: {
107
+ runtime: "automatic"
108
+ }
109
+ }
110
+ }
111
+ };
112
+ };
113
+ const compiler = (0, import_core.rspack)({
114
+ entry: {
115
+ index: entry
116
+ },
117
+ context: root,
118
+ mode: "development",
119
+ output: {
120
+ clean: true,
121
+ path: outDir,
122
+ pathinfo: false,
123
+ library: {
124
+ name: getExternalLibraryName(name),
125
+ type: "umd",
126
+ umdNamedDefine: true
127
+ },
128
+ globalObject: "this"
129
+ },
130
+ devtool: "cheap-module-source-map",
131
+ module: {
132
+ rules: [
133
+ {
134
+ test: /\.(j|t)s$/,
135
+ loader: "builtin:swc-loader",
136
+ options: getSwcOptions({ tsx: false })
137
+ },
138
+ {
139
+ test: /\.(j|t)sx$/,
140
+ use: [
141
+ {
142
+ loader: "builtin:swc-loader",
143
+ options: getSwcOptions({ tsx: true })
144
+ }
145
+ ]
146
+ },
147
+ {
148
+ test: /\.less$/,
149
+ type: "css/auto",
150
+ use: [
151
+ {
152
+ loader: (0, import_utils.getCompiledPkgPath)("less-loader"),
153
+ options: {
154
+ lessOptions: {
155
+ javascriptEnabled: true
156
+ },
157
+ implementation: (0, import_utils.getUserDepPath)(root, "less")
158
+ }
159
+ }
160
+ ]
161
+ },
162
+ {
163
+ test: /\.s[ac]ss$/i,
164
+ type: "css/auto",
165
+ use: [
166
+ {
167
+ loader: (0, import_utils.getCompiledPkgPath)("sass-loader"),
168
+ options: {
169
+ api: "modern-compiler",
170
+ implementation: (0, import_utils.getUserDepPath)(root, ["sass-embedded", "sass"])
171
+ }
172
+ }
173
+ ]
174
+ }
175
+ ]
176
+ },
177
+ optimization: {
178
+ splitChunks: false
179
+ },
180
+ experiments: {
181
+ css: true
182
+ },
183
+ externals: {
184
+ react: getExternalValue("react"),
185
+ "react-dom": getExternalValue("react-dom"),
186
+ "react-router": getExternalValue("react-router"),
187
+ "react-router-dom": getExternalValue("react-router-dom")
188
+ }
189
+ });
190
+ compiler.run((_, stats) => {
191
+ if (stats?.hasErrors()) {
192
+ failedDeps.push(name);
193
+ import_node_fs.default.rmSync(outDir, { recursive: true, force: true });
194
+ } else {
195
+ count.bundled++;
196
+ }
197
+ updateProgress();
198
+ compiler.close(() => {
199
+ const res = getResult();
200
+ resolve(!failedDeps.includes(res.name) ? res : void 0);
201
+ });
202
+ });
203
+ });
204
+ };
205
+ const getExistExternals = (externals) => {
206
+ const existExternals = /* @__PURE__ */ new Set();
207
+ if (Array.isArray(externals)) {
208
+ externals.forEach((item) => {
209
+ if ((0, import_utils.isPlainObject)(item)) {
210
+ Object.keys(item).forEach((key) => existExternals.add(key));
211
+ }
212
+ });
213
+ } else if ((0, import_utils.isPlainObject)(externals)) {
214
+ Object.keys(externals).forEach((key) => existExternals.add(key));
215
+ }
216
+ return Array.from(existExternals);
217
+ };
218
+ const getPkgEntry = (packageJson) => {
219
+ if (packageJson.module)
220
+ return packageJson.module;
221
+ if (packageJson.exports) {
222
+ if ((0, import_utils.isString)(packageJson.exports))
223
+ return packageJson.exports;
224
+ const defaultExport = packageJson.exports["."];
225
+ if (defaultExport) {
226
+ if ((0, import_utils.isString)(defaultExport))
227
+ return defaultExport;
228
+ if ((0, import_utils.isString)(defaultExport.import))
229
+ return defaultExport.import;
230
+ if ((0, import_utils.isString)(defaultExport.browser))
231
+ return defaultExport.browser;
232
+ if ((0, import_utils.isString)(defaultExport.default))
233
+ return defaultExport.default;
234
+ }
235
+ }
236
+ if (packageJson.main)
237
+ return packageJson.main;
238
+ };
239
+ const prebundleDeps = async ({
240
+ unpackConfig
241
+ }) => {
242
+ const userOptions = (0, import_utils.isPlainObject)(unpackConfig.dev?.prebundle) ? unpackConfig.dev.prebundle : {};
243
+ const { root } = unpackConfig;
244
+ const packageJson = JSON.parse(import_node_fs.default.readFileSync(import_node_path.default.resolve(root, "package.json"), "utf-8"));
245
+ const existExternals = getExistExternals(unpackConfig.externals);
246
+ const shouldIncludeDeps = Object.keys(packageJson.dependencies).filter(
247
+ (pkgName) => !existExternals.includes(pkgName) && !userOptions.exclude?.includes(pkgName)
248
+ );
249
+ const needBundleDeps = shouldIncludeDeps.map((pkgName) => {
250
+ const packageJson2 = JSON.parse(
251
+ import_node_fs.default.readFileSync(import_node_path.default.resolve(root, "node_modules", pkgName, "package.json"), "utf-8")
252
+ );
253
+ const entry = getPkgEntry(packageJson2);
254
+ if (!entry) {
255
+ noEntryDeps.push(pkgName);
256
+ return;
257
+ }
258
+ return {
259
+ name: pkgName,
260
+ entry: import_node_path.default.resolve(root, "node_modules", pkgName, entry),
261
+ version: packageJson2.version
262
+ };
263
+ }).filter(Boolean);
264
+ if (noEntryDeps[0]) {
265
+ import_logger.logger.warn(`Could not find entry for "${import_colors.default.bold(noEntryDeps.join(", "))}"`);
266
+ }
267
+ const bundledDeps = await Promise.all(
268
+ needBundleDeps.map((depInfo) => bundleDep({ root, ...depInfo }))
269
+ );
270
+ if (failedDeps[0]) {
271
+ import_logger.logger.warn(`Something went wrong while optimizing "${import_colors.default.bold(failedDeps.join(", "))}"`);
272
+ }
273
+ const cachePath = import_node_path.default.resolve(root, import_constants.TEMP_DIR, CACHE_DIR);
274
+ app.use(`/${CACHE_DIR}`, import_express.default.static(cachePath));
275
+ const port = await (0, import_utils.getPort)(3200);
276
+ app.listen(port, () => {
277
+ });
278
+ const externals = {};
279
+ const jsAssets = [];
280
+ const cssAssets = [];
281
+ const preJsAssets = [];
282
+ const ipv4Interfaces = (0, import_utils.getIpv4Interfaces)();
283
+ bundledDeps.filter(Boolean).forEach((dep) => {
284
+ externals[dep.name] = getExternalValue(dep.name);
285
+ dep.assets.forEach((absPath) => {
286
+ const relativePath = import_node_path.default.relative(cachePath, absPath);
287
+ const preDeps = ["react", "react-dom", "react-router", "react-router-dom"];
288
+ const serverPath = `//${ipv4Interfaces[1].address}:${port}/${CACHE_DIR}/${relativePath}`;
289
+ switch (import_node_path.default.extname(relativePath)) {
290
+ case ".js":
291
+ if (preDeps.includes(dep.name)) {
292
+ preJsAssets.push({
293
+ path: serverPath,
294
+ order: preDeps.indexOf(dep.name)
295
+ });
296
+ } else {
297
+ jsAssets.push(serverPath);
298
+ }
299
+ break;
300
+ case ".css":
301
+ cssAssets.push(serverPath);
302
+ break;
303
+ default:
304
+ break;
305
+ }
306
+ });
307
+ });
308
+ unpackConfig.externals = Array.isArray(unpackConfig.externals) ? [externals, ...unpackConfig.externals] : { ...externals, ...unpackConfig.externals };
309
+ unpackConfig.plugins.push({
310
+ name: "unpack:prebundle",
311
+ bundlerConfig: (config) => {
312
+ const PLUGIN_NAME = "PluginInjectAssets";
313
+ config.plugins.push({
314
+ apply: (compiler) => {
315
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
316
+ import_html_webpack_plugin.default.getCompilationHooks(compilation).beforeAssetTagGeneration.tapPromise(
317
+ PLUGIN_NAME,
318
+ async (args) => {
319
+ args.assets.js.unshift(
320
+ ...[
321
+ ...preJsAssets.sort((a, b) => a.order - b.order).map((item) => item.path),
322
+ ...jsAssets
323
+ ]
324
+ );
325
+ args.assets.css.unshift(...cssAssets);
326
+ return args;
327
+ }
328
+ );
329
+ });
330
+ }
331
+ });
332
+ return config;
333
+ }
334
+ });
335
+ return unpackConfig;
336
+ };
337
+ // Annotate the CommonJS export names for ESM import in node:
338
+ 0 && (module.exports = {
339
+ prebundleDeps
340
+ });
@@ -0,0 +1,5 @@
1
+ import type { UnpackConfig } from './types';
2
+ export declare const prebundleDeps: ({ unpackConfig, }: {
3
+ unpackConfig: UnpackConfig;
4
+ }) => Promise<UnpackConfig>;
5
+ //# sourceMappingURL=prebundleDeps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prebundleDeps.d.ts","sourceRoot":"","sources":["../src/prebundleDeps.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAsN3C,eAAO,MAAM,aAAa,sBAEvB;IACD,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,OAAO,CAAC,YAAY,CA0GvB,CAAA"}