@umijs/bundler-utoopack 4.6.17 → 4.6.19
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 +74 -10
- 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
|
|
@@ -106,12 +116,22 @@ function getNormalizedExternals(externals) {
|
|
|
106
116
|
(ret, [k, v]) => {
|
|
107
117
|
if (Array.isArray(v)) {
|
|
108
118
|
const [url, ...members] = v;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
+
}
|
|
115
135
|
} else if (typeof v === "string") {
|
|
116
136
|
ret[k] = v.replace(/^window(\s+|\.)/, "");
|
|
117
137
|
} else {
|
|
@@ -121,6 +141,40 @@ function getNormalizedExternals(externals) {
|
|
|
121
141
|
{}
|
|
122
142
|
);
|
|
123
143
|
}
|
|
144
|
+
function getSvgModuleRules(opts) {
|
|
145
|
+
const { svgr, svgo = {} } = 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
|
+
}
|
|
124
178
|
async function getProdUtooPackConfig(opts) {
|
|
125
179
|
var _a;
|
|
126
180
|
const webpackConfig = await (0, import_bundler_webpack.getConfig)({
|
|
@@ -159,7 +213,10 @@ async function getProdUtooPackConfig(opts) {
|
|
|
159
213
|
publicPath,
|
|
160
214
|
runtimePublicPath,
|
|
161
215
|
externals: userExternals,
|
|
162
|
-
copy = []
|
|
216
|
+
copy = [],
|
|
217
|
+
svgr,
|
|
218
|
+
svgo = {},
|
|
219
|
+
inlineLimit
|
|
163
220
|
} = opts.config;
|
|
164
221
|
utooBundlerOpts = {
|
|
165
222
|
...utooBundlerOpts,
|
|
@@ -194,7 +251,8 @@ async function getProdUtooPackConfig(opts) {
|
|
|
194
251
|
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
195
252
|
},
|
|
196
253
|
nodePolyfill: true,
|
|
197
|
-
externals: getNormalizedExternals(userExternals)
|
|
254
|
+
externals: getNormalizedExternals(userExternals),
|
|
255
|
+
...getSvgModuleRules({ svgr, svgo, inlineLimit })
|
|
198
256
|
},
|
|
199
257
|
opts.config.utoopack || {}
|
|
200
258
|
)
|
|
@@ -239,8 +297,13 @@ async function getDevUtooPackConfig(opts) {
|
|
|
239
297
|
publicPath,
|
|
240
298
|
runtimePublicPath,
|
|
241
299
|
externals: userExternals,
|
|
242
|
-
copy = []
|
|
300
|
+
copy = [],
|
|
301
|
+
svgr,
|
|
302
|
+
svgo = {},
|
|
303
|
+
inlineLimit
|
|
243
304
|
} = opts.config;
|
|
305
|
+
const normalizedExternals = getNormalizedExternals(userExternals);
|
|
306
|
+
debugger;
|
|
244
307
|
utooBundlerOpts = {
|
|
245
308
|
...utooBundlerOpts,
|
|
246
309
|
config: import_utils.lodash.merge(
|
|
@@ -274,7 +337,8 @@ async function getDevUtooPackConfig(opts) {
|
|
|
274
337
|
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
275
338
|
},
|
|
276
339
|
nodePolyfill: true,
|
|
277
|
-
externals:
|
|
340
|
+
externals: normalizedExternals,
|
|
341
|
+
...getSvgModuleRules({ svgr, svgo, inlineLimit })
|
|
278
342
|
},
|
|
279
343
|
opts.config.utoopack || {}
|
|
280
344
|
),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-utoopack",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.19",
|
|
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.6.
|
|
18
|
-
"@umijs/bundler-webpack": "4.6.
|
|
18
|
+
"@umijs/bundler-utils": "4.6.19",
|
|
19
|
+
"@umijs/bundler-webpack": "4.6.19"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"father": "4.1.5"
|