@umijs/bundler-utoopack 4.4.13-canary.20250910.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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/config.d.ts +32 -0
- package/dist/config.js +177 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +231 -0
- package/dist/types.d.ts +18 -0
- package/dist/types.js +17 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-present ChenCheng (sorrycc@gmail.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IOpts as IConfigOpts } from '@umijs/bundler-webpack';
|
|
2
|
+
import type { BundleOptions } from '@utoo/pack';
|
|
3
|
+
import type { IOpts } from './types';
|
|
4
|
+
export declare function getProdUtooPackConfig(opts: IOpts): Promise<BundleOptions>;
|
|
5
|
+
export declare type IDevOpts = {
|
|
6
|
+
afterMiddlewares?: any[];
|
|
7
|
+
beforeMiddlewares?: any[];
|
|
8
|
+
onDevCompileDone?: Function;
|
|
9
|
+
onProgress?: Function;
|
|
10
|
+
onMFSUProgress?: Function;
|
|
11
|
+
port?: number;
|
|
12
|
+
host?: string;
|
|
13
|
+
ip?: string;
|
|
14
|
+
babelPreset?: any;
|
|
15
|
+
chainWebpack?: Function;
|
|
16
|
+
modifyWebpackConfig?: Function;
|
|
17
|
+
beforeBabelPlugins?: any[];
|
|
18
|
+
beforeBabelPresets?: any[];
|
|
19
|
+
extraBabelPlugins?: any[];
|
|
20
|
+
extraBabelPresets?: any[];
|
|
21
|
+
cwd: string;
|
|
22
|
+
rootDir?: string;
|
|
23
|
+
config: Record<string, any>;
|
|
24
|
+
entry: Record<string, string>;
|
|
25
|
+
mfsuStrategy?: 'eager' | 'normal';
|
|
26
|
+
mfsuInclude?: string[];
|
|
27
|
+
srcCodeCache?: any;
|
|
28
|
+
startBuildWorker?: (deps: any[]) => Worker;
|
|
29
|
+
onBeforeMiddleware?: Function;
|
|
30
|
+
disableCopy?: boolean;
|
|
31
|
+
} & Pick<IConfigOpts, 'cache' | 'pkg'>;
|
|
32
|
+
export declare function getDevUtooPackConfig(opts: IDevOpts): Promise<BundleOptions>;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/config.ts
|
|
20
|
+
var config_exports = {};
|
|
21
|
+
__export(config_exports, {
|
|
22
|
+
getDevUtooPackConfig: () => getDevUtooPackConfig,
|
|
23
|
+
getProdUtooPackConfig: () => getProdUtooPackConfig
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(config_exports);
|
|
26
|
+
var import_bundler_webpack = require("@umijs/bundler-webpack");
|
|
27
|
+
var import_utils = require("@umijs/utils");
|
|
28
|
+
var import_pack = require("@utoo/pack");
|
|
29
|
+
function getModularizeImports(extraBabelPlugins) {
|
|
30
|
+
return extraBabelPlugins.filter((p) => /^import$|babel-plugin-import/.test(p[0])).reduce(
|
|
31
|
+
(acc, [_, v]) => {
|
|
32
|
+
const { libraryName, libraryDirectory, style, ...rest } = v;
|
|
33
|
+
if (Object.keys(rest).length > 0) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
`babel-plugin-import options ${Object.keys(
|
|
36
|
+
rest
|
|
37
|
+
)} is not supported in utoopack bundler`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (typeof style === "function") {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`babel-plugin-import style function is not supported in utoopack bundler`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
acc[libraryName] = {
|
|
46
|
+
transform: `${libraryName}/${libraryDirectory}/{{ kebabCase member }}`,
|
|
47
|
+
preventFullImport: false,
|
|
48
|
+
skipDefaultConversion: false,
|
|
49
|
+
style: typeof style === "boolean" ? "style" : style
|
|
50
|
+
};
|
|
51
|
+
return acc;
|
|
52
|
+
},
|
|
53
|
+
{}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
async function getProdUtooPackConfig(opts) {
|
|
57
|
+
const webpackConfig = await (0, import_bundler_webpack.getConfig)({
|
|
58
|
+
cwd: opts.cwd,
|
|
59
|
+
rootDir: opts.rootDir,
|
|
60
|
+
env: "production",
|
|
61
|
+
entry: opts.entry,
|
|
62
|
+
userConfig: opts.config,
|
|
63
|
+
analyze: process.env.ANALYZE,
|
|
64
|
+
babelPreset: opts.babelPreset,
|
|
65
|
+
extraBabelPlugins: [
|
|
66
|
+
...opts.beforeBabelPlugins || [],
|
|
67
|
+
...opts.extraBabelPlugins || []
|
|
68
|
+
],
|
|
69
|
+
extraBabelPresets: [
|
|
70
|
+
...opts.beforeBabelPresets || [],
|
|
71
|
+
...opts.extraBabelPresets || []
|
|
72
|
+
],
|
|
73
|
+
extraBabelIncludes: opts.config.extraBabelIncludes,
|
|
74
|
+
chainWebpack: opts.chainWebpack,
|
|
75
|
+
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
76
|
+
pkg: opts.pkg,
|
|
77
|
+
disableCopy: opts.disableCopy
|
|
78
|
+
});
|
|
79
|
+
let utooBundlerOpts = (0, import_pack.compatOptionsFromWebpack)({
|
|
80
|
+
...import_utils.lodash.omit(webpackConfig, ["target", "module"]),
|
|
81
|
+
compatMode: true
|
|
82
|
+
});
|
|
83
|
+
const extraBabelPlugins = [
|
|
84
|
+
...opts.extraBabelPlugins || [],
|
|
85
|
+
...opts.config.extraBabelPlugins || []
|
|
86
|
+
];
|
|
87
|
+
const modularizeImports = getModularizeImports(extraBabelPlugins);
|
|
88
|
+
utooBundlerOpts = {
|
|
89
|
+
...utooBundlerOpts,
|
|
90
|
+
config: {
|
|
91
|
+
...utooBundlerOpts.config,
|
|
92
|
+
output: {
|
|
93
|
+
...utooBundlerOpts.config.output,
|
|
94
|
+
// webpack config 没处理 clean 参数
|
|
95
|
+
clean: true
|
|
96
|
+
},
|
|
97
|
+
optimization: {
|
|
98
|
+
...utooBundlerOpts.config.optimization,
|
|
99
|
+
modularizeImports
|
|
100
|
+
},
|
|
101
|
+
styles: {
|
|
102
|
+
less: {
|
|
103
|
+
modifyVars: opts.config.theme,
|
|
104
|
+
javascriptEnabled: true,
|
|
105
|
+
...opts.config.lessLoader
|
|
106
|
+
},
|
|
107
|
+
sass: opts.config.sassLoader ?? void 0
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return utooBundlerOpts;
|
|
112
|
+
}
|
|
113
|
+
async function getDevUtooPackConfig(opts) {
|
|
114
|
+
let webpackConfig = await (0, import_bundler_webpack.getConfig)({
|
|
115
|
+
cwd: opts.cwd,
|
|
116
|
+
rootDir: opts.rootDir,
|
|
117
|
+
env: "development",
|
|
118
|
+
entry: opts.entry,
|
|
119
|
+
userConfig: opts.config,
|
|
120
|
+
babelPreset: opts.babelPreset,
|
|
121
|
+
extraBabelPlugins: [
|
|
122
|
+
...opts.beforeBabelPlugins || [],
|
|
123
|
+
...opts.extraBabelPlugins || []
|
|
124
|
+
],
|
|
125
|
+
extraBabelPresets: [
|
|
126
|
+
...opts.beforeBabelPresets || [],
|
|
127
|
+
...opts.extraBabelPresets || []
|
|
128
|
+
],
|
|
129
|
+
extraBabelIncludes: opts.config.extraBabelIncludes,
|
|
130
|
+
chainWebpack: opts.chainWebpack,
|
|
131
|
+
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
132
|
+
// TO avoild bundler webpack add extra entry.
|
|
133
|
+
hmr: false,
|
|
134
|
+
analyze: process.env.ANALYZE
|
|
135
|
+
});
|
|
136
|
+
let utooBundlerOpts = (0, import_pack.compatOptionsFromWebpack)({
|
|
137
|
+
...import_utils.lodash.omit(webpackConfig, ["target", "module"]),
|
|
138
|
+
compatMode: true
|
|
139
|
+
});
|
|
140
|
+
const extraBabelPlugins = [
|
|
141
|
+
...opts.extraBabelPlugins || [],
|
|
142
|
+
...opts.config.extraBabelPlugins || []
|
|
143
|
+
];
|
|
144
|
+
const modularizeImports = getModularizeImports(extraBabelPlugins);
|
|
145
|
+
utooBundlerOpts = {
|
|
146
|
+
...utooBundlerOpts,
|
|
147
|
+
config: {
|
|
148
|
+
...utooBundlerOpts.config,
|
|
149
|
+
output: {
|
|
150
|
+
...utooBundlerOpts.config.output,
|
|
151
|
+
clean: true
|
|
152
|
+
},
|
|
153
|
+
optimization: {
|
|
154
|
+
...utooBundlerOpts.config.optimization,
|
|
155
|
+
modularizeImports
|
|
156
|
+
},
|
|
157
|
+
styles: {
|
|
158
|
+
less: {
|
|
159
|
+
modifyVars: opts.config.theme,
|
|
160
|
+
javascriptEnabled: true,
|
|
161
|
+
...opts.config.lessLoader
|
|
162
|
+
},
|
|
163
|
+
sass: opts.config.sassLoader ?? void 0
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
watch: {
|
|
167
|
+
enable: true
|
|
168
|
+
},
|
|
169
|
+
dev: true
|
|
170
|
+
};
|
|
171
|
+
return utooBundlerOpts;
|
|
172
|
+
}
|
|
173
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
174
|
+
0 && (module.exports = {
|
|
175
|
+
getDevUtooPackConfig,
|
|
176
|
+
getProdUtooPackConfig
|
|
177
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { findRootDir } from '@utoo/pack';
|
|
2
|
+
import { IDevOpts } from './config';
|
|
3
|
+
import type { IOpts } from './types';
|
|
4
|
+
export declare function build(opts: IOpts): Promise<any>;
|
|
5
|
+
export declare function dev(opts: IDevOpts): Promise<any>;
|
|
6
|
+
export * from './config';
|
|
7
|
+
export { findRootDir };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
build: () => build,
|
|
34
|
+
dev: () => dev,
|
|
35
|
+
findRootDir: () => import_pack.findRootDir
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(src_exports);
|
|
38
|
+
var import_bundler_utils = require("@umijs/bundler-utils");
|
|
39
|
+
var import_express = __toESM(require("@umijs/bundler-utils/compiled/express"));
|
|
40
|
+
var import_http_proxy_middleware = require("@umijs/bundler-utils/compiled/http-proxy-middleware");
|
|
41
|
+
var import_utils = require("@umijs/utils");
|
|
42
|
+
var import_pack = require("@utoo/pack");
|
|
43
|
+
var import_fs = __toESM(require("fs"));
|
|
44
|
+
var import_http = __toESM(require("http"));
|
|
45
|
+
var import_path = __toESM(require("path"));
|
|
46
|
+
var import_config = require("./config");
|
|
47
|
+
__reExport(src_exports, require("./config"), module.exports);
|
|
48
|
+
async function build(opts) {
|
|
49
|
+
var _a;
|
|
50
|
+
const { cwd, onBuildComplete } = opts;
|
|
51
|
+
const utooPackConfig = await (0, import_config.getProdUtooPackConfig)(opts);
|
|
52
|
+
const rootDir = (0, import_pack.findRootDir)(cwd);
|
|
53
|
+
const { build: utooPackBuild } = require("@utoo/pack");
|
|
54
|
+
try {
|
|
55
|
+
await utooPackBuild(utooPackConfig, cwd, rootDir);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.error(e.message);
|
|
58
|
+
const err = new Error("Build with utoopack failed.");
|
|
59
|
+
err.stack = null;
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
const stats = JSON.parse(
|
|
63
|
+
import_fs.default.readFileSync(
|
|
64
|
+
import_path.default.join((_a = utooPackConfig.config.output) == null ? void 0 : _a.path, "stats.json"),
|
|
65
|
+
"utf-8"
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
stats.hasErrors = () => false;
|
|
69
|
+
stats.toJson = () => stats;
|
|
70
|
+
stats.toString = () => {
|
|
71
|
+
};
|
|
72
|
+
stats.compilation = {
|
|
73
|
+
...stats,
|
|
74
|
+
assets: stats.assets.reduce(
|
|
75
|
+
(acc, cur) => Object.assign(acc, { [cur.name]: cur }),
|
|
76
|
+
{}
|
|
77
|
+
)
|
|
78
|
+
};
|
|
79
|
+
await (onBuildComplete == null ? void 0 : onBuildComplete({
|
|
80
|
+
stats
|
|
81
|
+
}));
|
|
82
|
+
return stats;
|
|
83
|
+
}
|
|
84
|
+
async function dev(opts) {
|
|
85
|
+
const { cwd, onDevCompileDone } = opts;
|
|
86
|
+
if (!opts) {
|
|
87
|
+
throw new Error("opts should be supplied");
|
|
88
|
+
}
|
|
89
|
+
const utooPackConfig = await (0, import_config.getDevUtooPackConfig)(opts);
|
|
90
|
+
const rootDir = (0, import_pack.findRootDir)(cwd);
|
|
91
|
+
const app = (0, import_express.default)();
|
|
92
|
+
const cors = require("cors");
|
|
93
|
+
const proxy = require("express-http-proxy");
|
|
94
|
+
const port = opts.port || 8e3;
|
|
95
|
+
const utooServePort = port + 1;
|
|
96
|
+
process.env.UTOO_PACK_VERBOSE = "1";
|
|
97
|
+
app.use(
|
|
98
|
+
cors({
|
|
99
|
+
origin: true,
|
|
100
|
+
methods: ["GET", "HEAD", "PUT", "POST", "PATCH", "DELETE", "OPTIONS"],
|
|
101
|
+
credentials: true
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
app.use(require("compression")());
|
|
105
|
+
if (opts.onBeforeMiddleware) {
|
|
106
|
+
opts.onBeforeMiddleware(app);
|
|
107
|
+
}
|
|
108
|
+
(opts.beforeMiddlewares || []).forEach((m) => app.use(m));
|
|
109
|
+
const wsProxy = (0, import_http_proxy_middleware.createProxyMiddleware)({
|
|
110
|
+
target: `http://127.0.0.1:${utooServePort}`,
|
|
111
|
+
ws: true,
|
|
112
|
+
logLevel: "silent"
|
|
113
|
+
});
|
|
114
|
+
app.use("/turbopack-hmr", wsProxy);
|
|
115
|
+
if (opts.config.proxy) {
|
|
116
|
+
(0, import_bundler_utils.createProxy)(opts.config.proxy, app);
|
|
117
|
+
}
|
|
118
|
+
app.use(
|
|
119
|
+
proxy(`http://127.0.0.1:${utooServePort}`, {
|
|
120
|
+
proxyReqOptDecorator: function(proxyReqOpts) {
|
|
121
|
+
proxyReqOpts.agent = false;
|
|
122
|
+
return proxyReqOpts;
|
|
123
|
+
},
|
|
124
|
+
filter: function(req, _res) {
|
|
125
|
+
return req.method == "GET" || req.method == "HEAD";
|
|
126
|
+
},
|
|
127
|
+
skipToNextHandlerFilter: function(proxyRes) {
|
|
128
|
+
return proxyRes.statusCode !== 200 && proxyRes.statusCode !== 304;
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
|
+
(opts.afterMiddlewares || []).forEach((m) => {
|
|
133
|
+
if (m.toString().includes("{ compiler }")) {
|
|
134
|
+
app.use(m({}));
|
|
135
|
+
} else {
|
|
136
|
+
app.use(m);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
app.use(
|
|
140
|
+
require("connect-history-api-fallback")({
|
|
141
|
+
index: "/"
|
|
142
|
+
})
|
|
143
|
+
);
|
|
144
|
+
let server;
|
|
145
|
+
const httpsOpts = opts.config.https;
|
|
146
|
+
if (httpsOpts) {
|
|
147
|
+
httpsOpts.hosts || (httpsOpts.hosts = import_utils.lodash.uniq(
|
|
148
|
+
[
|
|
149
|
+
...httpsOpts.hosts || [],
|
|
150
|
+
// always add localhost, 127.0.0.1, ip and host
|
|
151
|
+
"127.0.0.1",
|
|
152
|
+
"localhost",
|
|
153
|
+
opts.ip,
|
|
154
|
+
opts.host !== "0.0.0.0" && opts.host
|
|
155
|
+
].filter(Boolean)
|
|
156
|
+
));
|
|
157
|
+
server = await (0, import_bundler_utils.createHttpsServer)(app, httpsOpts);
|
|
158
|
+
} else {
|
|
159
|
+
server = import_http.default.createServer(app);
|
|
160
|
+
}
|
|
161
|
+
server.listen(port, () => {
|
|
162
|
+
const protocol = opts.config.https ? "https:" : "http:";
|
|
163
|
+
const banner = getDevBanner(
|
|
164
|
+
protocol,
|
|
165
|
+
opts.host,
|
|
166
|
+
port,
|
|
167
|
+
opts.ip ?? "0.0.0.0"
|
|
168
|
+
);
|
|
169
|
+
console.log(banner);
|
|
170
|
+
});
|
|
171
|
+
if (wsProxy.upgrade) {
|
|
172
|
+
server.on("upgrade", wsProxy.upgrade);
|
|
173
|
+
}
|
|
174
|
+
const createStatsObject = () => {
|
|
175
|
+
var _a;
|
|
176
|
+
let stats;
|
|
177
|
+
try {
|
|
178
|
+
stats = JSON.parse(
|
|
179
|
+
import_fs.default.readFileSync(
|
|
180
|
+
import_path.default.join((_a = utooPackConfig.config.output) == null ? void 0 : _a.path, "stats.json"),
|
|
181
|
+
"utf-8"
|
|
182
|
+
)
|
|
183
|
+
);
|
|
184
|
+
} catch (e) {
|
|
185
|
+
throw new Error("Stats.json not found by utoopack dev");
|
|
186
|
+
}
|
|
187
|
+
stats.hasErrors = () => false;
|
|
188
|
+
stats.toJson = () => stats;
|
|
189
|
+
stats.toString = () => {
|
|
190
|
+
};
|
|
191
|
+
stats.compilation = {
|
|
192
|
+
...stats,
|
|
193
|
+
assets: stats.assets.reduce(
|
|
194
|
+
(acc, cur) => Object.assign(acc, { [cur.name]: cur }),
|
|
195
|
+
{}
|
|
196
|
+
)
|
|
197
|
+
};
|
|
198
|
+
return stats;
|
|
199
|
+
};
|
|
200
|
+
const { serve: utooPackServe } = require("@utoo/pack");
|
|
201
|
+
try {
|
|
202
|
+
await utooPackServe(utooPackConfig, cwd, rootDir, {
|
|
203
|
+
port: utooServePort,
|
|
204
|
+
hostname: opts.host
|
|
205
|
+
});
|
|
206
|
+
const stats = createStatsObject();
|
|
207
|
+
await (onDevCompileDone == null ? void 0 : onDevCompileDone({
|
|
208
|
+
stats
|
|
209
|
+
}));
|
|
210
|
+
return stats;
|
|
211
|
+
} catch (e) {
|
|
212
|
+
console.error(e.message);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function getDevBanner(protocol, host, port, ip) {
|
|
216
|
+
const hostStr = host === "0.0.0.0" ? "localhost" : host;
|
|
217
|
+
const messages = [];
|
|
218
|
+
messages.push(" App listening at:");
|
|
219
|
+
messages.push(
|
|
220
|
+
` - Local: ${import_utils.chalk.cyan(`${protocol}//${hostStr}:${port}`)}`
|
|
221
|
+
);
|
|
222
|
+
messages.push(` - Network: ${import_utils.chalk.cyan(`${protocol}//${ip}:${port}`)}`);
|
|
223
|
+
return messages.join("\n");
|
|
224
|
+
}
|
|
225
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
226
|
+
0 && (module.exports = {
|
|
227
|
+
build,
|
|
228
|
+
dev,
|
|
229
|
+
findRootDir,
|
|
230
|
+
...require("./config")
|
|
231
|
+
});
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IOpts as IConfigOpts } from '@umijs/bundler-webpack';
|
|
2
|
+
export declare type IOpts = {
|
|
3
|
+
cwd: string;
|
|
4
|
+
rootDir?: string;
|
|
5
|
+
entry: Record<string, string>;
|
|
6
|
+
config: Record<string, any>;
|
|
7
|
+
onBuildComplete?: Function;
|
|
8
|
+
babelPreset?: any;
|
|
9
|
+
chainWebpack?: Function;
|
|
10
|
+
modifyWebpackConfig?: Function;
|
|
11
|
+
beforeBabelPlugins?: any[];
|
|
12
|
+
beforeBabelPresets?: any[];
|
|
13
|
+
extraBabelPlugins?: any[];
|
|
14
|
+
extraBabelPresets?: any[];
|
|
15
|
+
clean?: boolean;
|
|
16
|
+
watch?: boolean;
|
|
17
|
+
disableCopy?: boolean;
|
|
18
|
+
} & Pick<IConfigOpts, 'cache' | 'pkg'>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@umijs/bundler-utoopack",
|
|
3
|
+
"version": "4.4.13-canary.20250910.1",
|
|
4
|
+
"description": "@umijs/bundler-utoopack",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@umijs/bundler-utils": "4.4.13-canary.20250910.1",
|
|
12
|
+
"@utoo/pack": "0.0.1-alpha.46",
|
|
13
|
+
"compression": "^1.7.4",
|
|
14
|
+
"connect-history-api-fallback": "^2.0.0",
|
|
15
|
+
"cors": "^2.8.5",
|
|
16
|
+
"express": "^4.18.2",
|
|
17
|
+
"express-http-proxy": "^2.1.1",
|
|
18
|
+
"find-up": "5.0.0",
|
|
19
|
+
"@umijs/bundler-webpack": "4.4.13-canary.20250910.1"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"father": "4.1.5"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "father build",
|
|
29
|
+
"build:deps": "umi-scripts bundleDeps",
|
|
30
|
+
"dev": "father dev"
|
|
31
|
+
}
|
|
32
|
+
}
|