@yannick-z/modulo 0.3.2 → 0.3.4
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/131.js +108 -0
- package/dist/54.js +340 -0
- package/dist/839.js +437 -0
- package/dist/938.js +289 -0
- package/dist/bin/modulo.js +3 -81
- package/dist/index.js +1 -200
- package/package.json +2 -1
- package/src/packer/lib.ts +4 -3
- package/template/index.html +12 -0
- package/dist/183.js +0 -130
- package/dist/740.js +0 -793
- package/dist/882.js +0 -697
package/dist/938.js
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { cwd, exit } from "node:process";
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
|
+
import { debug_log, readFileSync, readdirSync, resolve, existsSync, statSync, picocolors, writeFileSync, join } from "./131.js";
|
|
4
|
+
function read_file(path, error_msg, throwError = false) {
|
|
5
|
+
try {
|
|
6
|
+
return readFileSync(path, "utf8");
|
|
7
|
+
} catch (error) {
|
|
8
|
+
const msg = error_msg || `文件无法访问或者不存在: ${path}`;
|
|
9
|
+
debug_log("read_file error", msg, error);
|
|
10
|
+
if (throwError) throw new Error(msg);
|
|
11
|
+
console.log(picocolors.red(msg));
|
|
12
|
+
return "";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function resolve_and_read(root, name) {
|
|
16
|
+
const fullpath = resolve(root, name);
|
|
17
|
+
debug_log(`resolve file: ${name}`, "result is:", fullpath);
|
|
18
|
+
return read_file(fullpath);
|
|
19
|
+
}
|
|
20
|
+
function get_directories(path) {
|
|
21
|
+
try {
|
|
22
|
+
if (!existsSync(path)) return [];
|
|
23
|
+
return readdirSync(path).filter((file)=>{
|
|
24
|
+
const fullPath = join(path, file);
|
|
25
|
+
return statSync(fullPath).isDirectory();
|
|
26
|
+
});
|
|
27
|
+
} catch (error) {
|
|
28
|
+
debug_log("get_directories error", path, error);
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function find_entry_file(dir, candidates, extensions = [
|
|
33
|
+
".ts",
|
|
34
|
+
".tsx",
|
|
35
|
+
".js",
|
|
36
|
+
".jsx",
|
|
37
|
+
".vue"
|
|
38
|
+
]) {
|
|
39
|
+
for (const name of candidates)for (const ext of extensions){
|
|
40
|
+
const filename = `${name}${ext}`;
|
|
41
|
+
const filepath = join(dir, filename);
|
|
42
|
+
if (existsSync(filepath) && statSync(filepath).isFile()) return filepath;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function exists(path) {
|
|
46
|
+
const isExist = existsSync(path);
|
|
47
|
+
debug_log(`check exists: ${path}`, isExist);
|
|
48
|
+
return isExist;
|
|
49
|
+
}
|
|
50
|
+
function jsonparse(input, defaultValue) {
|
|
51
|
+
try {
|
|
52
|
+
if (input) return JSON.parse(input);
|
|
53
|
+
return defaultValue;
|
|
54
|
+
} catch (e) {
|
|
55
|
+
console.error(picocolors.red(`JSON.parse failed\n${e}`));
|
|
56
|
+
return defaultValue;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function update_json_file(path, updater, createIfNotExist = false) {
|
|
60
|
+
try {
|
|
61
|
+
let data;
|
|
62
|
+
try {
|
|
63
|
+
const content = readFileSync(path, "utf-8");
|
|
64
|
+
const parsed = jsonparse(content);
|
|
65
|
+
if (parsed) data = parsed;
|
|
66
|
+
else if (createIfNotExist) data = {};
|
|
67
|
+
else {
|
|
68
|
+
console.error(picocolors.red(`Failed to parse JSON file: ${path}`));
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if ("ENOENT" === error.code && createIfNotExist) data = {};
|
|
73
|
+
else {
|
|
74
|
+
console.error(picocolors.red(`Failed to read file: ${path}`));
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const newData = updater(data);
|
|
79
|
+
writeFileSync(path, JSON.stringify(newData, null, 2) + "\n");
|
|
80
|
+
return true;
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.error(picocolors.red(`Failed to update JSON file: ${path}\n${e}`));
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const panic_alert = "! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !";
|
|
87
|
+
function PANIC_IF(status = false, msg = "SOMETHING'S WRONG", halt = true) {
|
|
88
|
+
if (status) {
|
|
89
|
+
console.log(picocolors.bgRed(picocolors.white(`\n${panic_alert}\n\n${msg}\n\n${panic_alert}`)), "\n");
|
|
90
|
+
halt && exit(1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function merge_user_config(target, input) {
|
|
94
|
+
for(const key in input){
|
|
95
|
+
const from = input[key];
|
|
96
|
+
const to = target[key];
|
|
97
|
+
if (typeof from === typeof to && key in target) if (Array.isArray(to)) {
|
|
98
|
+
PANIC_IF(!Array.isArray(from));
|
|
99
|
+
target[key] = [
|
|
100
|
+
...to,
|
|
101
|
+
...from
|
|
102
|
+
];
|
|
103
|
+
} else if ("object" == typeof to) merge_user_config(to, from);
|
|
104
|
+
else target[key] = from;
|
|
105
|
+
else {
|
|
106
|
+
target[key] = from;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const preset_alias = {
|
|
112
|
+
"@": "{input.src}"
|
|
113
|
+
};
|
|
114
|
+
const preset_dev_server_config = {
|
|
115
|
+
open: false,
|
|
116
|
+
port: 8080,
|
|
117
|
+
proxy: {}
|
|
118
|
+
};
|
|
119
|
+
const preset_input_dirs = {
|
|
120
|
+
src: "src",
|
|
121
|
+
pages: "pages",
|
|
122
|
+
modules: "modules"
|
|
123
|
+
};
|
|
124
|
+
const preset_output_dirs = {
|
|
125
|
+
dist: "dist",
|
|
126
|
+
pages: "",
|
|
127
|
+
modules: "modules",
|
|
128
|
+
filenameHash: true
|
|
129
|
+
};
|
|
130
|
+
const default_html_config = {
|
|
131
|
+
meta: {},
|
|
132
|
+
root: "",
|
|
133
|
+
tags: [],
|
|
134
|
+
template: "",
|
|
135
|
+
title: ""
|
|
136
|
+
};
|
|
137
|
+
const preset_ui_libs = {
|
|
138
|
+
react19: "19.2.4",
|
|
139
|
+
vue2: "2.7.16"
|
|
140
|
+
};
|
|
141
|
+
const preset_minify_config = {
|
|
142
|
+
js: true,
|
|
143
|
+
jsOptions: {
|
|
144
|
+
minimizerOptions: {
|
|
145
|
+
compress: {
|
|
146
|
+
dead_code: true,
|
|
147
|
+
defaults: false,
|
|
148
|
+
toplevel: true,
|
|
149
|
+
unused: true
|
|
150
|
+
},
|
|
151
|
+
format: {
|
|
152
|
+
comments: "some",
|
|
153
|
+
ecma: 2015,
|
|
154
|
+
preserve_annotations: true,
|
|
155
|
+
safari10: true,
|
|
156
|
+
semicolons: false
|
|
157
|
+
},
|
|
158
|
+
mangle: true,
|
|
159
|
+
minify: true
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const preset_url_config = {
|
|
164
|
+
base: "/",
|
|
165
|
+
cdn: ""
|
|
166
|
+
};
|
|
167
|
+
const preset_config = {
|
|
168
|
+
analyze: false,
|
|
169
|
+
define: {},
|
|
170
|
+
dev_server: preset_dev_server_config,
|
|
171
|
+
externals: {},
|
|
172
|
+
html: default_html_config,
|
|
173
|
+
input: preset_input_dirs,
|
|
174
|
+
minify: preset_minify_config,
|
|
175
|
+
output: preset_output_dirs,
|
|
176
|
+
ui_lib: preset_ui_libs,
|
|
177
|
+
url: preset_url_config,
|
|
178
|
+
alias: preset_alias,
|
|
179
|
+
webhost: true,
|
|
180
|
+
autoExternal: true,
|
|
181
|
+
externalsType: "importmap"
|
|
182
|
+
};
|
|
183
|
+
const config_root = cwd();
|
|
184
|
+
let packagejson = null;
|
|
185
|
+
function get_packagejson(customRoot = config_root) {
|
|
186
|
+
if (packagejson) {
|
|
187
|
+
if (customRoot !== config_root) {
|
|
188
|
+
const newPackageJson = jsonparse(resolve_and_read(customRoot, "package.json"));
|
|
189
|
+
PANIC_IF(!newPackageJson, "根目录下没有package.json");
|
|
190
|
+
PANIC_IF(!newPackageJson.name, "package.json缺少name字段");
|
|
191
|
+
return newPackageJson;
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
packagejson = jsonparse(resolve_and_read(customRoot, "package.json"));
|
|
195
|
+
PANIC_IF(!packagejson, "根目录下没有package.json");
|
|
196
|
+
PANIC_IF(!packagejson.name, "package.json缺少name字段");
|
|
197
|
+
}
|
|
198
|
+
return packagejson;
|
|
199
|
+
}
|
|
200
|
+
let global_config;
|
|
201
|
+
async function get_global_config(args) {
|
|
202
|
+
if (!global_config) {
|
|
203
|
+
let configPath = args.pack.config;
|
|
204
|
+
if (!configPath) {
|
|
205
|
+
const candidates = [
|
|
206
|
+
"modulo.config.ts",
|
|
207
|
+
"modulo.config.js",
|
|
208
|
+
"modulo.config.json"
|
|
209
|
+
];
|
|
210
|
+
for (const f of candidates){
|
|
211
|
+
const p = resolve(config_root, f);
|
|
212
|
+
if (existsSync(p)) {
|
|
213
|
+
configPath = p;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (!configPath) throw new Error("根目录下没有配置文件 (modulo.config.ts/js/json)");
|
|
219
|
+
const resolvedConfigPath = resolve(config_root, configPath);
|
|
220
|
+
let user_config;
|
|
221
|
+
try {
|
|
222
|
+
const fileUrl = pathToFileURL(resolvedConfigPath).href;
|
|
223
|
+
const mod = await import(fileUrl);
|
|
224
|
+
user_config = mod.default || mod;
|
|
225
|
+
} catch (e) {
|
|
226
|
+
console.error(`无法加载配置文件: ${resolvedConfigPath}`);
|
|
227
|
+
throw e;
|
|
228
|
+
}
|
|
229
|
+
PANIC_IF(!user_config, "根目录下没有配置文件");
|
|
230
|
+
debug_log("input user config", user_config);
|
|
231
|
+
if (user_config.extends) {
|
|
232
|
+
const extend_config_path = resolve(config_root, user_config.extends);
|
|
233
|
+
try {
|
|
234
|
+
const extend_fileUrl = pathToFileURL(extend_config_path).href;
|
|
235
|
+
const extend_mod = await import(extend_fileUrl);
|
|
236
|
+
const extend_config = extend_mod.default || extend_mod;
|
|
237
|
+
debug_log("extend config", extend_config);
|
|
238
|
+
merge_user_config(preset_config, extend_config);
|
|
239
|
+
} catch (e) {
|
|
240
|
+
console.error(`无法加载继承的配置文件: ${extend_config_path}`);
|
|
241
|
+
throw e;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
merge_user_config(preset_config, user_config);
|
|
245
|
+
const _config = preset_config;
|
|
246
|
+
const src = resolve(config_root, _config.input.src);
|
|
247
|
+
const input = {
|
|
248
|
+
modules: resolve(src, _config.input.modules),
|
|
249
|
+
pages: resolve(src, _config.input.pages),
|
|
250
|
+
src: src
|
|
251
|
+
};
|
|
252
|
+
const dist = resolve(config_root, _config.output.dist);
|
|
253
|
+
const output = {
|
|
254
|
+
..._config.output,
|
|
255
|
+
dist: dist,
|
|
256
|
+
modules: resolve(dist, _config.output.modules),
|
|
257
|
+
pages: resolve(dist, _config.output.pages)
|
|
258
|
+
};
|
|
259
|
+
const html = _config.html?.template ? {
|
|
260
|
+
..._config.html,
|
|
261
|
+
template: resolve(config_root, _config.html.template)
|
|
262
|
+
} : _config.html;
|
|
263
|
+
const define = Object.fromEntries(Object.entries({
|
|
264
|
+
..._config.define,
|
|
265
|
+
"import.meta.env.MOUNT_ID": _config.html.root
|
|
266
|
+
}).map(([k, v])=>[
|
|
267
|
+
k,
|
|
268
|
+
JSON.stringify(v)
|
|
269
|
+
]));
|
|
270
|
+
debug_log("当前模式", process.env.NODE_ENV);
|
|
271
|
+
const minify = true === _config.minify ? preset_minify_config : _config.minify;
|
|
272
|
+
const alias = Object.fromEntries(Object.entries(_config.alias).map(([k, v])=>[
|
|
273
|
+
k,
|
|
274
|
+
v.replace("{input.src}", input.src)
|
|
275
|
+
]));
|
|
276
|
+
global_config = {
|
|
277
|
+
..._config,
|
|
278
|
+
define,
|
|
279
|
+
html,
|
|
280
|
+
input,
|
|
281
|
+
minify,
|
|
282
|
+
output,
|
|
283
|
+
alias
|
|
284
|
+
};
|
|
285
|
+
debug_log("global config", global_config);
|
|
286
|
+
}
|
|
287
|
+
return global_config;
|
|
288
|
+
}
|
|
289
|
+
export { PANIC_IF, exists, fileURLToPath, find_entry_file, get_directories, get_global_config, get_packagejson, preset_alias, preset_config, update_json_file };
|
package/dist/bin/modulo.js
CHANGED
|
@@ -1,85 +1,7 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
6
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
7
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
11
|
-
return module.exports;
|
|
12
|
-
}
|
|
13
|
-
__webpack_require__.m = __webpack_modules__;
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.d = (exports, definition)=>{
|
|
16
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: definition[key]
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
})();
|
|
22
|
-
(()=>{
|
|
23
|
-
__webpack_require__.f = {};
|
|
24
|
-
__webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>{
|
|
25
|
-
__webpack_require__.f[key](chunkId, promises);
|
|
26
|
-
return promises;
|
|
27
|
-
}, []));
|
|
28
|
-
})();
|
|
29
|
-
(()=>{
|
|
30
|
-
__webpack_require__.u = (chunkId)=>"" + chunkId + ".js";
|
|
31
|
-
})();
|
|
32
|
-
(()=>{
|
|
33
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
34
|
-
})();
|
|
35
|
-
(()=>{
|
|
36
|
-
__webpack_require__.r = (exports)=>{
|
|
37
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
|
|
38
|
-
value: 'Module'
|
|
39
|
-
});
|
|
40
|
-
Object.defineProperty(exports, '__esModule', {
|
|
41
|
-
value: true
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
})();
|
|
45
|
-
(()=>{
|
|
46
|
-
var installedChunks = {
|
|
47
|
-
660: 0
|
|
48
|
-
};
|
|
49
|
-
var installChunk = (data)=>{
|
|
50
|
-
var __webpack_ids__ = data.__webpack_ids__;
|
|
51
|
-
var __webpack_modules__ = data.__webpack_modules__;
|
|
52
|
-
var __webpack_runtime__ = data.__webpack_runtime__;
|
|
53
|
-
var moduleId, chunkId, i = 0;
|
|
54
|
-
for(moduleId in __webpack_modules__)if (__webpack_require__.o(__webpack_modules__, moduleId)) __webpack_require__.m[moduleId] = __webpack_modules__[moduleId];
|
|
55
|
-
if (__webpack_runtime__) __webpack_runtime__(__webpack_require__);
|
|
56
|
-
for(; i < __webpack_ids__.length; i++){
|
|
57
|
-
chunkId = __webpack_ids__[i];
|
|
58
|
-
if (__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) installedChunks[chunkId][0]();
|
|
59
|
-
installedChunks[__webpack_ids__[i]] = 0;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
__webpack_require__.f.j = function(chunkId, promises) {
|
|
63
|
-
var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : void 0;
|
|
64
|
-
if (0 !== installedChunkData) if (installedChunkData) promises.push(installedChunkData[1]);
|
|
65
|
-
else {
|
|
66
|
-
var promise = import("../" + __webpack_require__.u(chunkId)).then(installChunk, (e)=>{
|
|
67
|
-
if (0 !== installedChunks[chunkId]) installedChunks[chunkId] = void 0;
|
|
68
|
-
throw e;
|
|
69
|
-
});
|
|
70
|
-
var promise = Promise.race([
|
|
71
|
-
promise,
|
|
72
|
-
new Promise((resolve)=>{
|
|
73
|
-
installedChunkData = installedChunks[chunkId] = [
|
|
74
|
-
resolve
|
|
75
|
-
];
|
|
76
|
-
})
|
|
77
|
-
]);
|
|
78
|
-
promises.push(installedChunkData[1] = promise);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
})();
|
|
82
|
-
__webpack_require__.e("183").then(__webpack_require__.bind(__webpack_require__, "./src/index.ts?fb01")).then((module)=>{
|
|
2
|
+
import("../131.js").then((mod)=>({
|
|
3
|
+
exec: mod.exec
|
|
4
|
+
})).then((module)=>{
|
|
83
5
|
try {
|
|
84
6
|
module.exec();
|
|
85
7
|
} catch (e) {
|
package/dist/index.js
CHANGED
|
@@ -1,200 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE_picocolors__ from "picocolors";
|
|
4
|
-
import { cac } from "cac";
|
|
5
|
-
var __webpack_modules__ = {
|
|
6
|
-
"./src/tools/log.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
-
n: ()=>debug_log,
|
|
9
|
-
v: ()=>logger
|
|
10
|
-
});
|
|
11
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
12
|
-
var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
|
|
13
|
-
var picocolors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("picocolors");
|
|
14
|
-
const logFile = node_path__WEBPACK_IMPORTED_MODULE_1__.join(process.cwd(), "modulo.debug.log");
|
|
15
|
-
let index = 0;
|
|
16
|
-
function debug_log(hint, ...params) {
|
|
17
|
-
const argv_debug = process.env.DEBUG || process.argv.includes("--debug");
|
|
18
|
-
const argv_verbose = process.argv.includes("--verbose") || process.argv.includes("-v");
|
|
19
|
-
if (!argv_debug && !argv_verbose) return;
|
|
20
|
-
const timestamp = new Date().toISOString();
|
|
21
|
-
const sn = String(index++).padStart(3, "0");
|
|
22
|
-
const logEntry = `--------------\n${sn} [${timestamp}] ${hint}\n${params.map((p)=>"object" == typeof p ? JSON.stringify(p, null, 2) : String(p)).join("\n")}\n---------------\n\n`;
|
|
23
|
-
if (argv_verbose) console.log(logEntry);
|
|
24
|
-
if (argv_debug) {
|
|
25
|
-
console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].blue(`\ndebug log ${sn}`));
|
|
26
|
-
node_fs__WEBPACK_IMPORTED_MODULE_0__.appendFileSync(logFile, logEntry);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const logger = {
|
|
30
|
-
info: (msg)=>console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].cyan(msg)),
|
|
31
|
-
success: (msg)=>console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].green(msg)),
|
|
32
|
-
warn: (msg)=>console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].yellow(msg)),
|
|
33
|
-
error: (msg)=>console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].red(msg)),
|
|
34
|
-
debug: (msg)=>{
|
|
35
|
-
if (process.env.DEBUG) console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].gray(`[DEBUG] ${msg}`));
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
"node:fs": function(module) {
|
|
40
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
41
|
-
},
|
|
42
|
-
"node:path": function(module) {
|
|
43
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__;
|
|
44
|
-
},
|
|
45
|
-
picocolors: function(module) {
|
|
46
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_picocolors__;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __webpack_module_cache__ = {};
|
|
50
|
-
function __webpack_require__(moduleId) {
|
|
51
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
52
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
53
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
54
|
-
exports: {}
|
|
55
|
-
};
|
|
56
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
57
|
-
return module.exports;
|
|
58
|
-
}
|
|
59
|
-
__webpack_require__.m = __webpack_modules__;
|
|
60
|
-
(()=>{
|
|
61
|
-
__webpack_require__.d = (exports, definition)=>{
|
|
62
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: definition[key]
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
})();
|
|
68
|
-
(()=>{
|
|
69
|
-
__webpack_require__.f = {};
|
|
70
|
-
__webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>{
|
|
71
|
-
__webpack_require__.f[key](chunkId, promises);
|
|
72
|
-
return promises;
|
|
73
|
-
}, []));
|
|
74
|
-
})();
|
|
75
|
-
(()=>{
|
|
76
|
-
__webpack_require__.u = (chunkId)=>"" + chunkId + ".js";
|
|
77
|
-
})();
|
|
78
|
-
(()=>{
|
|
79
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
80
|
-
})();
|
|
81
|
-
(()=>{
|
|
82
|
-
__webpack_require__.r = (exports)=>{
|
|
83
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
|
|
84
|
-
value: 'Module'
|
|
85
|
-
});
|
|
86
|
-
Object.defineProperty(exports, '__esModule', {
|
|
87
|
-
value: true
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
})();
|
|
91
|
-
(()=>{
|
|
92
|
-
var installedChunks = {
|
|
93
|
-
410: 0
|
|
94
|
-
};
|
|
95
|
-
var installChunk = (data)=>{
|
|
96
|
-
var __webpack_ids__ = data.__webpack_ids__;
|
|
97
|
-
var __webpack_modules__ = data.__webpack_modules__;
|
|
98
|
-
var __webpack_runtime__ = data.__webpack_runtime__;
|
|
99
|
-
var moduleId, chunkId, i = 0;
|
|
100
|
-
for(moduleId in __webpack_modules__)if (__webpack_require__.o(__webpack_modules__, moduleId)) __webpack_require__.m[moduleId] = __webpack_modules__[moduleId];
|
|
101
|
-
if (__webpack_runtime__) __webpack_runtime__(__webpack_require__);
|
|
102
|
-
for(; i < __webpack_ids__.length; i++){
|
|
103
|
-
chunkId = __webpack_ids__[i];
|
|
104
|
-
if (__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) installedChunks[chunkId][0]();
|
|
105
|
-
installedChunks[__webpack_ids__[i]] = 0;
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
__webpack_require__.f.j = function(chunkId, promises) {
|
|
109
|
-
var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : void 0;
|
|
110
|
-
if (0 !== installedChunkData) if (installedChunkData) promises.push(installedChunkData[1]);
|
|
111
|
-
else {
|
|
112
|
-
var promise = import("./" + __webpack_require__.u(chunkId)).then(installChunk, (e)=>{
|
|
113
|
-
if (0 !== installedChunks[chunkId]) installedChunks[chunkId] = void 0;
|
|
114
|
-
throw e;
|
|
115
|
-
});
|
|
116
|
-
var promise = Promise.race([
|
|
117
|
-
promise,
|
|
118
|
-
new Promise((resolve)=>{
|
|
119
|
-
installedChunkData = installedChunks[chunkId] = [
|
|
120
|
-
resolve
|
|
121
|
-
];
|
|
122
|
-
})
|
|
123
|
-
]);
|
|
124
|
-
promises.push(installedChunkData[1] = promise);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
})();
|
|
128
|
-
var log = __webpack_require__("./src/tools/log.ts");
|
|
129
|
-
var package_namespaceObject = {
|
|
130
|
-
rE: "0.3.2"
|
|
131
|
-
};
|
|
132
|
-
const cli = cac("modulo");
|
|
133
|
-
cli.command("init <target>", "Initialize modulo configuration or scripts").option("-f, --force", "Force overwrite existing files").option("--path <path>", "Specify the path to initialize").option("--preset <preset>", "Specify the preset to use").action((target, options)=>{
|
|
134
|
-
__webpack_require__.e("882").then(__webpack_require__.bind(__webpack_require__, "./src/cli/init.ts")).then(({ init_tool })=>{
|
|
135
|
-
init_tool({
|
|
136
|
-
cmd: "init",
|
|
137
|
-
target: target,
|
|
138
|
-
init: {
|
|
139
|
-
path: options.path,
|
|
140
|
-
force: options.force,
|
|
141
|
-
preset: options.preset
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
cli.command("build <target>", "Build the project for production").option("-c, --config <file>", "Use specified config file").option("-w, --watch", "Watch for changes").option("--env <env>", "Specify the environment (dev/prd)").action((target, options)=>{
|
|
147
|
-
__webpack_require__.e("740").then(__webpack_require__.bind(__webpack_require__, "./src/cli/pack-code.ts")).then(({ pack_code })=>{
|
|
148
|
-
pack_code({
|
|
149
|
-
cmd: "build",
|
|
150
|
-
target: target,
|
|
151
|
-
pack: {
|
|
152
|
-
config: options.config,
|
|
153
|
-
env: options.env || "prd",
|
|
154
|
-
watch: options.watch,
|
|
155
|
-
esm: true
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
cli.command("dev <target>", "Start development server").option("-c, --config <file>", "Use specified config file").option("--env <env>", "Specify the environment (dev/prd)").option("--debug", "Enable debug mode").action((target, options)=>{
|
|
161
|
-
if (options.debug) process.env.DEBUG = "true";
|
|
162
|
-
__webpack_require__.e("740").then(__webpack_require__.bind(__webpack_require__, "./src/cli/pack-code.ts")).then(({ pack_code })=>{
|
|
163
|
-
pack_code({
|
|
164
|
-
cmd: "dev",
|
|
165
|
-
target: target,
|
|
166
|
-
pack: {
|
|
167
|
-
config: options.config,
|
|
168
|
-
env: options.env || "dev",
|
|
169
|
-
watch: true,
|
|
170
|
-
esm: true
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
cli.command("preview <target>", "Preview the production build").option("-c, --config <file>", "Use specified config file").action((target, options)=>{
|
|
176
|
-
__webpack_require__.e("740").then(__webpack_require__.bind(__webpack_require__, "./src/cli/pack-code.ts")).then(({ pack_code })=>{
|
|
177
|
-
pack_code({
|
|
178
|
-
cmd: "preview",
|
|
179
|
-
target: target,
|
|
180
|
-
pack: {
|
|
181
|
-
config: options.config,
|
|
182
|
-
env: "prd",
|
|
183
|
-
watch: false,
|
|
184
|
-
esm: true
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
cli.help();
|
|
190
|
-
cli.version(package_namespaceObject.rE);
|
|
191
|
-
function exec() {
|
|
192
|
-
try {
|
|
193
|
-
cli.parse();
|
|
194
|
-
} catch (error) {
|
|
195
|
-
log.v.error(`Error: ${error.message}`);
|
|
196
|
-
cli.outputHelp();
|
|
197
|
-
process.exit(1);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
export { exec };
|
|
1
|
+
export { exec } from "./131.js";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@yannick-z/modulo",
|
|
3
3
|
"description": "",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.4",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "oyangxiao",
|
|
8
8
|
"scripts": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"dist",
|
|
19
19
|
"bin",
|
|
20
20
|
"src",
|
|
21
|
+
"template",
|
|
21
22
|
"README.md",
|
|
22
23
|
"LICENSE"
|
|
23
24
|
],
|
package/src/packer/lib.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pluginLess } from "@rsbuild/plugin-less";
|
|
2
|
-
import {
|
|
2
|
+
import { rsbuild, defineConfig, createRslib } from "@rslib/core";
|
|
3
3
|
import picocolors from "picocolors";
|
|
4
4
|
import type { ModuloArgs_Pack } from "../args/index.ts";
|
|
5
5
|
import { get_global_config, get_packagejson } from "../config/index.ts";
|
|
@@ -24,6 +24,7 @@ export async function lib_pack(args: ModuloArgs_Pack) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const rslibConfig = defineConfig({
|
|
27
|
+
root: process.cwd(),
|
|
27
28
|
source: {
|
|
28
29
|
define: config.define,
|
|
29
30
|
entry: entries,
|
|
@@ -83,9 +84,9 @@ export async function lib_pack(args: ModuloArgs_Pack) {
|
|
|
83
84
|
},
|
|
84
85
|
});
|
|
85
86
|
|
|
86
|
-
await
|
|
87
|
+
const rslibInstance = await createRslib({ config: rslibConfig })
|
|
88
|
+
await rslibInstance.build({
|
|
87
89
|
watch: args.cmd === "build" && !!args.pack.watch,
|
|
88
|
-
root: process.cwd(),
|
|
89
90
|
});
|
|
90
91
|
|
|
91
92
|
if (args.cmd === "build") {
|