@umijs/bundler-utoopack 4.0.0-canary.20251209.1 → 4.0.0-canary.20260105.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 +107 -12
- package/dist/index.js +2 -1
- package/package.json +5 -4
package/dist/config.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
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
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/config.ts
|
|
@@ -27,6 +37,27 @@ var import_bundler_webpack = require("@umijs/bundler-webpack");
|
|
|
27
37
|
var import_utils = require("@umijs/utils");
|
|
28
38
|
var import_pack = require("@utoo/pack");
|
|
29
39
|
var import_path = require("path");
|
|
40
|
+
function convertProcessEnvForUtoopack(webpackConfig) {
|
|
41
|
+
var _a;
|
|
42
|
+
let processEnvForUtoopack = {};
|
|
43
|
+
if (webpackConfig.plugins) {
|
|
44
|
+
const definePlugin = webpackConfig.plugins.find(
|
|
45
|
+
(plugin) => plugin.constructor.name === "DefinePlugin"
|
|
46
|
+
);
|
|
47
|
+
if ((_a = definePlugin == null ? void 0 : definePlugin.definitions) == null ? void 0 : _a["process.env"]) {
|
|
48
|
+
for (const [key, value] of Object.entries(
|
|
49
|
+
definePlugin.definitions["process.env"]
|
|
50
|
+
)) {
|
|
51
|
+
if (typeof value === "string" && value.startsWith('"') && value.endsWith('"')) {
|
|
52
|
+
processEnvForUtoopack[key] = JSON.parse(value);
|
|
53
|
+
} else {
|
|
54
|
+
processEnvForUtoopack[key] = value;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return processEnvForUtoopack;
|
|
60
|
+
}
|
|
30
61
|
function getModularizeImports(extraBabelPlugins) {
|
|
31
62
|
return extraBabelPlugins.filter((p) => /^import$|babel-plugin-import/.test(p[0])).reduce(
|
|
32
63
|
(acc, [_, v]) => {
|
|
@@ -85,12 +116,22 @@ function getNormalizedExternals(externals) {
|
|
|
85
116
|
(ret, [k, v]) => {
|
|
86
117
|
if (Array.isArray(v)) {
|
|
87
118
|
const [url, ...members] = v;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
119
|
+
const containsScript = url.startsWith("script");
|
|
120
|
+
const script = url.replace("script ", "");
|
|
121
|
+
if (containsScript) {
|
|
122
|
+
ret[k] = {
|
|
123
|
+
// ['antd', 'Button'] => `antd.Button`
|
|
124
|
+
root: members.join("."),
|
|
125
|
+
type: "script",
|
|
126
|
+
// `script https://example.com/lib/script.js` => `https://example.com/lib/script.js`
|
|
127
|
+
script
|
|
128
|
+
};
|
|
129
|
+
} else {
|
|
130
|
+
ret[k] = {
|
|
131
|
+
root: members.join("."),
|
|
132
|
+
script
|
|
133
|
+
};
|
|
134
|
+
}
|
|
94
135
|
} else if (typeof v === "string") {
|
|
95
136
|
ret[k] = v.replace(/^window(\s+|\.)/, "");
|
|
96
137
|
} else {
|
|
@@ -100,6 +141,40 @@ function getNormalizedExternals(externals) {
|
|
|
100
141
|
{}
|
|
101
142
|
);
|
|
102
143
|
}
|
|
144
|
+
function getSvgModuleRules(opts) {
|
|
145
|
+
const { svgr, svgo = {}, inlineLimit } = opts;
|
|
146
|
+
if (!svgr) {
|
|
147
|
+
return {};
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
module: {
|
|
151
|
+
rules: {
|
|
152
|
+
"*.svg": {
|
|
153
|
+
loaders: [
|
|
154
|
+
{
|
|
155
|
+
loader: require.resolve("@svgr/webpack"),
|
|
156
|
+
condition: {
|
|
157
|
+
all: [
|
|
158
|
+
// Exclude node_modules (similar to excluding non-source files)
|
|
159
|
+
{ not: "foreign" },
|
|
160
|
+
// Match JavaScript/TypeScript files
|
|
161
|
+
{ path: /\.[jt]sx?$/ }
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
options: {
|
|
165
|
+
exportType: "named",
|
|
166
|
+
namedExport: "ReactComponent",
|
|
167
|
+
ref: true,
|
|
168
|
+
svgo: !!svgo
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
as: "*.js"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
103
178
|
async function getProdUtooPackConfig(opts) {
|
|
104
179
|
var _a;
|
|
105
180
|
const webpackConfig = await (0, import_bundler_webpack.getConfig)({
|
|
@@ -126,18 +201,22 @@ async function getProdUtooPackConfig(opts) {
|
|
|
126
201
|
});
|
|
127
202
|
let utooBundlerOpts = (0, import_pack.compatOptionsFromWebpack)({
|
|
128
203
|
...import_utils.lodash.omit(webpackConfig, ["target", "module", "externals"]),
|
|
129
|
-
|
|
204
|
+
webpackMode: true
|
|
130
205
|
});
|
|
131
206
|
const extraBabelPlugins = [
|
|
132
207
|
...opts.extraBabelPlugins || [],
|
|
133
208
|
...opts.config.extraBabelPlugins || []
|
|
134
209
|
];
|
|
135
210
|
const modularizeImports = getModularizeImports(extraBabelPlugins);
|
|
211
|
+
const processEnvForUtoopack = convertProcessEnvForUtoopack(webpackConfig);
|
|
136
212
|
const {
|
|
137
213
|
publicPath,
|
|
138
214
|
runtimePublicPath,
|
|
139
215
|
externals: userExternals,
|
|
140
|
-
copy = []
|
|
216
|
+
copy = [],
|
|
217
|
+
svgr,
|
|
218
|
+
svgo = {},
|
|
219
|
+
inlineLimit
|
|
141
220
|
} = opts.config;
|
|
142
221
|
utooBundlerOpts = {
|
|
143
222
|
...utooBundlerOpts,
|
|
@@ -167,8 +246,13 @@ async function getProdUtooPackConfig(opts) {
|
|
|
167
246
|
},
|
|
168
247
|
sass: opts.config.sassLoader ?? void 0
|
|
169
248
|
},
|
|
249
|
+
// Override process.env for utoopack format
|
|
250
|
+
define: {
|
|
251
|
+
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
252
|
+
},
|
|
170
253
|
nodePolyfill: true,
|
|
171
|
-
externals: getNormalizedExternals(userExternals)
|
|
254
|
+
externals: getNormalizedExternals(userExternals),
|
|
255
|
+
...getSvgModuleRules({ svgr, svgo, inlineLimit })
|
|
172
256
|
},
|
|
173
257
|
opts.config.utoopack || {}
|
|
174
258
|
)
|
|
@@ -201,19 +285,25 @@ async function getDevUtooPackConfig(opts) {
|
|
|
201
285
|
});
|
|
202
286
|
let utooBundlerOpts = (0, import_pack.compatOptionsFromWebpack)({
|
|
203
287
|
...import_utils.lodash.omit(webpackConfig, ["target", "module", "externals"]),
|
|
204
|
-
|
|
288
|
+
webpackMode: true
|
|
205
289
|
});
|
|
206
290
|
const extraBabelPlugins = [
|
|
207
291
|
...opts.extraBabelPlugins || [],
|
|
208
292
|
...opts.config.extraBabelPlugins || []
|
|
209
293
|
];
|
|
210
294
|
const modularizeImports = getModularizeImports(extraBabelPlugins);
|
|
295
|
+
const processEnvForUtoopack = convertProcessEnvForUtoopack(webpackConfig);
|
|
211
296
|
const {
|
|
212
297
|
publicPath,
|
|
213
298
|
runtimePublicPath,
|
|
214
299
|
externals: userExternals,
|
|
215
|
-
copy = []
|
|
300
|
+
copy = [],
|
|
301
|
+
svgr,
|
|
302
|
+
svgo = {},
|
|
303
|
+
inlineLimit
|
|
216
304
|
} = opts.config;
|
|
305
|
+
const normalizedExternals = getNormalizedExternals(userExternals);
|
|
306
|
+
debugger;
|
|
217
307
|
utooBundlerOpts = {
|
|
218
308
|
...utooBundlerOpts,
|
|
219
309
|
config: import_utils.lodash.merge(
|
|
@@ -242,8 +332,13 @@ async function getDevUtooPackConfig(opts) {
|
|
|
242
332
|
},
|
|
243
333
|
sass: opts.config.sassLoader ?? void 0
|
|
244
334
|
},
|
|
335
|
+
// Override process.env for utoopack format
|
|
336
|
+
define: {
|
|
337
|
+
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
338
|
+
},
|
|
245
339
|
nodePolyfill: true,
|
|
246
|
-
externals:
|
|
340
|
+
externals: normalizedExternals,
|
|
341
|
+
...getSvgModuleRules({ svgr, svgo, inlineLimit })
|
|
247
342
|
},
|
|
248
343
|
opts.config.utoopack || {}
|
|
249
344
|
),
|
package/dist/index.js
CHANGED
|
@@ -204,7 +204,8 @@ async function dev(opts) {
|
|
|
204
204
|
try {
|
|
205
205
|
await utooPackServe(utooPackConfig, cwd, rootDir, {
|
|
206
206
|
port: utooServePort,
|
|
207
|
-
hostname: "127.0.0.1"
|
|
207
|
+
hostname: "127.0.0.1",
|
|
208
|
+
logServerInfo: false
|
|
208
209
|
});
|
|
209
210
|
const stats = createStatsObject();
|
|
210
211
|
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.
|
|
3
|
+
"version": "4.0.0-canary.20260105.1",
|
|
4
4
|
"description": "@umijs/bundler-utoopack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,14 +8,15 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@
|
|
11
|
+
"@svgr/webpack": "^8.1.0",
|
|
12
|
+
"@utoo/pack": "1.1.17",
|
|
12
13
|
"compression": "^1.7.4",
|
|
13
14
|
"connect-history-api-fallback": "^2.0.0",
|
|
14
15
|
"cors": "^2.8.5",
|
|
15
16
|
"express": "^4.18.2",
|
|
16
17
|
"express-http-proxy": "^2.1.1",
|
|
17
|
-
"@umijs/bundler-utils": "4.0.0-canary.
|
|
18
|
-
"@umijs/bundler-webpack": "4.0.0-canary.
|
|
18
|
+
"@umijs/bundler-utils": "4.0.0-canary.20260105.1",
|
|
19
|
+
"@umijs/bundler-webpack": "4.0.0-canary.20260105.1"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"father": "4.1.5"
|