@umijs/bundler-utoopack 4.0.0-canary.20251113.1 → 4.0.0-canary.20251120.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 +39 -7
- package/package.json +3 -3
package/dist/config.js
CHANGED
|
@@ -55,6 +55,7 @@ function getModularizeImports(extraBabelPlugins) {
|
|
|
55
55
|
libraryDirectory,
|
|
56
56
|
style,
|
|
57
57
|
camel2DashComponentName,
|
|
58
|
+
transformToDefaultImport,
|
|
58
59
|
...rest
|
|
59
60
|
} = v;
|
|
60
61
|
if (Object.keys(rest).length > 0) {
|
|
@@ -73,10 +74,11 @@ function getModularizeImports(extraBabelPlugins) {
|
|
|
73
74
|
if (camel2DashComponentName === false) {
|
|
74
75
|
transformRule = "{{ member }}";
|
|
75
76
|
}
|
|
77
|
+
const skipDefaultConversion = typeof transformToDefaultImport === "undefined" ? false : !Boolean(transformToDefaultImport);
|
|
76
78
|
acc[libraryName] = {
|
|
77
79
|
transform: `${libraryName}/${libraryDirectory}/${transformRule}`,
|
|
78
80
|
preventFullImport: false,
|
|
79
|
-
skipDefaultConversion
|
|
81
|
+
skipDefaultConversion,
|
|
80
82
|
style: typeof style === "boolean" ? "style" : style
|
|
81
83
|
};
|
|
82
84
|
return acc;
|
|
@@ -95,6 +97,26 @@ function getNormalizedAlias(alias, rootDir) {
|
|
|
95
97
|
newAlias[`${rootDir}/*`] = `${rootDir}/*`;
|
|
96
98
|
return newAlias;
|
|
97
99
|
}
|
|
100
|
+
function getNormalizedExternals(externals) {
|
|
101
|
+
return Object.entries(externals || {}).reduce(
|
|
102
|
+
(ret, [k, v]) => {
|
|
103
|
+
if (Array.isArray(v)) {
|
|
104
|
+
const [url, ...members] = v;
|
|
105
|
+
ret[k] = {
|
|
106
|
+
// ['antd', 'Button'] => `antd.Button`
|
|
107
|
+
root: members.join("."),
|
|
108
|
+
// `script https://example.com/lib/script.js` => `https://example.com/lib/script.js`
|
|
109
|
+
script: url.replace("script ", "")
|
|
110
|
+
};
|
|
111
|
+
} else if (typeof v === "string") {
|
|
112
|
+
ret[k] = v.replace(/^window(\s+|\.)/, "");
|
|
113
|
+
} else {
|
|
114
|
+
}
|
|
115
|
+
return ret;
|
|
116
|
+
},
|
|
117
|
+
{}
|
|
118
|
+
);
|
|
119
|
+
}
|
|
98
120
|
async function getProdUtooPackConfig(opts) {
|
|
99
121
|
var _a;
|
|
100
122
|
const webpackConfig = await (0, import_bundler_webpack.getConfig)({
|
|
@@ -120,7 +142,7 @@ async function getProdUtooPackConfig(opts) {
|
|
|
120
142
|
disableCopy: opts.disableCopy
|
|
121
143
|
});
|
|
122
144
|
let utooBundlerOpts = (0, import_pack.compatOptionsFromWebpack)({
|
|
123
|
-
...import_utils.lodash.omit(webpackConfig, ["target", "module"]),
|
|
145
|
+
...import_utils.lodash.omit(webpackConfig, ["target", "module", "externals"]),
|
|
124
146
|
compatMode: true
|
|
125
147
|
});
|
|
126
148
|
const extraBabelPlugins = [
|
|
@@ -129,7 +151,11 @@ async function getProdUtooPackConfig(opts) {
|
|
|
129
151
|
];
|
|
130
152
|
const modularizeImports = getModularizeImports(extraBabelPlugins);
|
|
131
153
|
const processEnvForUtoopack = convertProcessEnvForUtoopack(webpackConfig);
|
|
132
|
-
const {
|
|
154
|
+
const {
|
|
155
|
+
publicPath,
|
|
156
|
+
runtimePublicPath,
|
|
157
|
+
externals: userExternals
|
|
158
|
+
} = opts.config;
|
|
133
159
|
utooBundlerOpts = {
|
|
134
160
|
...utooBundlerOpts,
|
|
135
161
|
config: import_utils.lodash.merge(
|
|
@@ -161,7 +187,8 @@ async function getProdUtooPackConfig(opts) {
|
|
|
161
187
|
define: {
|
|
162
188
|
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
163
189
|
},
|
|
164
|
-
nodePolyfill: true
|
|
190
|
+
nodePolyfill: true,
|
|
191
|
+
externals: getNormalizedExternals(userExternals)
|
|
165
192
|
},
|
|
166
193
|
opts.config.utoopack || {}
|
|
167
194
|
)
|
|
@@ -193,7 +220,7 @@ async function getDevUtooPackConfig(opts) {
|
|
|
193
220
|
analyze: process.env.ANALYZE
|
|
194
221
|
});
|
|
195
222
|
let utooBundlerOpts = (0, import_pack.compatOptionsFromWebpack)({
|
|
196
|
-
...import_utils.lodash.omit(webpackConfig, ["target", "module"]),
|
|
223
|
+
...import_utils.lodash.omit(webpackConfig, ["target", "module", "externals"]),
|
|
197
224
|
compatMode: true
|
|
198
225
|
});
|
|
199
226
|
const extraBabelPlugins = [
|
|
@@ -202,7 +229,11 @@ async function getDevUtooPackConfig(opts) {
|
|
|
202
229
|
];
|
|
203
230
|
const modularizeImports = getModularizeImports(extraBabelPlugins);
|
|
204
231
|
const processEnvForUtoopack = convertProcessEnvForUtoopack(webpackConfig);
|
|
205
|
-
const {
|
|
232
|
+
const {
|
|
233
|
+
publicPath,
|
|
234
|
+
runtimePublicPath,
|
|
235
|
+
externals: userExternals
|
|
236
|
+
} = opts.config;
|
|
206
237
|
utooBundlerOpts = {
|
|
207
238
|
...utooBundlerOpts,
|
|
208
239
|
config: import_utils.lodash.merge(
|
|
@@ -234,7 +265,8 @@ async function getDevUtooPackConfig(opts) {
|
|
|
234
265
|
define: {
|
|
235
266
|
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
236
267
|
},
|
|
237
|
-
nodePolyfill: true
|
|
268
|
+
nodePolyfill: true,
|
|
269
|
+
externals: getNormalizedExternals(userExternals)
|
|
238
270
|
},
|
|
239
271
|
opts.config.utoopack || {}
|
|
240
272
|
),
|
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.20251120.1",
|
|
4
4
|
"description": "@umijs/bundler-utoopack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,8 +13,8 @@
|
|
|
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.20251120.1",
|
|
17
|
+
"@umijs/bundler-webpack": "4.0.0-canary.20251120.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@utoo/pack": "^0.0.1-alpha.69",
|