@yongdall/build 0.1.0

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.
Files changed (3) hide show
  1. package/index.mjs +604 -0
  2. package/index.mjs.map +1 -0
  3. package/package.json +20 -0
package/index.mjs ADDED
@@ -0,0 +1,604 @@
1
+ #!/usr/bin/env node
2
+ import * as pathFn from "node:path";
3
+ import * as pathPosix from "node:path/posix";
4
+ import { rolldown } from "rolldown";
5
+ import loadConfiguration from "@yongdall/load-configuration";
6
+ import * as fsPromises from "node:fs/promises";
7
+ import * as os from "node:os";
8
+ import { dts } from "rolldown-plugin-dts";
9
+ import * as ts from "typescript";
10
+ import commonjs from "@rollup/plugin-commonjs";
11
+
12
+ //#region cli/build/config.mjs
13
+ const root = process.env.BUILD_PLUGIN_ROOT || process.env.npm_config_local_prefix || "";
14
+ /**
15
+ * @typedef {object} AssetsBuild
16
+ * @prop {string} [dir]
17
+ * @prop {string} [dts]
18
+ * @prop {Record<string, string | [string, string?]>} [inputs]
19
+ * @prop {Record<string, string>} [exports]
20
+ * @prop {Record<string, string>} [imports]
21
+ * @prop {Record<string, string>} [alias]
22
+ * @prop {string} [hooks]
23
+ * @prop {string[]} [styles]
24
+ * @prop {string[]} [external]
25
+ * @prop {any[]} [plugins]
26
+ * @prop {string[]} [polyfill]
27
+ * @prop {boolean} [sourcemap]
28
+ */
29
+ /**
30
+ * @typedef {object} Build
31
+ * @prop {string} [dir]
32
+ * @prop {string} [target]
33
+ * @prop {string} [dts]
34
+ * @prop {string[]} [inputs] 入口文件
35
+ * @prop {Record<string, string | [string, string?]>} [exports] 导出文件
36
+ * @prop {Record<string, string>} [imports] 内部别名
37
+ * @prop {Record<string, string> | string} [bin] 二进制文件
38
+ * @prop {string[]} [external]
39
+ */
40
+ /**
41
+ * @typedef {object} NodeModule
42
+ * @prop {string} [dir]
43
+ * @prop {Record<string, string>} [esm]
44
+ * @prop {Record<string, Record<string, string>>} [importmap]
45
+ */
46
+ /**
47
+ * @typedef {object} Copy
48
+ * @prop {string} [from]
49
+ * @prop {string} [to]
50
+ * @prop {string | string[]} files
51
+ * @prop {boolean} [assets]
52
+ */
53
+ /**
54
+ * @typedef {object} Config
55
+ * @prop {string} [package]
56
+ * @prop {string} [dist]
57
+ * @prop {AssetsBuild} [assetsBuild]
58
+ * @prop {Record<string, Record<string, string>>} [importmap]
59
+ * @prop {Record<string, NodeModule>} [nodeModules]
60
+ * @prop {(string | Copy[])} [copy]
61
+ * @prop {Build} [build]
62
+ * @prop {string} [assetsDir]
63
+ */
64
+ /** @type {Config?} */
65
+ const config = await loadConfiguration(pathFn.resolve(root, "build.yongdall"));
66
+ if (!config) {
67
+ console.error("读取定义配置文件失败");
68
+ process.exit();
69
+ }
70
+ const packagePath = pathFn.join(root, config.package || "package.json");
71
+ const assetsBuild = config.assetsBuild;
72
+ const build = config.build;
73
+ const copyFiles = config.copy || [];
74
+ const importmap = config.importmap;
75
+ const nodeModules = config.nodeModules;
76
+ /** @type {Record<string, any>} */
77
+ const nodePackage = await loadConfiguration(packagePath).then((v) => v || {}, () => ({}));
78
+ const distDir = (config.dist || "dist").replace(/\{%([^%]*)%\}/g, (_, name) => {
79
+ switch (name) {
80
+ case "name": {
81
+ const name = nodePackage.name;
82
+ if (name && typeof name === "string") return name;
83
+ }
84
+ case "dir": return pathFn.basename(pathFn.resolve(root));
85
+ }
86
+ return _;
87
+ });
88
+ const distRoot = pathPosix.join(root, distDir === "." ? "" : distDir);
89
+ const assetsDir = config.assetsDir || "assets";
90
+ const assetsRoot = pathFn.resolve(root, assetsDir);
91
+
92
+ //#endregion
93
+ //#region cli/build/buildDts.mjs
94
+ const extNames = [
95
+ ".d.ts",
96
+ ".d.mts",
97
+ ".ts",
98
+ ".mts",
99
+ ".js",
100
+ ".mjs"
101
+ ];
102
+ /**
103
+ *
104
+ * @param {string} assetRoot
105
+ */
106
+ async function findFiles(assetRoot) {
107
+ const files = /* @__PURE__ */ new Set();
108
+ const list2 = [];
109
+ for await (const f of fsPromises.glob("**/*.{mjs,js,mts,ts}", {
110
+ cwd: assetRoot,
111
+ exclude: ["node_modules/**"]
112
+ })) {
113
+ if (f.startsWith("node_modules/") || f.includes("/node_modules/")) continue;
114
+ for (const e of extNames) {
115
+ if (!f.endsWith(e)) continue;
116
+ if (e.includes(".d.")) {
117
+ list2.push(f.slice(0, f.length - e.length) + e.slice(2));
118
+ list2.push(f.slice(0, f.length - e.length) + e.slice(2).replace("t", "j") || "");
119
+ } else files.add(f);
120
+ }
121
+ }
122
+ for (const f of list2) files.delete(f);
123
+ if (!files.size) return null;
124
+ return files;
125
+ }
126
+ /**
127
+ * 使用 TypeScript Compiler API 编译指定文件,仅生成 .d.ts 声明文件
128
+ * @param {string[]} files - 要编译的文件路径列表(相对于 root)
129
+ * @param {string} root - 工作目录(cwd)
130
+ */
131
+ async function compileDeclarations(files, root) {
132
+ const program = ts.createProgram(files.map((f) => pathFn.resolve(root, f)), {
133
+ strict: true,
134
+ allowJs: true,
135
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
136
+ declaration: true,
137
+ emitDeclarationOnly: true,
138
+ module: ts.ModuleKind.ESNext,
139
+ target: ts.ScriptTarget.ESNext,
140
+ outDir: root,
141
+ rootDir: root,
142
+ verbatimModuleSyntax: true,
143
+ allowSyntheticDefaultImports: false,
144
+ customConditions: [
145
+ "types",
146
+ "typings",
147
+ "module",
148
+ "node"
149
+ ],
150
+ skipLibCheck: true,
151
+ esModuleInterop: false
152
+ });
153
+ const emitResult = program.emit();
154
+ const errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics).filter((v) => v.category === ts.DiagnosticCategory.Error);
155
+ if (errors.length > 0) {
156
+ const message = ts.formatDiagnosticsWithColorAndContext(errors, {
157
+ getCurrentDirectory: () => root,
158
+ getCanonicalFileName: (fileName) => fileName,
159
+ getNewLine: () => os.EOL
160
+ });
161
+ console.error(message);
162
+ throw new Error(`TS 编译错误: ${message}`);
163
+ }
164
+ }
165
+ /**
166
+ *
167
+ * @param {Record<string, string>} input
168
+ * @param {string} root
169
+ * @param {string} outdir
170
+ * @param {object} [options]
171
+ * @param {string[] | ((is: string) => boolean)} [options.external]
172
+ * @param {boolean} [options.tsc]
173
+ * @returns
174
+ */
175
+ async function buildDts(input, root, outdir, { external, tsc } = {}) {
176
+ const files = (Object.values(input).find((v) => v.endsWith(".js") || v.endsWith(".mjs")) || tsc) && await findFiles(root);
177
+ if (files) await compileDeclarations([...files], root);
178
+ const { output } = await (await rolldown({
179
+ input,
180
+ external,
181
+ plugins: [dts({
182
+ emitDtsOnly: true,
183
+ compilerOptions: {
184
+ allowJs: true,
185
+ moduleResolution: "Bundler",
186
+ declaration: true,
187
+ module: "ESNext",
188
+ target: "ESNext",
189
+ emitDeclarationOnly: true,
190
+ verbatimModuleSyntax: true,
191
+ strict: true,
192
+ allowSyntheticDefaultImports: false,
193
+ customConditions: [
194
+ "types",
195
+ "typings",
196
+ "module",
197
+ "node"
198
+ ],
199
+ skipLibCheck: true
200
+ }
201
+ })]
202
+ })).generate({
203
+ dir: outdir,
204
+ format: "esm",
205
+ sourcemap: false,
206
+ entryFileNames: "[name].mjs",
207
+ chunkFileNames: "[name]-[hash].mjs"
208
+ });
209
+ for (const chunkOrAsset of output) {
210
+ if (!chunkOrAsset.fileName.endsWith(".d.mts")) continue;
211
+ const filePath = pathFn.resolve(outdir, chunkOrAsset.fileName);
212
+ await fsPromises.mkdir(pathFn.dirname(filePath), { recursive: true });
213
+ const content = chunkOrAsset.code ?? chunkOrAsset.source;
214
+ await fsPromises.writeFile(filePath, content || "");
215
+ }
216
+ if (files) await Promise.allSettled([...files].map((v) => v.replace(/\.(m?)[jt]s$/, ".d.$1ts")).map((path) => fsPromises.unlink(pathFn.resolve(root, path))));
217
+ }
218
+
219
+ //#endregion
220
+ //#region cli/build/createExternal.mjs
221
+ /**
222
+ *
223
+ * @param {Set<string>} dependencies
224
+ * @param {Set<string>} externals
225
+ * @param {boolean} [node]
226
+ * @returns {(id: string) => boolean}
227
+ */
228
+ function createExternal(dependencies, externals, node) {
229
+ return (id) => {
230
+ if (node && id.startsWith("node:")) return true;
231
+ if (externals.has(id)) return true;
232
+ if (dependencies.has(id)) return true;
233
+ let index = id.indexOf("/");
234
+ if (index > 0 && id[0] === "@") index = id.indexOf("/", index + 1);
235
+ const name = id.slice(0, index);
236
+ if (!name) return false;
237
+ return dependencies.has(name);
238
+ };
239
+ }
240
+
241
+ //#endregion
242
+ //#region cli/build/buildAssets.mjs
243
+ const toNameRegex = /\.[^.]+$/;
244
+ async function buildAssets() {
245
+ if (!assetsBuild) return;
246
+ const list = Object.entries(assetsBuild.inputs || {});
247
+ if (!list.length) return;
248
+ const outdir = pathPosix.join(distRoot, assetsDir);
249
+ const assetRoot = pathFn.join(root, assetsBuild.dir || "");
250
+ /** @type {(id: string) => boolean} */
251
+ const external = createExternal(new Set([
252
+ ...nodePackage.name ? [nodePackage.name] : [],
253
+ ...Object.keys(nodePackage?.devDependencies || {}),
254
+ ...Object.keys(nodePackage?.peerDependencies || {}),
255
+ ...Object.keys(nodePackage?.optionalDependencies || {})
256
+ ]), new Set([...Object.keys(assetsBuild.imports || {}), ...assetsBuild.external || []]));
257
+ if (assetsBuild.dts) {
258
+ let dtsInputs = list.map(([name, relPath]) => [name, pathFn.join(assetRoot, Array.isArray(relPath) ? relPath[1] || "" : relPath)]);
259
+ dtsInputs = dtsInputs.filter((v) => v[1]);
260
+ if (dtsInputs.length) await buildDts(Object.fromEntries(dtsInputs), assetRoot, outdir, {
261
+ tsc: true,
262
+ external
263
+ });
264
+ }
265
+ const result = await (await rolldown({
266
+ input: Object.fromEntries(list.map(([name, relPath]) => [name, pathFn.join(assetRoot, Array.isArray(relPath) ? relPath[0] : relPath)])),
267
+ external,
268
+ plugins: assetsBuild.plugins || []
269
+ })).write({
270
+ dir: outdir,
271
+ format: "esm",
272
+ sourcemap: assetsBuild.sourcemap !== false,
273
+ entryFileNames: "[name].mjs",
274
+ chunkFileNames: "[name]-[hash].mjs",
275
+ minify: true
276
+ });
277
+ /** @type {Record<string, Record<string, string>>} */
278
+ const points = {};
279
+ for (const { fileName } of result.output) {
280
+ const ext = pathPosix.extname(fileName);
281
+ if (ext === ".map") continue;
282
+ const point = fileName.replace(toNameRegex, "");
283
+ if (!Object.hasOwn(points, point)) points[point] = {};
284
+ points[point][ext.slice(1)] = fileName;
285
+ }
286
+ return points;
287
+ }
288
+
289
+ //#endregion
290
+ //#region cli/build/copy.mjs
291
+ /**
292
+ *
293
+ * @param {string} fPath
294
+ * @param {string} tPath
295
+ */
296
+ async function copy(fPath, tPath) {
297
+ const fStat = await fsPromises.lstat(fPath).catch(() => null);
298
+ if (!fStat) return;
299
+ if (fStat.isSymbolicLink() || fStat.isFile()) {
300
+ const tStat = await fsPromises.lstat(tPath).catch(() => null);
301
+ if (tStat?.isDirectory()) await fsPromises.rmdir(tPath);
302
+ else if (tStat) await fsPromises.unlink(tPath);
303
+ await fsPromises.mkdir(pathFn.dirname(tPath), { recursive: true });
304
+ fsPromises.copyFile(fPath, tPath);
305
+ }
306
+ if (!fStat.isDirectory()) return;
307
+ const tStat = await fsPromises.lstat(tPath).catch(() => null);
308
+ if (!tStat?.isDirectory()) {
309
+ if (tStat) await fsPromises.unlink(tPath);
310
+ await fsPromises.mkdir(tPath, { recursive: true });
311
+ }
312
+ for (const file of await fsPromises.readdir(fPath)) await copy(pathFn.join(fPath, file), pathFn.join(tPath, file));
313
+ }
314
+
315
+ //#endregion
316
+ //#region cli/build/buildBack.mjs
317
+ /**
318
+ * @typedef {Object} BackPoints
319
+ * @property {string | Record<string, string> | null} [bin] - 可执行脚本的路径,可以是字符串(单个入口)或对象(多个命名入口)。
320
+ * @property {Record<string, string>?} [exports] - 模块导出映射,键为导出名称,值可以是模块路径字符串,或包含主入口和可选子路径的元组。
321
+ * @property {Record<string, string>?} [imports] - 模块导入别名映射,用于在代码中通过别名引用模块。
322
+ */
323
+ const regex = /^(?<name>.+)\.(mjs|mts|js|ts)$/;
324
+ /**
325
+ *
326
+ * @returns {Promise<BackPoints | undefined>}
327
+ */
328
+ async function buildBack() {
329
+ if (!build) return;
330
+ const inputRoot = pathFn.join(root, build.dir || "");
331
+ const outdir = pathPosix.join(distRoot, build.target || ".");
332
+ /** @type {[string, string][] | undefined} */
333
+ let inputs = build.inputs?.map((path) => {
334
+ const name = regex.exec(path)?.groups?.name;
335
+ if (!name) return ["", ""];
336
+ return [name, path];
337
+ }) || [];
338
+ inputs = inputs.filter((v) => v[0]);
339
+ const { bin, imports, exports } = build;
340
+ const external = createExternal(new Set([
341
+ ...nodePackage.name ? [nodePackage.name] : [],
342
+ ...Object.keys(nodePackage?.dependencies || {}),
343
+ ...Object.keys(nodePackage?.devDependencies || {}),
344
+ ...Object.keys(nodePackage?.peerDependencies || {}),
345
+ ...Object.keys(nodePackage?.optionalDependencies || {})
346
+ ]), new Set([
347
+ ...Object.keys(imports || {}),
348
+ ...build.external || [],
349
+ ...Object.keys(nodePackage?.dependencies || {})
350
+ ]), true);
351
+ if (build.dts && exports && typeof exports === "object") {
352
+ /** @type {Record<string, string>} */
353
+ const dts = {};
354
+ for (const v of Object.values(exports)) {
355
+ const path = Array.isArray(v) ? v[1] : v;
356
+ if (!path || typeof path !== "string") continue;
357
+ const name = regex.exec(path)?.groups?.name;
358
+ if (!name) continue;
359
+ dts[name] = pathFn.resolve(inputRoot, path);
360
+ }
361
+ if (Object.keys(dts).length) await buildDts(dts, root, outdir, {
362
+ external,
363
+ tsc: true
364
+ });
365
+ }
366
+ /** @type {BackPoints['bin']} */
367
+ let binPoints = null;
368
+ if (bin && typeof bin === "string") {
369
+ const name = regex.exec(bin)?.groups?.name;
370
+ if (name) inputs.push([name, bin]);
371
+ binPoints = "./" + pathFn.join("./", name ? `${name}.mjs` : bin);
372
+ } else if (bin && typeof bin === "object") {
373
+ /** @type {[string, string][]} */
374
+ const list = Object.entries(bin).map(([k, path]) => {
375
+ const name = regex.exec(path)?.groups?.name;
376
+ if (name) inputs.push([name, path]);
377
+ return [k, "./" + pathFn.join("./", name ? `${name}.mjs` : path)];
378
+ });
379
+ if (list.length) binPoints = Object.fromEntries(list);
380
+ }
381
+ /** @type {[string, string][]} */
382
+ const importPoints = imports && typeof imports === "object" && Object.entries(imports).map(([k, path]) => {
383
+ const name = regex.exec(path)?.groups?.name;
384
+ if (name) inputs.push([name, path]);
385
+ return [k[0] === "#" ? k : `#${k}`, "./" + pathFn.join("./", name ? `${name}.mjs` : path)];
386
+ }) || [];
387
+ /** @type {[string, string][]} */
388
+ const exportPoints = exports && typeof exports === "object" && Object.entries(exports).map(([k, v]) => {
389
+ const path = Array.isArray(v) ? v[0] : v;
390
+ const name = typeof path === "string" && regex.exec(path)?.groups?.name;
391
+ if (name) inputs.push([name, path]);
392
+ return [k, "./" + pathFn.join("./", name ? `${name}.mjs` : path)];
393
+ }) || [];
394
+ if (!inputs.length) return;
395
+ await (await rolldown({
396
+ input: Object.fromEntries(inputs.map(([k, v]) => [k, pathFn.resolve(inputRoot, v)])),
397
+ external
398
+ })).write({
399
+ dir: outdir,
400
+ format: "esm",
401
+ sourcemap: true,
402
+ entryFileNames: "[name].mjs",
403
+ chunkFileNames: "[name]-[hash].mjs"
404
+ });
405
+ return {
406
+ bin: binPoints,
407
+ exports: exportPoints.length ? Object.fromEntries(exportPoints) : null,
408
+ imports: importPoints.length ? Object.fromEntries(importPoints) : null
409
+ };
410
+ }
411
+
412
+ //#endregion
413
+ //#region cli/build/buildPackage.mjs
414
+ /**
415
+ *
416
+ * @param {Record<string, any>} obj
417
+ * @param {string} key
418
+ * @returns
419
+ */
420
+ function getObjectProp(obj, key) {
421
+ const prop = key in obj && obj[key];
422
+ return prop && typeof prop === "object" && prop || {};
423
+ }
424
+ /**
425
+ *
426
+ * @param {string} path
427
+ * @param {any} cfg
428
+ * @param {string | number} [space]
429
+ * @returns {Promise<void>}
430
+ */
431
+ async function writeCfg(path, cfg, space) {
432
+ const text = JSON.stringify(cfg, null, space);
433
+ await fsPromises.writeFile(path, text);
434
+ }
435
+ /**
436
+ *
437
+ * @param {*} nodePackage
438
+ * @param {string} name
439
+ */
440
+ async function updateVersion(nodePackage, name) {
441
+ if (!Object.hasOwn(nodePackage, name)) return;
442
+ const dependencies = nodePackage[name];
443
+ if (!dependencies || typeof dependencies !== "object") return;
444
+ if (!Object.keys(dependencies).length) return;
445
+ for (const [name, version] of Object.entries(dependencies)) {
446
+ if (typeof version !== "string" || !version) continue;
447
+ let path = "";
448
+ if (version.startsWith("workspace:")) {
449
+ const workspace = version.slice(10);
450
+ if (["/", "."].includes(workspace[0])) path = workspace;
451
+ else {
452
+ dependencies[name] = workspace;
453
+ continue;
454
+ }
455
+ } else if (version.startsWith("file:")) path = version.slice(5);
456
+ else if (version.startsWith("link:")) path = version.slice(5);
457
+ if (!path) continue;
458
+ const packagePath = pathPosix.resolve(root, path, "package.json");
459
+ try {
460
+ const json = await fsPromises.readFile(packagePath, "utf-8");
461
+ const version = JSON.parse(json)?.version;
462
+ if (version && typeof version === "string") dependencies[name] = `^${version}`;
463
+ } catch {}
464
+ }
465
+ nodePackage[name] = dependencies;
466
+ }
467
+ /** @import { BackPoints } from './buildBack.mjs' */
468
+ /**
469
+ *
470
+ * @param {BackPoints} [backPoints]
471
+ * @param {Record<string, Record<string, string>>} [points]
472
+ */
473
+ async function buildPackage({ imports, bin, exports } = {}, points = {}) {
474
+ const pkg = structuredClone(nodePackage);
475
+ /** @type {Record<string, string>} */
476
+ const assetExports = {};
477
+ for (const [k, v] of Object.entries(assetsBuild?.exports || {})) {
478
+ if (Object.hasOwn(points, v) && points[v].mjs) {
479
+ assetExports[k] = "./" + pathPosix.join(assetsDir, points[v].mjs);
480
+ continue;
481
+ }
482
+ const index = v.lastIndexOf(".");
483
+ if (index <= 0) continue;
484
+ const name = v.slice(0, index);
485
+ const ext = v.slice(index + 1);
486
+ const value = points[name]?.[ext];
487
+ if (!value) continue;
488
+ assetExports[k] = "./" + pathPosix.join(assetsDir, value);
489
+ }
490
+ if (exports || Object.keys(assetExports).length) pkg.exports = {
491
+ ...getObjectProp(pkg, "exports"),
492
+ ...assetExports,
493
+ ...exports
494
+ };
495
+ const main = exports && Object.hasOwn(exports, ".") && exports["."] || Object.hasOwn(assetExports, ".") && assetExports["."];
496
+ if (main) {
497
+ pkg.main = main;
498
+ pkg.type = "module";
499
+ delete pkg.types;
500
+ }
501
+ if (imports) pkg.imports = {
502
+ ...getObjectProp(pkg, "imports"),
503
+ ...imports
504
+ };
505
+ if (typeof bin === "string") pkg.bin = bin;
506
+ else if (bin) pkg.bin = {
507
+ ...getObjectProp(pkg, "bin"),
508
+ ...bin
509
+ };
510
+ await updateVersion(pkg, "dependencies");
511
+ await updateVersion(pkg, "devDependencies");
512
+ await updateVersion(pkg, "peerDependencies");
513
+ await updateVersion(pkg, "optionalDependencies");
514
+ await updateVersion(pkg, "bundledDependencies");
515
+ delete pkg.private;
516
+ await writeCfg(pathPosix.join(distRoot, "package.json"), pkg, 2);
517
+ }
518
+
519
+ //#endregion
520
+ //#region cli/build/buildAssetsMjs.mjs
521
+ /**
522
+ *
523
+ * @param {Record<string, Record<string, string>>} [points]
524
+ * @param {string[]} [polyfill]
525
+ */
526
+ async function buildAssetsMjs(points, polyfill) {
527
+ /** @type {string[]} */
528
+ const scripts = [];
529
+ /** @type {Record<string, string>} */
530
+ const files = {};
531
+ /** @type {Record<string, string>} */
532
+ const mjs = {};
533
+ /** @type {Record<string, string>} */
534
+ const css = {};
535
+ for (const [point, values] of Object.entries(points || {})) {
536
+ for (const [type, value] of Object.entries(values)) {
537
+ if (type === "mjs") continue;
538
+ files[`${point}.${type}`] = value;
539
+ }
540
+ if ("mjs" in values) mjs[point] = values.mjs;
541
+ if ("css" in values) css[point] = values.css;
542
+ }
543
+ if (Object.keys(files).length) scripts.push(`export const files = ${JSON.stringify(files)};\n`);
544
+ const alias = assetsBuild?.alias;
545
+ if (alias && Object.keys(alias).length) scripts.push(`export const alias = ${JSON.stringify(alias)};\n`);
546
+ if (Object.keys(mjs).length) scripts.push(`export const esm = ${JSON.stringify(mjs)};\n`);
547
+ if (importmap) scripts.push(`export const importmap = ${JSON.stringify(importmap)};\n`);
548
+ const hooks = assetsBuild?.hooks;
549
+ const styles = assetsBuild?.styles?.map((v) => Object.hasOwn(css, v) ? css[v] : "").filter(Boolean);
550
+ if (styles?.length) scripts.push(`export const styles = ${JSON.stringify(styles)};\n`);
551
+ if (typeof hooks === "string") scripts.push(`export const hooks = ${JSON.stringify(hooks)};\n`);
552
+ if (nodeModules) scripts.push(`export const nodeModules = ${JSON.stringify(nodeModules)};\n`);
553
+ if (polyfill?.length) scripts.push(`export const polyfill = ${JSON.stringify(polyfill)};\n`);
554
+ if (!scripts.length) return;
555
+ if (assetsDir && assetsDir !== ".") scripts.push(`export const dir = ${JSON.stringify(assetsDir)};\n`);
556
+ await fsPromises.writeFile(pathFn.join(distRoot, "assets.yongdall.mjs"), scripts.join(""));
557
+ }
558
+
559
+ //#endregion
560
+ //#region cli/build/buildPolyfill.mjs
561
+ async function buildPolyfill() {
562
+ if (!assetsBuild) return;
563
+ const assetRoot = pathFn.join(root, assetsBuild.dir || "");
564
+ const outdir = pathPosix.join(distRoot, assetsDir);
565
+ const list = assetsBuild.polyfill?.map((v) => pathFn.join(assetRoot, v)).filter(Boolean) || [];
566
+ if (!list.length) return;
567
+ const result = await (await rolldown({
568
+ input: list,
569
+ plugins: [commonjs()]
570
+ })).write({
571
+ dir: outdir,
572
+ format: "iife",
573
+ sourcemap: assetsBuild.sourcemap !== false,
574
+ entryFileNames: "[name].js",
575
+ minify: true,
576
+ name: `polyfill_${Date.now()}_${`${Math.random()}`.slice(2)}`
577
+ });
578
+ /** @type {string[]} */
579
+ const polyfill = [];
580
+ for (const { fileName } of result.output) {
581
+ if (pathPosix.extname(fileName) === ".map") continue;
582
+ polyfill.push(fileName);
583
+ }
584
+ return polyfill;
585
+ }
586
+
587
+ //#endregion
588
+ //#region cli/build/index.mjs
589
+ for (const g of copyFiles) {
590
+ if (typeof g === "string") {
591
+ await copy(pathFn.join(root, g), pathFn.join(distRoot, g));
592
+ continue;
593
+ }
594
+ const { files, from, to, assets } = g;
595
+ for (const file of [files].flat()) await copy(pathFn.join(root, from || "", file), pathFn.join(assets ? assetsRoot : distRoot, to || "", file));
596
+ }
597
+ const points = await buildAssets();
598
+ const polyfill = await buildPolyfill();
599
+ const backPoints = await buildBack();
600
+ await buildAssetsMjs(points, polyfill);
601
+ await buildPackage(backPoints, points);
602
+
603
+ //#endregion
604
+ //# sourceMappingURL=index.mjs.map
package/index.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["pathFn"],"sources":["../../cli/build/config.mjs","../../cli/build/buildDts.mjs","../../cli/build/createExternal.mjs","../../cli/build/buildAssets.mjs","../../cli/build/copy.mjs","../../cli/build/buildBack.mjs","../../cli/build/buildPackage.mjs","../../cli/build/buildAssetsMjs.mjs","../../cli/build/buildPolyfill.mjs","../../cli/build/index.mjs"],"sourcesContent":["\nimport * as pathFn from 'node:path';\nimport * as pathPosix from 'node:path/posix';\nimport loadConfiguration from '@yongdall/load-configuration';\n\nexport const root = process.env.BUILD_PLUGIN_ROOT || process.env.npm_config_local_prefix || '';\n\n/**\n * @typedef {object} AssetsBuild\n * @prop {string} [dir]\n * @prop {string} [dts]\n * @prop {Record<string, string | [string, string?]>} [inputs]\n * @prop {Record<string, string>} [exports]\n * @prop {Record<string, string>} [imports]\n * @prop {Record<string, string>} [alias]\n * @prop {string} [hooks]\n * @prop {string[]} [styles]\n * @prop {string[]} [external]\n * @prop {any[]} [plugins]\n * @prop {string[]} [polyfill]\n * @prop {boolean} [sourcemap]\n */\n/**\n * @typedef {object} Build\n * @prop {string} [dir] \n * @prop {string} [target] \n * @prop {string} [dts]\n * @prop {string[]} [inputs] 入口文件\n * @prop {Record<string, string | [string, string?]>} [exports] 导出文件\n * @prop {Record<string, string>} [imports] 内部别名\n * @prop {Record<string, string> | string} [bin] 二进制文件\n * @prop {string[]} [external]\n */\n/**\n * @typedef {object} NodeModule\n * @prop {string} [dir]\n * @prop {Record<string, string>} [esm]\n * @prop {Record<string, Record<string, string>>} [importmap]\n */\n/**\n * @typedef {object} Copy\n * @prop {string} [from]\n * @prop {string} [to]\n * @prop {string | string[]} files\n * @prop {boolean} [assets]\n */\n/**\n * @typedef {object} Config\n * @prop {string} [package]\n * @prop {string} [dist]\n * @prop {AssetsBuild} [assetsBuild]\n * @prop {Record<string, Record<string, string>>} [importmap]\n * @prop {Record<string, NodeModule>} [nodeModules]\n * @prop {(string | Copy[])} [copy]\n * @prop {Build} [build]\n * @prop {string} [assetsDir]\n */\n/** @type {Config?} */\nexport const config = await loadConfiguration(pathFn.resolve(root, 'build.yongdall'));\nif (!config) {\n\tconsole.error('读取定义配置文件失败');\n\tprocess.exit();\n}\n\nexport const packagePath = pathFn.join(root, config.package || 'package.json');\nexport const assetsBuild = config.assetsBuild;\nexport const build = config.build;\nexport const copyFiles = config.copy || [];\nexport const importmap = config.importmap;\nexport const nodeModules = config.nodeModules;\n\n/** @type {Record<string, any>} */\nexport const nodePackage = await loadConfiguration(packagePath).then(v => v || {}, () => ({}));\n\n\nconst distDir = (config.dist || 'dist').replace(/\\{%([^%]*)%\\}/g, (_, name) => {\n\tswitch (name) {\n\t\tcase 'name': {\n\t\t\tconst name = nodePackage.name;\n\t\t\tif (name && typeof name === 'string') { return name; }\n\t\t}\n\t\tcase 'dir': return pathFn.basename(pathFn.resolve(root));\n\t}\n\treturn _;\n});\nexport const distRoot = pathPosix.join(root, distDir === '.' ? '' : distDir);\n\nexport const assetsDir = config.assetsDir || 'assets';\nexport const assetsRoot = pathFn.resolve(root, assetsDir);\n","import * as pathFn from 'node:path';\nimport * as fsPromises from 'node:fs/promises';\nimport * as os from 'node:os';\nimport { rolldown } from 'rolldown';\nimport { dts } from 'rolldown-plugin-dts';\nimport * as ts from 'typescript';\n\n\nconst extNames = ['.d.ts', '.d.mts', '.ts', '.mts', '.js', '.mjs'];\n/**\n * \n * @param {string} assetRoot \n */\nasync function findFiles(assetRoot) {\n\tconst files = new Set();\n\tconst list2 = [];\n\tfor await (const f of fsPromises.glob('**/*.{mjs,js,mts,ts}', {\n\t\tcwd: assetRoot, exclude: ['node_modules/**']\n\t})) {\n\t\tif (f.startsWith('node_modules/') || f.includes('/node_modules/')) { continue; }\n\t\tfor (const e of extNames) {\n\t\t\tif (!f.endsWith(e)) { continue; }\n\t\t\tif (e.includes('.d.')) {\n\t\t\t\tlist2.push(f.slice(0, f.length - e.length) + e.slice(2));\n\t\t\t\tlist2.push(f.slice(0, f.length - e.length) + e.slice(2).replace('t', 'j') || '');\n\t\t\t} else {\n\t\t\t\tfiles.add(f);\n\t\t\t}\n\t\t}\n\t}\n\tfor (const f of list2) {\n\t\tfiles.delete(f);\n\t}\n\tif (!files.size) { return null; }\n\treturn files;\n\n}\n\n/**\n * 使用 TypeScript Compiler API 编译指定文件,仅生成 .d.ts 声明文件\n * @param {string[]} files - 要编译的文件路径列表(相对于 root)\n * @param {string} root - 工作目录(cwd)\n */\nasync function compileDeclarations(files, root) {\n\t// 创建编译程序\n\tconst program = ts.createProgram(files.map(f => pathFn.resolve(root, f)), {\n\t\tstrict: true,\n\t\tallowJs: true,\n\t\tmoduleResolution: ts.ModuleResolutionKind.Bundler,\n\t\tdeclaration: true,\n\t\temitDeclarationOnly: true,\n\t\tmodule: ts.ModuleKind.ESNext,\n\t\ttarget: ts.ScriptTarget.ESNext,\n\t\toutDir: root,\n\t\trootDir: root,\n\n\t\t// 你额外要求的关键选项(CLI 不支持,但 API 支持!)\n\t\tverbatimModuleSyntax: true,\n\t\tallowSyntheticDefaultImports: false,\n\t\tcustomConditions: ['types', 'typings', 'module', 'node'],\n\n\t\t// 可选:提升兼容性\n\t\tskipLibCheck: true,\n\t\tesModuleInterop: false,\n\t});\n\n\tconst emitResult = program.emit();\n\n\t// 获取所有诊断信息(包括语法错误、类型错误等)\n\tconst diagnostics = ts\n\t\t.getPreEmitDiagnostics(program)\n\t\t.concat(emitResult.diagnostics);\n\n\tconst errors = diagnostics.filter(v => v.category === ts.DiagnosticCategory.Error);\n\tif (errors.length > 0) {\n\t\tconst message = ts.formatDiagnosticsWithColorAndContext(errors, {\n\t\t\tgetCurrentDirectory: () => root,\n\t\t\tgetCanonicalFileName: fileName => fileName,\n\t\t\tgetNewLine: () => os.EOL,\n\t\t});\n\t\tconsole.error(message); // 相当于 stderr 输出\n\t\tthrow new Error(`TS 编译错误: ${message}`);\n\t}\n\n}\n\n/**\n * \n * @param {Record<string, string>} input \n * @param {string} root \n * @param {string} outdir \n * @param {object} [options]\n * @param {string[] | ((is: string) => boolean)} [options.external] \n * @param {boolean} [options.tsc] \n * @returns \n */\nexport default async function buildDts(input, root, outdir, {\n\texternal, tsc\n} = {}) {\n\n\n\n\tconst files = (Object.values(input).find(v => v.endsWith('.js') || v.endsWith('.mjs')) || tsc) && await findFiles(root);\n\tif (files) {\n\t\tawait compileDeclarations([...files], root);\n\t}\n\n\n\t// === 第二步:DTS 构建 — 生成 .d.mts ===\n\tconst dtsBundle = await rolldown({\n\t\tinput,\n\t\texternal,\n\t\tplugins: [\n\t\t\tdts({\n\t\t\t\temitDtsOnly: true,\n\t\t\t\tcompilerOptions: {\n\t\t\t\t\tallowJs: true,\n\t\t\t\t\tmoduleResolution: 'Bundler',\n\t\t\t\t\tdeclaration: true,\n\t\t\t\t\tmodule: 'ESNext',\n\t\t\t\t\ttarget: 'ESNext',\n\t\t\t\t\temitDeclarationOnly: true,\n\t\t\t\t\tverbatimModuleSyntax: true,\n\t\t\t\t\tstrict: true,\n\t\t\t\t\tallowSyntheticDefaultImports: false,\n\t\t\t\t\tcustomConditions: ['types', 'typings', 'module', 'node'],\n\t\t\t\t\tskipLibCheck: true,\n\n\t\t\t\t},\n\t\t\t}),\n\t\t],\n\t});\n\n\tconst { output } = await dtsBundle.generate({\n\t\tdir: outdir,\n\t\tformat: 'esm',\n\t\tsourcemap: false,\n\t\tentryFileNames: '[name].mjs',\n\t\tchunkFileNames: '[name]-[hash].mjs',\n\t});\n\n\tfor (const chunkOrAsset of output) {\n\t\tif (!chunkOrAsset.fileName.endsWith('.d.mts')) { continue; }\n\t\tconst filePath = pathFn.resolve(outdir, chunkOrAsset.fileName);\n\t\tawait fsPromises.mkdir(pathFn.dirname(filePath), { recursive: true });\n\n\t\t// @ts-ignore\n\t\tconst content = chunkOrAsset.code ?? chunkOrAsset.source;\n\t\tawait fsPromises.writeFile(filePath, content || '');\n\t}\n\n\tif (files) {\n\t\tawait Promise.allSettled(\n\t\t\t[...files].map(v => v.replace(/\\.(m?)[jt]s$/, '.d.$1ts'))\n\t\t\t\t.map(path => fsPromises.unlink(pathFn.resolve(root, path)))\n\t\t);\n\t}\n\n\n}\n","/**\n * \n * @param {Set<string>} dependencies \n * @param {Set<string>} externals \n * @param {boolean} [node] \n * @returns {(id: string) => boolean}\n */\nexport default function createExternal(dependencies, externals, node) {\n\treturn id => {\n\t\tif (node && id.startsWith('node:')) { return true; }\n\t\tif (externals.has(id)) { return true; }\n\t\tif (dependencies.has(id)) { return true; }\n\t\tlet index = id.indexOf('/');\n\t\tif (index > 0 && id[0] === '@') {\n\t\t\tindex = id.indexOf('/', index + 1);\n\t\t}\n\t\tconst name = id.slice(0, index);\n\t\tif (!name) { return false; }\n\t\treturn dependencies.has(name);\n\t};\n}\n","import * as pathFn from 'node:path';\nimport * as pathPosix from 'node:path/posix';\nimport { rolldown } from 'rolldown';\nimport { assetsDir, distRoot, root, assetsBuild, nodePackage } from './config.mjs';\nimport buildDts from './buildDts.mjs';\nimport createExternal from './createExternal.mjs';\n\nconst toNameRegex = /\\.[^.]+$/;\n\n\nexport default async function buildAssets() {\n\tif (!assetsBuild) return;\n\tconst list = Object.entries(assetsBuild.inputs || {});\n\tif (!list.length) return;\n\n\tconst outdir = pathPosix.join(distRoot, assetsDir);\n\tconst assetRoot = pathFn.join(root, assetsBuild.dir || '');\n\n\n\n\tconst dependencies = new Set([\n\t\t...nodePackage.name ? [nodePackage.name] : [],\n\t\t...Object.keys(nodePackage?.devDependencies || {}),\n\t\t...Object.keys(nodePackage?.peerDependencies || {}),\n\t\t...Object.keys(nodePackage?.optionalDependencies || {}),\n\t]);\n\tconst externals = new Set([\n\t\t...Object.keys(assetsBuild.imports || {}),\n\t\t...(assetsBuild.external || []),\n\t]);\n\t/** @type {(id: string) => boolean} */\n\tconst external = createExternal(dependencies, externals);\n\tif (assetsBuild.dts) {\n\n\t\tlet dtsInputs = list.map(([name, relPath]) => [name, pathFn.join(assetRoot, Array.isArray(relPath) ? relPath[1] || '' : relPath)]);\n\t\tdtsInputs = dtsInputs.filter(v => v[1]);\n\n\t\tif (dtsInputs.length) {\n\t\t\tawait buildDts(Object.fromEntries(dtsInputs), assetRoot, outdir, {\n\t\t\t\ttsc: true, external,\n\t\t\t});\n\t\t}\n\t}\n\tconst input = Object.fromEntries(\n\t\tlist.map(([name, relPath]) => [name, pathFn.join(assetRoot, Array.isArray(relPath) ? relPath[0] : relPath)])\n\t);\n\n\n\tconst bundle = await rolldown({\n\t\tinput,\n\t\texternal,\n\t\tplugins: assetsBuild.plugins || [],\n\t});\n\n\tconst result = await bundle.write({\n\t\tdir: outdir,\n\t\tformat: 'esm',\n\t\tsourcemap: assetsBuild.sourcemap !== false,\n\t\tentryFileNames: '[name].mjs',\n\t\tchunkFileNames: '[name]-[hash].mjs',\n\t\tminify: true,\n\t});\n\n\n\t/** @type {Record<string, Record<string, string>>} */\n\tconst points = {};\n\tfor (const { fileName } of result.output) {\n\t\tconst ext = pathPosix.extname(fileName);\n\t\tif (ext === '.map') { continue; }\n\t\tconst point = fileName.replace(toNameRegex, '');\n\t\tif (!Object.hasOwn(points, point)) {\n\t\t\tpoints[point] = {};\n\t\t}\n\t\tpoints[point][ext.slice(1)] = fileName;\n\t}\n\treturn points;\n\n}\n","import * as pathFn from 'node:path';\nimport * as fsPromises from 'node:fs/promises';\n\n/**\n * \n * @param {string} fPath \n * @param {string} tPath \n */\nexport default async function copy(fPath, tPath) {\n\tconst fStat = await fsPromises.lstat(fPath).catch(() => null);\n\tif (!fStat) { return; }\n\tif (fStat.isSymbolicLink() || fStat.isFile()) {\n\t\tconst tStat = await fsPromises.lstat(tPath).catch(() => null);\n\t\tif (tStat?.isDirectory()) {\n\t\t\tawait fsPromises.rmdir(tPath);\n\t\t} else if (tStat) {\n\t\t\tawait fsPromises.unlink(tPath);\n\t\t}\n\t\tawait fsPromises.mkdir(pathFn.dirname(tPath), { recursive: true });\n\t\tfsPromises.copyFile(fPath, tPath);\n\t}\n\tif (!fStat.isDirectory()) { return; }\n\tconst tStat = await fsPromises.lstat(tPath).catch(() => null);\n\tif (!tStat?.isDirectory()) {\n\t\tif (tStat) {\n\t\t\tawait fsPromises.unlink(tPath);\n\t\t}\n\t\tawait fsPromises.mkdir(tPath, { recursive: true });\n\t}\n\tfor (const file of await fsPromises.readdir(fPath)) {\n\t\tawait copy(pathFn.join(fPath, file), pathFn.join(tPath, file));\n\t}\n}\n\n/**\n * \n * @param {string} fPath \n * @param {string} tPath \n */\nexport async function copyDir(fPath, tPath) {\n\tconst fStat = await fsPromises.lstat(fPath).catch(() => null);\n\tif (!fStat?.isDirectory()) { return; }\n\tconst tStat = await fsPromises.lstat(tPath).catch(() => null);\n\tif (!tStat?.isDirectory()) {\n\t\tif (tStat) {\n\t\t\tawait fsPromises.unlink(tPath);\n\t\t}\n\t\tawait fsPromises.mkdir(tPath, { recursive: true });\n\t}\n\tfor (const file of await fsPromises.readdir(fPath)) {\n\t\tawait copy(pathFn.join(fPath, file), pathFn.join(tPath, file));\n\t}\n}\n","import * as pathFn from 'node:path';\nimport * as pathPosix from 'node:path/posix';\nimport { rolldown } from 'rolldown';\nimport { distRoot, root, build, nodePackage } from './config.mjs';\nimport buildDts from './buildDts.mjs';\nimport createExternal from './createExternal.mjs';\n/**\n * @typedef {Object} BackPoints\n * @property {string | Record<string, string> | null} [bin] - 可执行脚本的路径,可以是字符串(单个入口)或对象(多个命名入口)。\n * @property {Record<string, string>?} [exports] - 模块导出映射,键为导出名称,值可以是模块路径字符串,或包含主入口和可选子路径的元组。\n * @property {Record<string, string>?} [imports] - 模块导入别名映射,用于在代码中通过别名引用模块。\n */\n\nconst regex = /^(?<name>.+)\\.(mjs|mts|js|ts)$/;\n/**\n * \n * @returns {Promise<BackPoints | undefined>}\n */\nexport default async function buildBack() {\n\tif (!build) { return; }\n\tconst inputRoot = pathFn.join(root, build.dir || '');\n\tconst outdir = pathPosix.join(distRoot, build.target || '.');\n\t/** @type {[string, string][] | undefined} */\n\tlet inputs = build.inputs?.map(path => {\n\t\tconst name = regex.exec(path)?.groups?.name;\n\t\tif (!name) { return ['', '']; }\n\t\treturn [name, path];\n\t}) || [];\n\tinputs = inputs.filter(v => v[0]);\n\tconst { bin, imports, exports } = build;\n\tconst dependencies = new Set([\n\t\t...nodePackage.name ? [nodePackage.name] : [],\n\t\t...Object.keys(nodePackage?.dependencies || {}),\n\t\t...Object.keys(nodePackage?.devDependencies || {}),\n\t\t...Object.keys(nodePackage?.peerDependencies || {}),\n\t\t...Object.keys(nodePackage?.optionalDependencies || {}),\n\t])\n\tconst externals = new Set([\n\t\t...Object.keys(imports || {}),\n\t\t...(build.external || []),\n\t\t...Object.keys(nodePackage?.dependencies || {}),\n\t]);\n\t\n\t\tconst external = createExternal(dependencies, externals, true);\n\n\n\tif (build.dts && exports && typeof exports === 'object') {\n\t\t/** @type {Record<string, string>} */\n\t\tconst dts = {};\n\t\tfor (const v of Object.values(exports)) {\n\t\t\tconst path = Array.isArray(v) ? v[1] : v;\n\t\t\tif (!path || typeof path !== 'string') { continue; }\n\t\t\tconst name = regex.exec(path)?.groups?.name;\n\t\t\tif (!name) { continue; }\n\t\t\tdts[name] = pathFn.resolve(inputRoot, path);\n\t\t}\n\t\tif (Object.keys(dts).length) {\n\t\t\tawait buildDts(dts, root, outdir, { external, tsc: true });\n\t\t}\n\t}\n\n\t/** @type {BackPoints['bin']} */\n\tlet binPoints = null\n\tif (bin && typeof bin === 'string') {\n\t\tconst name = regex.exec(bin)?.groups?.name;\n\t\tif (name) { inputs.push([name, bin]); }\n\t\tbinPoints = './' + pathFn.join('./', name ? `${name}.mjs` : bin);\n\t} else if (bin && typeof bin === 'object') {\n\t\t/** @type {[string, string][]} */\n\t\tconst list = Object.entries(bin).map(([k, path]) => {\n\t\t\tconst name = regex.exec(path)?.groups?.name;\n\t\t\tif (name) { inputs.push([name, path]); }\n\t\t\treturn [k, './' + pathFn.join('./', name ? `${name}.mjs` : path)];\n\t\t});\n\t\tif (list.length) {\n\t\t\tbinPoints = Object.fromEntries(list);\n\t\t}\n\t}\n\n\t/** @type {[string, string][]} */\n\tconst importPoints = imports && typeof imports === 'object' && Object.entries(imports).map(([k, path]) => {\n\t\tconst name = regex.exec(path)?.groups?.name;\n\t\tif (name) { inputs.push([name, path]); }\n\t\treturn [k[0] === '#' ? k : `#${k}`, './' + pathFn.join('./', name ? `${name}.mjs` : path)];\n\t}) || [];\n\n\t/** @type {[string, string][]} */\n\tconst exportPoints = exports && typeof exports === 'object' && Object.entries(exports).map(([k, v]) => {\n\t\tconst path = Array.isArray(v) ? v[0] : v;\n\t\tconst name = typeof path === 'string' && regex.exec(path)?.groups?.name;\n\t\tif (name) { inputs.push([name, path]); }\n\t\treturn [k, './' + pathFn.join('./', name ? `${name}.mjs` : path)];\n\t}) || [];\n\tif (!inputs.length) { return; }\n\n\tconst input = Object.fromEntries(inputs.map(([k, v]) => [k, pathFn.resolve(inputRoot, v)]));\n\n\tconst mainBundle = await rolldown({ input, external });\n\tawait mainBundle.write({\n\t\tdir: outdir,\n\t\tformat: 'esm',\n\t\tsourcemap: true,\n\t\tentryFileNames: '[name].mjs',\n\t\tchunkFileNames: '[name]-[hash].mjs',\n\t});\n\treturn {\n\t\tbin: binPoints,\n\t\texports: exportPoints.length ? Object.fromEntries(exportPoints) : null,\n\t\timports: importPoints.length ? Object.fromEntries(importPoints) : null,\n\t};\n}\n","import * as pathFn from 'node:path/posix';\nimport { assetsDir, distRoot, build, assetsBuild, nodePackage, root } from './config.mjs';\nimport * as fsPromises from 'node:fs/promises';\n/**\n *\n * @param {Record<string, any>} obj\n * @param {string} key\n * @returns\n */\nfunction getObjectProp(obj, key) {\n\tconst prop = key in obj && obj[key];\n\treturn prop && typeof prop === 'object' && prop || {};\n}\n\n/**\n * \n * @param {string} path\n * @param {any} cfg\n * @param {string | number} [space]\n * @returns {Promise<void>}\n */\nasync function writeCfg(path, cfg, space) {\n\tconst text = JSON.stringify(cfg, null, space);\n\tawait fsPromises.writeFile(path, text);\n}\n\n/**\n * \n * @param {*} nodePackage \n * @param {string} name \n */\nasync function updateVersion(nodePackage, name) {\n\tif (!Object.hasOwn(nodePackage, name)) { return; }\n\tconst dependencies = nodePackage[name];\n\tif (!dependencies || typeof dependencies !== 'object') { return; }\n\tif (!Object.keys(dependencies).length) { return; }\n\tfor (const [name, version] of Object.entries(dependencies)) {\n\t\tif (typeof version !== 'string' || !version) { continue; }\n\t\tlet path = '';\n\t\tif (version.startsWith('workspace:')) {\n\t\t\tconst workspace = version.slice('workspace:'.length);\n\t\t\tif (['/', '.'].includes(workspace[0])) {\n\t\t\t\tpath = workspace;\n\t\t\t} else {\n\t\t\t\tdependencies[name] = workspace;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (version.startsWith('file:')) {\n\t\t\tpath = version.slice('file:'.length);\n\t\t} else if (version.startsWith('link:')) {\n\t\t\tpath = version.slice('link:'.length);\n\t\t}\n\n\t\tif (!path) { continue; }\n\t\tconst packagePath = pathFn.resolve(root, path, 'package.json');\n\t\ttry {\n\t\t\tconst json = await fsPromises.readFile(packagePath, 'utf-8');\n\t\t\tconst version = JSON.parse(json)?.version;\n\t\t\tif (version && typeof version === 'string') {\n\t\t\t\tdependencies[name] = `^${version}`;\n\t\t\t}\n\t\t} catch { }\n\t}\n\tnodePackage[name] = dependencies;\n}\n\n/** @import { BackPoints } from './buildBack.mjs' */\n/**\n * \n * @param {BackPoints} [backPoints] \n * @param {Record<string, Record<string, string>>} [points] \n */\nexport default async function buildPackage({imports, bin, exports} = {}, points = {}) {\n\tconst pkg = structuredClone(nodePackage);\n\t/** @type {Record<string, string>} */\n\tconst assetExports = {};\n\tfor (const [k, v] of Object.entries(assetsBuild?.exports || {})) {\n\t\tif (Object.hasOwn(points, v) && points[v].mjs) {\n\t\t\tassetExports[k] = './' + pathFn.join(assetsDir, points[v].mjs);\n\t\t\tcontinue;\n\t\t}\n\t\tconst index = v.lastIndexOf('.');\n\t\tif (index <= 0) { continue; }\n\t\tconst name = v.slice(0, index);\n\t\tconst ext = v.slice(index + 1);\n\t\tconst value = points[name]?.[ext];\n\t\tif (!value) { continue; }\n\t\tassetExports[k] = './' + pathFn.join(assetsDir, value);\n\t}\n\tif (exports || Object.keys(assetExports).length) {\n\t\tpkg.exports = {...getObjectProp(pkg, 'exports'), ...assetExports, ...exports};\n\t}\n\tconst main = exports && Object.hasOwn(exports, '.') && exports['.']\n\t\t|| Object.hasOwn(assetExports, '.') && assetExports['.'];\n\tif (main) {\n\t\tpkg.main = main;\n\t\tpkg.type = 'module';\n\t\tdelete pkg.types;\n\t}\n\tif (imports) {\n\t\tpkg.imports = {...getObjectProp(pkg, 'imports'), ...imports}\n\t}\n\tif (typeof bin === 'string') {\n\t\tpkg.bin = bin;\n\t} else if (bin) {\n\t\tpkg.bin = {...getObjectProp(pkg, 'bin'), ...bin};\n\t}\n\tawait updateVersion(pkg, 'dependencies');\n\tawait updateVersion(pkg, 'devDependencies');\n\tawait updateVersion(pkg, 'peerDependencies');\n\tawait updateVersion(pkg, 'optionalDependencies');\n\tawait updateVersion(pkg, 'bundledDependencies');\n\tdelete pkg.private;\n\tawait writeCfg(pathFn.join(distRoot, 'package.json'), pkg, 2);\n}\n","import * as pathFn from 'node:path';\nimport * as fsPromises from 'node:fs/promises';\nimport { assetsBuild, assetsDir, importmap, nodeModules, distRoot } from './config.mjs';\n\n/**\n * \n * @param {Record<string, Record<string, string>>} [points] \n * @param {string[]} [polyfill] \n */\nexport default async function buildAssetsMjs(points, polyfill) {\n\t/** @type {string[]} */\n\tconst scripts = [];\n\t/** @type {Record<string, string>} */\n\tconst files = {};\n\t/** @type {Record<string, string>} */\n\tconst mjs = {};\n\t/** @type {Record<string, string>} */\n\tconst css = {};\n\tfor (const [point, values] of Object.entries(points || {})) {\n\t\tfor (const [type, value] of Object.entries(values)) {\n\t\t\tif (type === 'mjs') continue;\n\t\t\tfiles[`${point}.${type}`] = value;\n\t\t}\n\t\tif ('mjs' in values) { mjs[point] = values.mjs; }\n\t\tif ('css' in values) { css[point] = values.css; }\n\t}\n\tif (Object.keys(files).length) {\n\t\tscripts.push(`export const files = ${JSON.stringify(files)};\\n`);\n\t}\n\n\tconst alias = assetsBuild?.alias;\n\tif (alias && Object.keys(alias).length) {\n\t\tscripts.push(`export const alias = ${JSON.stringify(alias)};\\n`);\n\t}\n\tif (Object.keys(mjs).length) {\n\t\tscripts.push(`export const esm = ${JSON.stringify(mjs)};\\n`);\n\t}\n\tif (importmap) {\n\t\tscripts.push(`export const importmap = ${JSON.stringify(importmap)};\\n`);\n\t}\n\tconst hooks = assetsBuild?.hooks;\n\tconst styles = assetsBuild?.styles?.map(v => Object.hasOwn(css, v) ? css[v] : '').filter(Boolean);\n\tif (styles?.length) {\n\t\tscripts.push(`export const styles = ${JSON.stringify(styles)};\\n`);\n\t}\n\tif (typeof hooks === 'string') {\n\t\tscripts.push(`export const hooks = ${JSON.stringify(hooks)};\\n`);\n\t}\n\tif (nodeModules) {\n\t\tscripts.push(`export const nodeModules = ${JSON.stringify(nodeModules)};\\n`);\n\t}\n\n\tif (polyfill?.length) {\n\t\tscripts.push(`export const polyfill = ${JSON.stringify(polyfill)};\\n`);\n\t}\n\tif (!scripts.length) { return; }\n\tif (assetsDir && assetsDir !== '.') {\n\t\tscripts.push(`export const dir = ${JSON.stringify(assetsDir)};\\n`);\n\t}\n\n\n\tawait fsPromises.writeFile(pathFn.join(distRoot, 'assets.yongdall.mjs'), scripts.join(''));\n}\n","import * as pathFn from 'node:path';\nimport * as pathPosix from 'node:path/posix';\nimport { rolldown } from 'rolldown';\nimport commonjs from '@rollup/plugin-commonjs';\nimport { assetsDir, distRoot, root, assetsBuild } from './config.mjs';\n\n\nexport default async function buildPolyfill() {\n\tif (!assetsBuild) { return; }\n\tconst assetRoot = pathFn.join(root, assetsBuild.dir || '');\n\tconst outdir = pathPosix.join(distRoot, assetsDir);\n\tconst list = assetsBuild.polyfill?.map(v => pathFn.join(assetRoot, v)).filter(Boolean) || [];\n\tif (!list.length) { return; }\n\n\n\tconst input = list;\n\tconst mainBundle = await rolldown({\n\t\tinput,\n\t\tplugins: [commonjs()],\n\t});\n\tconst result = await mainBundle.write({\n\t\tdir: outdir,\n\t\tformat: 'iife',\n\t\tsourcemap: assetsBuild.sourcemap !== false,\n\t\tentryFileNames: '[name].js',\n\t\tminify: true,\n\t\tname: `polyfill_${Date.now()}_${`${Math.random()}`.slice(2)}`\n\t});\n\n\n\t/** @type {string[]} */\n\tconst polyfill = [];\n\tfor (const { fileName } of result.output) {\n\t\tconst ext = pathPosix.extname(fileName);\n\t\tif (ext === '.map') { continue; }\n\t\tpolyfill.push(fileName);\n\t}\n\treturn polyfill;\n}\n","#!/usr/bin/env node\nimport * as pathFn from 'node:path';\nimport buildAssets from './buildAssets.mjs';\nimport { assetsRoot, copyFiles, distRoot, root } from './config.mjs';\nimport copy from './copy.mjs';\nimport buildBack from './buildBack.mjs';\nimport buildPackage from './buildPackage.mjs';\nimport buildAssetsMjs from './buildAssetsMjs.mjs';\nimport buildPolyfill from './buildPolyfill.mjs';\nfor (const g of copyFiles) {\n\tif (typeof g === 'string') {\n\t\tawait copy(pathFn.join(root, g), pathFn.join(distRoot, g));\n\t\tcontinue;\n\t}\n\tconst { files, from, to, assets } = g;\n\tfor (const file of [files].flat()) {\n\t\tawait copy(\n\t\t\tpathFn.join(root, from || '', file),\n\t\t\tpathFn.join(assets ? assetsRoot : distRoot, to || '', file),\n\t\t);\n\t}\n}\nconst points = await build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-0,0 +1,20 @@
1
+ {
2
+ "name": "@yongdall/build",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "bin": {
6
+ "build.yongdall": "./index.mjs"
7
+ },
8
+ "main": "index.mjs",
9
+ "imports": {
10
+ "#index": "./index.mjs"
11
+ },
12
+ "dependencies": {
13
+ "@rollup/plugin-alias": "^6.0.0",
14
+ "@rollup/plugin-commonjs": "^29.0.0",
15
+ "@yongdall/load-configuration": "^0.1.0",
16
+ "rolldown": "1.0.0-rc.2",
17
+ "rolldown-plugin-dts": "^0.21.8",
18
+ "typescript": "^5.8.3"
19
+ }
20
+ }