@umijs/bundler-utoopack 4.4.13-canary.20250915.3 → 4.4.13-canary.20250917.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/README.md +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.js +42 -6
- package/dist/index.js +18 -15
- package/dist/types.d.ts +1 -1
- package/package.json +7 -5
package/README.md
CHANGED
package/dist/config.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare type IDevOpts = {
|
|
|
19
19
|
extraBabelPlugins?: any[];
|
|
20
20
|
extraBabelPresets?: any[];
|
|
21
21
|
cwd: string;
|
|
22
|
-
rootDir
|
|
22
|
+
rootDir: string;
|
|
23
23
|
config: Record<string, any>;
|
|
24
24
|
entry: Record<string, string>;
|
|
25
25
|
mfsuStrategy?: 'eager' | 'normal';
|
|
@@ -28,5 +28,6 @@ export declare type IDevOpts = {
|
|
|
28
28
|
startBuildWorker?: (deps: any[]) => Worker;
|
|
29
29
|
onBeforeMiddleware?: Function;
|
|
30
30
|
disableCopy?: boolean;
|
|
31
|
+
clean?: boolean;
|
|
31
32
|
} & Pick<IConfigOpts, 'cache' | 'pkg'>;
|
|
32
33
|
export declare function getDevUtooPackConfig(opts: IDevOpts): Promise<BundleOptions>;
|
package/dist/config.js
CHANGED
|
@@ -26,6 +26,27 @@ module.exports = __toCommonJS(config_exports);
|
|
|
26
26
|
var import_bundler_webpack = require("@umijs/bundler-webpack");
|
|
27
27
|
var import_utils = require("@umijs/utils");
|
|
28
28
|
var import_pack = require("@utoo/pack");
|
|
29
|
+
function convertProcessEnvForUtoopack(webpackConfig) {
|
|
30
|
+
var _a;
|
|
31
|
+
let processEnvForUtoopack = {};
|
|
32
|
+
if (webpackConfig.plugins) {
|
|
33
|
+
const definePlugin = webpackConfig.plugins.find(
|
|
34
|
+
(plugin) => plugin.constructor.name === "DefinePlugin"
|
|
35
|
+
);
|
|
36
|
+
if ((_a = definePlugin == null ? void 0 : definePlugin.definitions) == null ? void 0 : _a["process.env"]) {
|
|
37
|
+
for (const [key, value] of Object.entries(
|
|
38
|
+
definePlugin.definitions["process.env"]
|
|
39
|
+
)) {
|
|
40
|
+
if (typeof value === "string" && value.startsWith('"') && value.endsWith('"')) {
|
|
41
|
+
processEnvForUtoopack[key] = JSON.parse(value);
|
|
42
|
+
} else {
|
|
43
|
+
processEnvForUtoopack[key] = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return processEnvForUtoopack;
|
|
49
|
+
}
|
|
29
50
|
function getModularizeImports(extraBabelPlugins) {
|
|
30
51
|
return extraBabelPlugins.filter((p) => /^import$|babel-plugin-import/.test(p[0])).reduce(
|
|
31
52
|
(acc, [_, v]) => {
|
|
@@ -53,11 +74,12 @@ function getModularizeImports(extraBabelPlugins) {
|
|
|
53
74
|
{}
|
|
54
75
|
);
|
|
55
76
|
}
|
|
56
|
-
function getNormalizedAlias(alias) {
|
|
77
|
+
function getNormalizedAlias(alias, rootDir) {
|
|
57
78
|
const newAlias = { ...alias };
|
|
58
79
|
if (newAlias.react) {
|
|
59
80
|
newAlias["react/*"] = `${newAlias.react}/*`;
|
|
60
81
|
}
|
|
82
|
+
newAlias[`${rootDir}/*`] = `${rootDir}/*`;
|
|
61
83
|
return newAlias;
|
|
62
84
|
}
|
|
63
85
|
async function getProdUtooPackConfig(opts) {
|
|
@@ -93,14 +115,14 @@ async function getProdUtooPackConfig(opts) {
|
|
|
93
115
|
...opts.config.extraBabelPlugins || []
|
|
94
116
|
];
|
|
95
117
|
const modularizeImports = getModularizeImports(extraBabelPlugins);
|
|
118
|
+
const processEnvForUtoopack = convertProcessEnvForUtoopack(webpackConfig);
|
|
96
119
|
utooBundlerOpts = {
|
|
97
120
|
...utooBundlerOpts,
|
|
98
121
|
config: {
|
|
99
122
|
...utooBundlerOpts.config,
|
|
100
123
|
output: {
|
|
101
124
|
...utooBundlerOpts.config.output,
|
|
102
|
-
|
|
103
|
-
clean: true
|
|
125
|
+
clean: opts.clean
|
|
104
126
|
},
|
|
105
127
|
optimization: {
|
|
106
128
|
...utooBundlerOpts.config.optimization,
|
|
@@ -112,7 +134,8 @@ async function getProdUtooPackConfig(opts) {
|
|
|
112
134
|
resolve: {
|
|
113
135
|
...utooBundlerOpts.config.resolve,
|
|
114
136
|
alias: getNormalizedAlias(
|
|
115
|
-
(_a = utooBundlerOpts.config.resolve) == null ? void 0 : _a.alias
|
|
137
|
+
(_a = utooBundlerOpts.config.resolve) == null ? void 0 : _a.alias,
|
|
138
|
+
opts.rootDir
|
|
116
139
|
)
|
|
117
140
|
},
|
|
118
141
|
styles: {
|
|
@@ -122,6 +145,11 @@ async function getProdUtooPackConfig(opts) {
|
|
|
122
145
|
...opts.config.lessLoader
|
|
123
146
|
},
|
|
124
147
|
sass: opts.config.sassLoader ?? void 0
|
|
148
|
+
},
|
|
149
|
+
// Override process.env for utoopack format
|
|
150
|
+
define: {
|
|
151
|
+
...utooBundlerOpts.config.define,
|
|
152
|
+
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
125
153
|
}
|
|
126
154
|
}
|
|
127
155
|
};
|
|
@@ -160,18 +188,21 @@ async function getDevUtooPackConfig(opts) {
|
|
|
160
188
|
...opts.config.extraBabelPlugins || []
|
|
161
189
|
];
|
|
162
190
|
const modularizeImports = getModularizeImports(extraBabelPlugins);
|
|
191
|
+
const processEnvForUtoopack = convertProcessEnvForUtoopack(webpackConfig);
|
|
163
192
|
utooBundlerOpts = {
|
|
164
193
|
...utooBundlerOpts,
|
|
165
194
|
config: {
|
|
166
195
|
...utooBundlerOpts.config,
|
|
167
196
|
output: {
|
|
168
197
|
...utooBundlerOpts.config.output,
|
|
169
|
-
|
|
198
|
+
// utoopack 的 dev 需要默认清空产物目录
|
|
199
|
+
clean: opts.clean === void 0 ? true : opts.clean
|
|
170
200
|
},
|
|
171
201
|
resolve: {
|
|
172
202
|
...utooBundlerOpts.config.resolve,
|
|
173
203
|
alias: getNormalizedAlias(
|
|
174
|
-
(_a = utooBundlerOpts.config.resolve) == null ? void 0 : _a.alias
|
|
204
|
+
(_a = utooBundlerOpts.config.resolve) == null ? void 0 : _a.alias,
|
|
205
|
+
opts.rootDir
|
|
175
206
|
)
|
|
176
207
|
},
|
|
177
208
|
optimization: {
|
|
@@ -185,6 +216,11 @@ async function getDevUtooPackConfig(opts) {
|
|
|
185
216
|
...opts.config.lessLoader
|
|
186
217
|
},
|
|
187
218
|
sass: opts.config.sassLoader ?? void 0
|
|
219
|
+
},
|
|
220
|
+
// Override process.env for utoopack format
|
|
221
|
+
define: {
|
|
222
|
+
...utooBundlerOpts.config.define,
|
|
223
|
+
"process.env": JSON.stringify(processEnvForUtoopack)
|
|
188
224
|
}
|
|
189
225
|
},
|
|
190
226
|
watch: {
|
package/dist/index.js
CHANGED
|
@@ -48,9 +48,12 @@ __reExport(src_exports, require("./config"), module.exports);
|
|
|
48
48
|
async function build(opts) {
|
|
49
49
|
var _a;
|
|
50
50
|
const { cwd, onBuildComplete } = opts;
|
|
51
|
-
const utooPackConfig = await (0, import_config.getProdUtooPackConfig)(opts);
|
|
52
51
|
const { build: utooPackBuild, findRootDir: findRootDir2 } = require("@utoo/pack");
|
|
53
52
|
const rootDir = findRootDir2(cwd);
|
|
53
|
+
const utooPackConfig = await (0, import_config.getProdUtooPackConfig)({
|
|
54
|
+
...opts,
|
|
55
|
+
rootDir
|
|
56
|
+
});
|
|
54
57
|
try {
|
|
55
58
|
await utooPackBuild(utooPackConfig, cwd, rootDir);
|
|
56
59
|
} catch (e) {
|
|
@@ -59,12 +62,11 @@ async function build(opts) {
|
|
|
59
62
|
err.stack = null;
|
|
60
63
|
throw err;
|
|
61
64
|
}
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"utf-8"
|
|
66
|
-
)
|
|
65
|
+
const statsPath = import_path.default.join(
|
|
66
|
+
((_a = utooPackConfig.config.output) == null ? void 0 : _a.path) || "dist",
|
|
67
|
+
"stats.json"
|
|
67
68
|
);
|
|
69
|
+
const stats = JSON.parse(import_fs.default.readFileSync(statsPath, "utf-8"));
|
|
68
70
|
stats.hasErrors = () => false;
|
|
69
71
|
stats.toJson = () => stats;
|
|
70
72
|
stats.toString = () => {
|
|
@@ -86,13 +88,17 @@ async function dev(opts) {
|
|
|
86
88
|
if (!opts) {
|
|
87
89
|
throw new Error("opts should be supplied");
|
|
88
90
|
}
|
|
89
|
-
const
|
|
91
|
+
const { findRootDir: findRootDir2, serve: utooPackServe } = require("@utoo/pack");
|
|
92
|
+
const rootDir = findRootDir2(cwd);
|
|
93
|
+
const utooPackConfig = await (0, import_config.getDevUtooPackConfig)({
|
|
94
|
+
...opts,
|
|
95
|
+
rootDir
|
|
96
|
+
});
|
|
90
97
|
const app = (0, import_express.default)();
|
|
91
98
|
const cors = require("cors");
|
|
92
99
|
const proxy = require("express-http-proxy");
|
|
93
100
|
const port = opts.port || 8e3;
|
|
94
101
|
const utooServePort = port + 1;
|
|
95
|
-
process.env.UTOO_PACK_VERBOSE = "1";
|
|
96
102
|
app.use(
|
|
97
103
|
cors({
|
|
98
104
|
origin: true,
|
|
@@ -174,12 +180,11 @@ async function dev(opts) {
|
|
|
174
180
|
var _a;
|
|
175
181
|
let stats;
|
|
176
182
|
try {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
"utf-8"
|
|
181
|
-
)
|
|
183
|
+
const statsPath = import_path.default.join(
|
|
184
|
+
((_a = utooPackConfig.config.output) == null ? void 0 : _a.path) || "dist",
|
|
185
|
+
"stats.json"
|
|
182
186
|
);
|
|
187
|
+
stats = JSON.parse(import_fs.default.readFileSync(statsPath, "utf-8"));
|
|
183
188
|
} catch (e) {
|
|
184
189
|
throw new Error("Stats.json not found by utoopack dev");
|
|
185
190
|
}
|
|
@@ -196,8 +201,6 @@ async function dev(opts) {
|
|
|
196
201
|
};
|
|
197
202
|
return stats;
|
|
198
203
|
};
|
|
199
|
-
const { serve: utooPackServe, findRootDir: findRootDir2 } = require("@utoo/pack");
|
|
200
|
-
const rootDir = findRootDir2(cwd);
|
|
201
204
|
try {
|
|
202
205
|
await utooPackServe(utooPackConfig, cwd, rootDir, {
|
|
203
206
|
port: utooServePort,
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-utoopack",
|
|
3
|
-
"version": "4.4.13-canary.
|
|
3
|
+
"version": "4.4.13-canary.20250917.1",
|
|
4
4
|
"description": "@umijs/bundler-utoopack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,19 +8,21 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@umijs/bundler-utils": "4.4.13-canary.20250915.3",
|
|
12
|
-
"@utoo/pack": "0.0.1-alpha.47",
|
|
13
11
|
"compression": "^1.7.4",
|
|
14
12
|
"connect-history-api-fallback": "^2.0.0",
|
|
15
13
|
"cors": "^2.8.5",
|
|
16
14
|
"express": "^4.18.2",
|
|
17
15
|
"express-http-proxy": "^2.1.1",
|
|
18
|
-
"
|
|
19
|
-
"@umijs/bundler-webpack": "4.4.13-canary.
|
|
16
|
+
"@umijs/bundler-utils": "4.4.13-canary.20250917.1",
|
|
17
|
+
"@umijs/bundler-webpack": "4.4.13-canary.20250917.1"
|
|
20
18
|
},
|
|
21
19
|
"devDependencies": {
|
|
20
|
+
"@utoo/pack": "0.0.1-alpha.47",
|
|
22
21
|
"father": "4.1.5"
|
|
23
22
|
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@utoo/pack": "^0.0.1-alpha.47"
|
|
25
|
+
},
|
|
24
26
|
"publishConfig": {
|
|
25
27
|
"access": "public"
|
|
26
28
|
},
|