@umijs/bundler-utoopack 4.6.38 → 4.6.40
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 +34 -32
- package/package.json +4 -4
package/dist/config.js
CHANGED
|
@@ -38,26 +38,15 @@ var import_utils = require("@umijs/utils");
|
|
|
38
38
|
var import_pack = require("@utoo/pack");
|
|
39
39
|
var import_fs = __toESM(require("fs"));
|
|
40
40
|
var import_path = require("path");
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
for (const [key, value] of Object.entries(
|
|
50
|
-
definePlugin.definitions["process.env"]
|
|
51
|
-
)) {
|
|
52
|
-
if (typeof value === "string" && value.startsWith('"') && value.endsWith('"')) {
|
|
53
|
-
processEnvForUtoopack[key] = JSON.parse(value);
|
|
54
|
-
} else {
|
|
55
|
-
processEnvForUtoopack[key] = value;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
41
|
+
function normalizeDefineValue(val) {
|
|
42
|
+
if (!import_utils.lodash.isPlainObject(val)) {
|
|
43
|
+
return JSON.stringify(val);
|
|
44
|
+
} else {
|
|
45
|
+
return Object.keys(val).reduce((obj, key) => {
|
|
46
|
+
obj[key] = normalizeDefineValue(val[key]);
|
|
47
|
+
return obj;
|
|
48
|
+
}, {});
|
|
59
49
|
}
|
|
60
|
-
return processEnvForUtoopack;
|
|
61
50
|
}
|
|
62
51
|
function getModularizeImports(extraBabelPlugins) {
|
|
63
52
|
return extraBabelPlugins.filter((p) => /^import$|babel-plugin-import/.test(p[0])).reduce(
|
|
@@ -232,7 +221,17 @@ async function getProdUtooPackConfig(opts) {
|
|
|
232
221
|
const emotion = extraBabelPlugins.some((p) => {
|
|
233
222
|
return p === "@emotion" || p === "@emotion/babel-plugin";
|
|
234
223
|
});
|
|
235
|
-
const
|
|
224
|
+
const define = {};
|
|
225
|
+
if (opts.config.define) {
|
|
226
|
+
for (const key of Object.keys(opts.config.define)) {
|
|
227
|
+
define[key] = normalizeDefineValue(opts.config.define[key]);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (process.env.SOCKET_SERVER) {
|
|
231
|
+
define["process.env.SOCKET_SERVER"] = normalizeDefineValue(
|
|
232
|
+
process.env.SOCKET_SERVER
|
|
233
|
+
);
|
|
234
|
+
}
|
|
236
235
|
const {
|
|
237
236
|
publicPath,
|
|
238
237
|
runtimePublicPath,
|
|
@@ -245,7 +244,7 @@ async function getProdUtooPackConfig(opts) {
|
|
|
245
244
|
utooBundlerOpts = {
|
|
246
245
|
...utooBundlerOpts,
|
|
247
246
|
config: import_utils.lodash.merge(
|
|
248
|
-
utooBundlerOpts.config,
|
|
247
|
+
import_utils.lodash.omit(utooBundlerOpts.config, ["define"]),
|
|
249
248
|
{
|
|
250
249
|
output: {
|
|
251
250
|
clean: opts.clean,
|
|
@@ -271,10 +270,7 @@ async function getProdUtooPackConfig(opts) {
|
|
|
271
270
|
sass: opts.config.sassLoader ?? void 0,
|
|
272
271
|
emotion
|
|
273
272
|
},
|
|
274
|
-
|
|
275
|
-
define: {
|
|
276
|
-
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
277
|
-
},
|
|
273
|
+
define,
|
|
278
274
|
nodePolyfill: true,
|
|
279
275
|
externals: getNormalizedExternals(userExternals),
|
|
280
276
|
...getSvgModuleRules({ svgr, svgo, inlineLimit })
|
|
@@ -320,7 +316,17 @@ async function getDevUtooPackConfig(opts) {
|
|
|
320
316
|
const emotion = extraBabelPlugins.some((p) => {
|
|
321
317
|
return p === "@emotion" || p === "@emotion/babel-plugin";
|
|
322
318
|
});
|
|
323
|
-
const
|
|
319
|
+
const define = {};
|
|
320
|
+
if (opts.config.define) {
|
|
321
|
+
for (const key of Object.keys(opts.config.define)) {
|
|
322
|
+
define[key] = normalizeDefineValue(opts.config.define[key]);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (process.env.SOCKET_SERVER) {
|
|
326
|
+
define["process.env.SOCKET_SERVER"] = normalizeDefineValue(
|
|
327
|
+
process.env.SOCKET_SERVER
|
|
328
|
+
);
|
|
329
|
+
}
|
|
324
330
|
const {
|
|
325
331
|
publicPath,
|
|
326
332
|
runtimePublicPath,
|
|
@@ -333,10 +339,9 @@ async function getDevUtooPackConfig(opts) {
|
|
|
333
339
|
utooBundlerOpts = {
|
|
334
340
|
...utooBundlerOpts,
|
|
335
341
|
config: import_utils.lodash.merge(
|
|
336
|
-
utooBundlerOpts.config,
|
|
342
|
+
import_utils.lodash.omit(utooBundlerOpts.config, ["define"]),
|
|
337
343
|
{
|
|
338
344
|
output: {
|
|
339
|
-
// utoopack 的 dev 需要默认清空产物目录
|
|
340
345
|
clean: opts.clean === void 0 ? true : opts.clean,
|
|
341
346
|
publicPath: runtimePublicPath ? "runtime" : publicPath || "/",
|
|
342
347
|
...opts.disableCopy ? { copy: [] } : { copy: ["public"].concat(copy) }
|
|
@@ -359,10 +364,7 @@ async function getDevUtooPackConfig(opts) {
|
|
|
359
364
|
sass: opts.config.sassLoader ?? void 0,
|
|
360
365
|
emotion
|
|
361
366
|
},
|
|
362
|
-
|
|
363
|
-
define: {
|
|
364
|
-
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
365
|
-
},
|
|
367
|
+
define,
|
|
366
368
|
// dev enable persistent cache by default
|
|
367
369
|
persistentCaching: true,
|
|
368
370
|
nodePolyfill: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-utoopack",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.40",
|
|
4
4
|
"description": "@umijs/bundler-utoopack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@utoo/pack": "1.3.
|
|
11
|
+
"@utoo/pack": "1.3.8",
|
|
12
12
|
"compression": "^1.7.4",
|
|
13
13
|
"connect-history-api-fallback": "^2.0.0",
|
|
14
14
|
"cors": "^2.8.5",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"postcss": "^8.4.21",
|
|
20
20
|
"sass": "1.54.0",
|
|
21
21
|
"sass-loader": "13.2.0",
|
|
22
|
-
"@umijs/bundler-
|
|
23
|
-
"@umijs/bundler-
|
|
22
|
+
"@umijs/bundler-webpack": "4.6.40",
|
|
23
|
+
"@umijs/bundler-utils": "4.6.40"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"father": "4.1.5"
|