@umijs/bundler-utoopack 4.0.0-canary.20251120.1 → 4.0.0-canary.20251209.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.
package/dist/config.js CHANGED
@@ -26,27 +26,7 @@ module.exports = __toCommonJS(config_exports);
26
26
  var import_bundler_webpack = require("@umijs/bundler-webpack");
27
27
  var import_utils = require("@umijs/utils");
28
28
  var import_pack = require("@utoo/pack");
29
- function convertProcessEnvForUtoopack(webpackConfig) {
30
- var _a;
31
- let processEnvForUtoopack = {};
32
- if (webpackConfig.plugins) {
33
- const definePlugin = webpackConfig.plugins.find(
34
- (plugin) => plugin.constructor.name === "DefinePlugin"
35
- );
36
- if ((_a = definePlugin == null ? void 0 : definePlugin.definitions) == null ? void 0 : _a["process.env"]) {
37
- for (const [key, value] of Object.entries(
38
- definePlugin.definitions["process.env"]
39
- )) {
40
- if (typeof value === "string" && value.startsWith('"') && value.endsWith('"')) {
41
- processEnvForUtoopack[key] = JSON.parse(value);
42
- } else {
43
- processEnvForUtoopack[key] = value;
44
- }
45
- }
46
- }
47
- }
48
- return processEnvForUtoopack;
49
- }
29
+ var import_path = require("path");
50
30
  function getModularizeImports(extraBabelPlugins) {
51
31
  return extraBabelPlugins.filter((p) => /^import$|babel-plugin-import/.test(p[0])).reduce(
52
32
  (acc, [_, v]) => {
@@ -88,11 +68,14 @@ function getModularizeImports(extraBabelPlugins) {
88
68
  }
89
69
  function getNormalizedAlias(alias, rootDir) {
90
70
  const newAlias = { ...alias };
91
- const keysToExpand = ["react", "react-dom", "@", "@@"];
92
- for (const key of keysToExpand) {
93
- if (newAlias[key]) {
94
- newAlias[`${key}/*`] = `${newAlias[key]}/*`;
71
+ for (const [key, value] of Object.entries(newAlias)) {
72
+ if (key.endsWith("/*") || value.endsWith("/*") || key.endsWith("/") || value.endsWith("/") || key.endsWith("$")) {
73
+ continue;
74
+ }
75
+ if ((0, import_path.extname)(value)) {
76
+ continue;
95
77
  }
78
+ newAlias[`${key}/*`] = `${value}/*`;
96
79
  }
97
80
  newAlias[`${rootDir}/*`] = `${rootDir}/*`;
98
81
  return newAlias;
@@ -150,11 +133,11 @@ async function getProdUtooPackConfig(opts) {
150
133
  ...opts.config.extraBabelPlugins || []
151
134
  ];
152
135
  const modularizeImports = getModularizeImports(extraBabelPlugins);
153
- const processEnvForUtoopack = convertProcessEnvForUtoopack(webpackConfig);
154
136
  const {
155
137
  publicPath,
156
138
  runtimePublicPath,
157
- externals: userExternals
139
+ externals: userExternals,
140
+ copy = []
158
141
  } = opts.config;
159
142
  utooBundlerOpts = {
160
143
  ...utooBundlerOpts,
@@ -163,7 +146,8 @@ async function getProdUtooPackConfig(opts) {
163
146
  {
164
147
  output: {
165
148
  clean: opts.clean,
166
- publicPath: runtimePublicPath ? "runtime" : publicPath || "/"
149
+ publicPath: runtimePublicPath ? "runtime" : publicPath || "/",
150
+ ...opts.disableCopy ? { copy: [] } : { copy: ["public"].concat(copy) }
167
151
  },
168
152
  optimization: {
169
153
  modularizeImports,
@@ -183,10 +167,6 @@ async function getProdUtooPackConfig(opts) {
183
167
  },
184
168
  sass: opts.config.sassLoader ?? void 0
185
169
  },
186
- // Override process.env for utoopack format
187
- define: {
188
- "process.env": JSON.stringify(processEnvForUtoopack)
189
- },
190
170
  nodePolyfill: true,
191
171
  externals: getNormalizedExternals(userExternals)
192
172
  },
@@ -228,11 +208,11 @@ async function getDevUtooPackConfig(opts) {
228
208
  ...opts.config.extraBabelPlugins || []
229
209
  ];
230
210
  const modularizeImports = getModularizeImports(extraBabelPlugins);
231
- const processEnvForUtoopack = convertProcessEnvForUtoopack(webpackConfig);
232
211
  const {
233
212
  publicPath,
234
213
  runtimePublicPath,
235
- externals: userExternals
214
+ externals: userExternals,
215
+ copy = []
236
216
  } = opts.config;
237
217
  utooBundlerOpts = {
238
218
  ...utooBundlerOpts,
@@ -242,7 +222,8 @@ async function getDevUtooPackConfig(opts) {
242
222
  output: {
243
223
  // utoopack 的 dev 需要默认清空产物目录
244
224
  clean: opts.clean === void 0 ? true : opts.clean,
245
- publicPath: runtimePublicPath ? "runtime" : publicPath || "/"
225
+ publicPath: runtimePublicPath ? "runtime" : publicPath || "/",
226
+ ...opts.disableCopy ? { copy: [] } : { copy: ["public"].concat(copy) }
246
227
  },
247
228
  resolve: {
248
229
  alias: getNormalizedAlias(
@@ -261,10 +242,6 @@ async function getDevUtooPackConfig(opts) {
261
242
  },
262
243
  sass: opts.config.sassLoader ?? void 0
263
244
  },
264
- // Override process.env for utoopack format
265
- define: {
266
- "process.env": JSON.stringify(processEnvForUtoopack)
267
- },
268
245
  nodePolyfill: true,
269
246
  externals: getNormalizedExternals(userExternals)
270
247
  },
package/dist/index.js CHANGED
@@ -186,7 +186,7 @@ async function dev(opts) {
186
186
  );
187
187
  stats = JSON.parse(import_fs.default.readFileSync(statsPath, "utf-8"));
188
188
  } catch (e) {
189
- throw new Error("Stats.json not found by utoopack dev");
189
+ throw new Error("File stats.json not found by utoopack dev");
190
190
  }
191
191
  stats.hasErrors = () => false;
192
192
  stats.toJson = () => stats;
@@ -204,7 +204,7 @@ async function dev(opts) {
204
204
  try {
205
205
  await utooPackServe(utooPackConfig, cwd, rootDir, {
206
206
  port: utooServePort,
207
- hostname: opts.host
207
+ hostname: "127.0.0.1"
208
208
  });
209
209
  const stats = createStatsObject();
210
210
  await (onDevCompileDone == null ? void 0 : onDevCompileDone({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/bundler-utoopack",
3
- "version": "4.0.0-canary.20251120.1",
3
+ "version": "4.0.0-canary.20251209.1",
4
4
  "description": "@umijs/bundler-utoopack",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,21 +8,18 @@
8
8
  "dist"
9
9
  ],
10
10
  "dependencies": {
11
+ "@utoo/pack": "1.0.5",
11
12
  "compression": "^1.7.4",
12
13
  "connect-history-api-fallback": "^2.0.0",
13
14
  "cors": "^2.8.5",
14
15
  "express": "^4.18.2",
15
16
  "express-http-proxy": "^2.1.1",
16
- "@umijs/bundler-utils": "4.0.0-canary.20251120.1",
17
- "@umijs/bundler-webpack": "4.0.0-canary.20251120.1"
17
+ "@umijs/bundler-utils": "4.0.0-canary.20251209.1",
18
+ "@umijs/bundler-webpack": "4.0.0-canary.20251209.1"
18
19
  },
19
20
  "devDependencies": {
20
- "@utoo/pack": "^0.0.1-alpha.69",
21
21
  "father": "4.1.5"
22
22
  },
23
- "peerDependencies": {
24
- "@utoo/pack": "^0.0.1-alpha.69"
25
- },
26
23
  "publishConfig": {
27
24
  "access": "public"
28
25
  },