@umijs/bundler-utoopack 4.0.0-canary.20251110.1 → 4.0.0-canary.20251116.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 +36 -6
- package/package.json +5 -5
package/dist/config.js
CHANGED
|
@@ -95,6 +95,26 @@ function getNormalizedAlias(alias, rootDir) {
|
|
|
95
95
|
newAlias[`${rootDir}/*`] = `${rootDir}/*`;
|
|
96
96
|
return newAlias;
|
|
97
97
|
}
|
|
98
|
+
function getNormalizedExternals(externals) {
|
|
99
|
+
return Object.entries(externals || {}).reduce(
|
|
100
|
+
(ret, [k, v]) => {
|
|
101
|
+
if (Array.isArray(v)) {
|
|
102
|
+
const [url, ...members] = v;
|
|
103
|
+
ret[k] = {
|
|
104
|
+
// ['antd', 'Button'] => `antd.Button`
|
|
105
|
+
root: members.join("."),
|
|
106
|
+
// `script https://example.com/lib/script.js` => `https://example.com/lib/script.js`
|
|
107
|
+
script: url.replace("script ", "")
|
|
108
|
+
};
|
|
109
|
+
} else if (typeof v === "string") {
|
|
110
|
+
ret[k] = v.replace(/^window(\s+|\.)/, "");
|
|
111
|
+
} else {
|
|
112
|
+
}
|
|
113
|
+
return ret;
|
|
114
|
+
},
|
|
115
|
+
{}
|
|
116
|
+
);
|
|
117
|
+
}
|
|
98
118
|
async function getProdUtooPackConfig(opts) {
|
|
99
119
|
var _a;
|
|
100
120
|
const webpackConfig = await (0, import_bundler_webpack.getConfig)({
|
|
@@ -120,7 +140,7 @@ async function getProdUtooPackConfig(opts) {
|
|
|
120
140
|
disableCopy: opts.disableCopy
|
|
121
141
|
});
|
|
122
142
|
let utooBundlerOpts = (0, import_pack.compatOptionsFromWebpack)({
|
|
123
|
-
...import_utils.lodash.omit(webpackConfig, ["target", "module"]),
|
|
143
|
+
...import_utils.lodash.omit(webpackConfig, ["target", "module", "externals"]),
|
|
124
144
|
compatMode: true
|
|
125
145
|
});
|
|
126
146
|
const extraBabelPlugins = [
|
|
@@ -129,7 +149,11 @@ async function getProdUtooPackConfig(opts) {
|
|
|
129
149
|
];
|
|
130
150
|
const modularizeImports = getModularizeImports(extraBabelPlugins);
|
|
131
151
|
const processEnvForUtoopack = convertProcessEnvForUtoopack(webpackConfig);
|
|
132
|
-
const {
|
|
152
|
+
const {
|
|
153
|
+
publicPath,
|
|
154
|
+
runtimePublicPath,
|
|
155
|
+
externals: userExternals
|
|
156
|
+
} = opts.config;
|
|
133
157
|
utooBundlerOpts = {
|
|
134
158
|
...utooBundlerOpts,
|
|
135
159
|
config: import_utils.lodash.merge(
|
|
@@ -161,7 +185,8 @@ async function getProdUtooPackConfig(opts) {
|
|
|
161
185
|
define: {
|
|
162
186
|
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
163
187
|
},
|
|
164
|
-
nodePolyfill: true
|
|
188
|
+
nodePolyfill: true,
|
|
189
|
+
externals: getNormalizedExternals(userExternals)
|
|
165
190
|
},
|
|
166
191
|
opts.config.utoopack || {}
|
|
167
192
|
)
|
|
@@ -193,7 +218,7 @@ async function getDevUtooPackConfig(opts) {
|
|
|
193
218
|
analyze: process.env.ANALYZE
|
|
194
219
|
});
|
|
195
220
|
let utooBundlerOpts = (0, import_pack.compatOptionsFromWebpack)({
|
|
196
|
-
...import_utils.lodash.omit(webpackConfig, ["target", "module"]),
|
|
221
|
+
...import_utils.lodash.omit(webpackConfig, ["target", "module", "externals"]),
|
|
197
222
|
compatMode: true
|
|
198
223
|
});
|
|
199
224
|
const extraBabelPlugins = [
|
|
@@ -202,7 +227,11 @@ async function getDevUtooPackConfig(opts) {
|
|
|
202
227
|
];
|
|
203
228
|
const modularizeImports = getModularizeImports(extraBabelPlugins);
|
|
204
229
|
const processEnvForUtoopack = convertProcessEnvForUtoopack(webpackConfig);
|
|
205
|
-
const {
|
|
230
|
+
const {
|
|
231
|
+
publicPath,
|
|
232
|
+
runtimePublicPath,
|
|
233
|
+
externals: userExternals
|
|
234
|
+
} = opts.config;
|
|
206
235
|
utooBundlerOpts = {
|
|
207
236
|
...utooBundlerOpts,
|
|
208
237
|
config: import_utils.lodash.merge(
|
|
@@ -234,7 +263,8 @@ async function getDevUtooPackConfig(opts) {
|
|
|
234
263
|
define: {
|
|
235
264
|
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
236
265
|
},
|
|
237
|
-
nodePolyfill: true
|
|
266
|
+
nodePolyfill: true,
|
|
267
|
+
externals: getNormalizedExternals(userExternals)
|
|
238
268
|
},
|
|
239
269
|
opts.config.utoopack || {}
|
|
240
270
|
),
|
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.20251116.1",
|
|
4
4
|
"description": "@umijs/bundler-utoopack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"cors": "^2.8.5",
|
|
14
14
|
"express": "^4.18.2",
|
|
15
15
|
"express-http-proxy": "^2.1.1",
|
|
16
|
-
"@umijs/bundler-utils": "4.0.0-canary.
|
|
17
|
-
"@umijs/bundler-webpack": "4.0.0-canary.
|
|
16
|
+
"@umijs/bundler-utils": "4.0.0-canary.20251116.1",
|
|
17
|
+
"@umijs/bundler-webpack": "4.0.0-canary.20251116.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@utoo/pack": "^0.0.1-alpha.
|
|
20
|
+
"@utoo/pack": "^0.0.1-alpha.69",
|
|
21
21
|
"father": "4.1.5"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@utoo/pack": "^0.0.1-alpha.
|
|
24
|
+
"@utoo/pack": "^0.0.1-alpha.69"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|