@umijs/bundler-utoopack 4.6.18 → 4.6.20
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 +81 -10
- package/package.json +4 -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,47 @@ 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("@umijs/bundler-webpack/dist/loader/svgr"),
|
|
156
|
+
options: {
|
|
157
|
+
svgoConfig: {
|
|
158
|
+
plugins: [
|
|
159
|
+
{
|
|
160
|
+
name: "preset-default",
|
|
161
|
+
params: {
|
|
162
|
+
overrides: {
|
|
163
|
+
removeTitle: false
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"prefixIds"
|
|
168
|
+
],
|
|
169
|
+
...typeof svgo === "object" ? svgo : {}
|
|
170
|
+
},
|
|
171
|
+
...svgr,
|
|
172
|
+
svgo: !!svgo
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
loader: require.resolve("@umijs/bundler-webpack/compiled/url-loader")
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
as: "*.js"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
124
185
|
async function getProdUtooPackConfig(opts) {
|
|
125
186
|
var _a;
|
|
126
187
|
const webpackConfig = await (0, import_bundler_webpack.getConfig)({
|
|
@@ -159,7 +220,10 @@ async function getProdUtooPackConfig(opts) {
|
|
|
159
220
|
publicPath,
|
|
160
221
|
runtimePublicPath,
|
|
161
222
|
externals: userExternals,
|
|
162
|
-
copy = []
|
|
223
|
+
copy = [],
|
|
224
|
+
svgr,
|
|
225
|
+
svgo = {},
|
|
226
|
+
inlineLimit
|
|
163
227
|
} = opts.config;
|
|
164
228
|
utooBundlerOpts = {
|
|
165
229
|
...utooBundlerOpts,
|
|
@@ -194,7 +258,8 @@ async function getProdUtooPackConfig(opts) {
|
|
|
194
258
|
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
195
259
|
},
|
|
196
260
|
nodePolyfill: true,
|
|
197
|
-
externals: getNormalizedExternals(userExternals)
|
|
261
|
+
externals: getNormalizedExternals(userExternals),
|
|
262
|
+
...getSvgModuleRules({ svgr, svgo, inlineLimit })
|
|
198
263
|
},
|
|
199
264
|
opts.config.utoopack || {}
|
|
200
265
|
)
|
|
@@ -239,8 +304,13 @@ async function getDevUtooPackConfig(opts) {
|
|
|
239
304
|
publicPath,
|
|
240
305
|
runtimePublicPath,
|
|
241
306
|
externals: userExternals,
|
|
242
|
-
copy = []
|
|
307
|
+
copy = [],
|
|
308
|
+
svgr,
|
|
309
|
+
svgo = {},
|
|
310
|
+
inlineLimit
|
|
243
311
|
} = opts.config;
|
|
312
|
+
const normalizedExternals = getNormalizedExternals(userExternals);
|
|
313
|
+
debugger;
|
|
244
314
|
utooBundlerOpts = {
|
|
245
315
|
...utooBundlerOpts,
|
|
246
316
|
config: import_utils.lodash.merge(
|
|
@@ -274,7 +344,8 @@ async function getDevUtooPackConfig(opts) {
|
|
|
274
344
|
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
275
345
|
},
|
|
276
346
|
nodePolyfill: true,
|
|
277
|
-
externals:
|
|
347
|
+
externals: normalizedExternals,
|
|
348
|
+
...getSvgModuleRules({ svgr, svgo, inlineLimit })
|
|
278
349
|
},
|
|
279
350
|
opts.config.utoopack || {}
|
|
280
351
|
),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-utoopack",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.20",
|
|
4
4
|
"description": "@umijs/bundler-utoopack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@utoo/pack": "1.1.
|
|
11
|
+
"@utoo/pack": "1.1.18",
|
|
12
12
|
"compression": "^1.7.4",
|
|
13
13
|
"connect-history-api-fallback": "^2.0.0",
|
|
14
14
|
"cors": "^2.8.5",
|
|
15
15
|
"express": "^4.18.2",
|
|
16
16
|
"express-http-proxy": "^2.1.1",
|
|
17
|
-
"@umijs/bundler-
|
|
18
|
-
"@umijs/bundler-
|
|
17
|
+
"@umijs/bundler-webpack": "4.6.20",
|
|
18
|
+
"@umijs/bundler-utils": "4.6.20"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"father": "4.1.5"
|