@reliverse/dler 1.7.62 → 1.7.64
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/bin/libs/cfg/cfg-impl/rse-config/rse-impl/rse-create.js +25 -4
- package/bin/libs/cfg/cfg-impl/rse-config/rse-impl/rse-define.d.ts +14 -14
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +260 -286
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.js +183 -193
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-mod.js +76 -91
- package/bin/libs/sdk/sdk-impl/config/info.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve, extname, join, basename, dirname } from "@reliverse/pathkit";
|
|
2
|
-
import {
|
|
2
|
+
import { relinka } from "@reliverse/relinka";
|
|
3
3
|
import defu from "defu";
|
|
4
4
|
import fsp from "node:fs/promises";
|
|
5
5
|
import { glob } from "tinyglobby";
|
|
@@ -8,206 +8,196 @@ import { getDeclarations, normalizeCompilerOptions } from "./utils/dts.js";
|
|
|
8
8
|
import { copyFileWithStream } from "./utils/fs.js";
|
|
9
9
|
import { getVueDeclarations } from "./utils/vue-dts.js";
|
|
10
10
|
export async function mkdist(options = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
const startTime = Date.now();
|
|
12
|
+
options.rootDir = resolve(process.cwd(), options.rootDir || ".");
|
|
13
|
+
options.srcDir = resolve(options.rootDir, options.srcDir || "src");
|
|
14
|
+
options.distDir = resolve(options.rootDir, options.distDir || "dist");
|
|
15
|
+
if (options.cleanDist !== false) {
|
|
16
|
+
relinka("info", "Cleaning distribution directory...");
|
|
17
|
+
await fsp.unlink(options.distDir).catch(() => {
|
|
18
|
+
});
|
|
19
|
+
await fsp.rm(options.distDir, { recursive: true, force: true });
|
|
20
|
+
await fsp.mkdir(options.distDir, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
relinka("info", "Scanning input files...");
|
|
23
|
+
const filePaths = await glob(options.pattern || "**", {
|
|
24
|
+
absolute: false,
|
|
25
|
+
ignore: ["**/node_modules", "**/coverage", "**/.git"],
|
|
26
|
+
cwd: options.srcDir,
|
|
27
|
+
dot: true,
|
|
28
|
+
...options.globOptions
|
|
29
|
+
});
|
|
30
|
+
const files = filePaths.map((path) => {
|
|
31
|
+
const sourcePath = resolve(options.srcDir, path);
|
|
32
|
+
return {
|
|
33
|
+
path,
|
|
34
|
+
srcPath: sourcePath,
|
|
35
|
+
extension: extname(path),
|
|
36
|
+
getContents: () => fsp.readFile(sourcePath, { encoding: "utf8" })
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
relinka("info", `Found ${files.length} files to process`);
|
|
40
|
+
options.typescript ||= {};
|
|
41
|
+
if (options.typescript.compilerOptions) {
|
|
42
|
+
relinka("info", "Normalizing TypeScript compiler options...");
|
|
43
|
+
options.typescript.compilerOptions = await normalizeCompilerOptions(
|
|
44
|
+
options.typescript.compilerOptions
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
options.typescript.compilerOptions = defu(
|
|
48
|
+
{ noEmit: false },
|
|
49
|
+
options.typescript.compilerOptions,
|
|
50
|
+
{
|
|
51
|
+
allowJs: true,
|
|
52
|
+
declaration: true,
|
|
53
|
+
skipLibCheck: true,
|
|
54
|
+
strictNullChecks: true,
|
|
55
|
+
emitDeclarationOnly: true,
|
|
56
|
+
allowImportingTsExtensions: true,
|
|
57
|
+
allowNonTsExtensions: true
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
relinka("info", "Creating file loaders...");
|
|
61
|
+
const { loadFile } = createLoader(options);
|
|
62
|
+
relinka("info", "Processing files with loaders...");
|
|
63
|
+
const outputs = [];
|
|
64
|
+
let processedCount = 0;
|
|
65
|
+
await Promise.all(
|
|
66
|
+
files.map(async (file) => {
|
|
67
|
+
const result = await loadFile(file);
|
|
68
|
+
if (result) {
|
|
69
|
+
outputs.push(...result);
|
|
22
70
|
}
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
cwd: options.srcDir,
|
|
28
|
-
dot: true,
|
|
29
|
-
...options.globOptions
|
|
30
|
-
});
|
|
31
|
-
const files = filePaths.map((path) => {
|
|
32
|
-
const sourcePath = resolve(options.srcDir, path);
|
|
33
|
-
return {
|
|
34
|
-
path,
|
|
35
|
-
srcPath: sourcePath,
|
|
36
|
-
extension: extname(path),
|
|
37
|
-
getContents: () => fsp.readFile(sourcePath, { encoding: "utf8" })
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
mainSpinner.setText(`Found ${files.length} files to process`);
|
|
41
|
-
options.typescript ||= {};
|
|
42
|
-
if (options.typescript.compilerOptions) {
|
|
43
|
-
mainSpinner.setText("Normalizing TypeScript compiler options...");
|
|
44
|
-
options.typescript.compilerOptions = await normalizeCompilerOptions(
|
|
45
|
-
options.typescript.compilerOptions
|
|
46
|
-
);
|
|
71
|
+
processedCount++;
|
|
72
|
+
const shouldUpdate = processedCount % Math.max(1, Math.floor(files.length / 10)) === 0 || processedCount === files.length;
|
|
73
|
+
if (shouldUpdate) {
|
|
74
|
+
relinka("verbose", `Processing files: ${file.path} (${processedCount}/${files.length})`);
|
|
47
75
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
mainSpinner.setText(`Processing files: ${file.path}`);
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
);
|
|
83
|
-
mainSpinner.setText("Normalizing output extensions...");
|
|
84
|
-
const pathConflicts = [];
|
|
85
|
-
for (const output of outputs.filter((o) => o.extension)) {
|
|
86
|
-
const renamed = basename(output.path, extname(output.path)) + output.extension;
|
|
87
|
-
output.path = join(dirname(output.path), renamed);
|
|
88
|
-
const conflictingOutput = outputs.find((o) => o !== output && o.path === output.path);
|
|
89
|
-
if (conflictingOutput) {
|
|
90
|
-
pathConflicts.push(output.path);
|
|
91
|
-
}
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
relinka("info", "Normalizing output extensions...");
|
|
79
|
+
const pathConflicts = [];
|
|
80
|
+
for (const output of outputs.filter((o) => o.extension)) {
|
|
81
|
+
const renamed = basename(output.path, extname(output.path)) + output.extension;
|
|
82
|
+
output.path = join(dirname(output.path), renamed);
|
|
83
|
+
const conflictingOutput = outputs.find((o) => o !== output && o.path === output.path);
|
|
84
|
+
if (conflictingOutput) {
|
|
85
|
+
pathConflicts.push(output.path);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (pathConflicts.length > 0) {
|
|
89
|
+
const errorMessage = `Output path conflict detected for paths: ${pathConflicts.join(", ")}. Multiple files would write to the same output path.`;
|
|
90
|
+
relinka("error", errorMessage);
|
|
91
|
+
throw new Error(errorMessage);
|
|
92
|
+
}
|
|
93
|
+
const dtsOutputs = outputs.filter((o) => o.declaration && !o.skip);
|
|
94
|
+
if (dtsOutputs.length > 0) {
|
|
95
|
+
relinka("info", `Generating TypeScript declarations for ${dtsOutputs.length} files...`);
|
|
96
|
+
const vfs = new Map(dtsOutputs.map((o) => [o.srcPath, o.contents || ""]));
|
|
97
|
+
const declarations = /* @__PURE__ */ Object.create(null);
|
|
98
|
+
for (const loader of [getVueDeclarations, getDeclarations]) {
|
|
99
|
+
Object.assign(declarations, await loader(vfs, options));
|
|
100
|
+
}
|
|
101
|
+
let dtsProcessed = 0;
|
|
102
|
+
for (const output of dtsOutputs) {
|
|
103
|
+
const result = declarations[output.srcPath];
|
|
104
|
+
output.contents = result?.contents || "";
|
|
105
|
+
if (result.errors) {
|
|
106
|
+
output.errors = result.errors;
|
|
92
107
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
throw new Error(errorMessage);
|
|
108
|
+
dtsProcessed++;
|
|
109
|
+
if (dtsProcessed % Math.max(1, Math.floor(dtsOutputs.length / 5)) === 0) {
|
|
110
|
+
relinka("verbose", `Generated declarations for ${dtsProcessed}/${dtsOutputs.length} files`);
|
|
97
111
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
output.contents = result?.contents || "";
|
|
110
|
-
if (result.errors) {
|
|
111
|
-
output.errors = result.errors;
|
|
112
|
-
}
|
|
113
|
-
dtsProcessed++;
|
|
114
|
-
if (dtsProcessed % Math.max(1, Math.floor(dtsOutputs.length / 5)) === 0) {
|
|
115
|
-
mainSpinner.setProgress({
|
|
116
|
-
current: dtsProcessed,
|
|
117
|
-
total: dtsOutputs.length
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
relinka("info", "Resolving relative imports...");
|
|
115
|
+
const outPaths = new Set(outputs.map((o) => o.path));
|
|
116
|
+
const resolveId = (from, id = "", resolveExtensions) => {
|
|
117
|
+
if (!id.startsWith(".")) {
|
|
118
|
+
return id;
|
|
119
|
+
}
|
|
120
|
+
for (const extension of resolveExtensions) {
|
|
121
|
+
if (outPaths.has(join(dirname(from), id + extension))) {
|
|
122
|
+
return id + extension;
|
|
121
123
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
124
|
+
}
|
|
125
|
+
return id;
|
|
126
|
+
};
|
|
127
|
+
const esmResolveExtensions = ["", "/index.mjs", "/index.js", ".mjs", ".ts", ".js"];
|
|
128
|
+
const esmOutputs = outputs.filter((o) => o.extension === ".mjs" || o.extension === ".js");
|
|
129
|
+
for (const output of esmOutputs) {
|
|
130
|
+
output.contents = output.contents.replace(
|
|
131
|
+
/(import|export)(\s+(?:.+|{[\s\w,]+})\s+from\s+["'])(.*)(["'])/g,
|
|
132
|
+
(_, type, head, id, tail) => type + head + resolveId(output.path, id, esmResolveExtensions) + tail
|
|
133
|
+
).replace(
|
|
134
|
+
/import\((["'])(.*)(["'])\)/g,
|
|
135
|
+
(_, head, id, tail) => "import(" + head + resolveId(output.path, id, esmResolveExtensions) + tail + ")"
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
const cjsResolveExtensions = ["", "/index.cjs", ".cjs"];
|
|
139
|
+
const cjsOutputs = outputs.filter((o) => o.extension === ".cjs");
|
|
140
|
+
for (const output of cjsOutputs) {
|
|
141
|
+
output.contents = output.contents.replace(
|
|
142
|
+
/require\((["'])(.*)(["'])\)/g,
|
|
143
|
+
(_, head, id, tail) => "require(" + head + resolveId(output.path, id, cjsResolveExtensions) + tail + ")"
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
const outputsToWrite = outputs.filter((o) => !o.skip);
|
|
147
|
+
relinka("info", `Writing ${outputsToWrite.length} output files...`);
|
|
148
|
+
const writtenFiles = [];
|
|
149
|
+
const errors = [];
|
|
150
|
+
let writtenCount = 0;
|
|
151
|
+
await Promise.all(
|
|
152
|
+
outputsToWrite.map(async (output) => {
|
|
153
|
+
try {
|
|
154
|
+
const outFile = join(options.distDir, output.path);
|
|
155
|
+
await fsp.mkdir(dirname(outFile), { recursive: true });
|
|
156
|
+
await (output.raw ? (
|
|
157
|
+
// @ts-expect-error TODO: fix ts
|
|
158
|
+
copyFileWithStream(output.srcPath, outFile)
|
|
159
|
+
) : (
|
|
160
|
+
// @ts-expect-error TODO: fix ts
|
|
161
|
+
fsp.writeFile(outFile, output.contents, "utf8")
|
|
162
|
+
));
|
|
163
|
+
writtenFiles.push(outFile);
|
|
164
|
+
if (output.errors) {
|
|
165
|
+
errors.push({ filename: outFile, errors: output.errors });
|
|
132
166
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/(import|export)(\s+(?:.+|{[\s\w,]+})\s+from\s+["'])(.*)(["'])/g,
|
|
140
|
-
(_, type, head, id, tail) => type + head + resolveId(output.path, id, esmResolveExtensions) + tail
|
|
141
|
-
).replace(
|
|
142
|
-
/import\((["'])(.*)(["'])\)/g,
|
|
143
|
-
(_, head, id, tail) => "import(" + head + resolveId(output.path, id, esmResolveExtensions) + tail + ")"
|
|
144
|
-
);
|
|
167
|
+
} catch (error) {
|
|
168
|
+
const errorMessage = `Failed to write file ${output.path}: ${error instanceof Error ? error.message : "Unknown error"}`;
|
|
169
|
+
errors.push({
|
|
170
|
+
filename: output.path,
|
|
171
|
+
errors: [new TypeError(errorMessage)]
|
|
172
|
+
});
|
|
145
173
|
}
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
/require\((["'])(.*)(["'])\)/g,
|
|
151
|
-
(_, head, id, tail) => "require(" + head + resolveId(output.path, id, cjsResolveExtensions) + tail + ")"
|
|
152
|
-
);
|
|
174
|
+
writtenCount++;
|
|
175
|
+
const progressUpdateInterval = Math.max(10, Math.floor(outputsToWrite.length / 10));
|
|
176
|
+
if (writtenCount % progressUpdateInterval === 0 || writtenCount === outputsToWrite.length) {
|
|
177
|
+
relinka("verbose", `Written ${writtenCount}/${outputsToWrite.length} files`);
|
|
153
178
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
await fsp.mkdir(dirname(outFile), { recursive: true });
|
|
164
|
-
await (output.raw ? (
|
|
165
|
-
// @ts-expect-error TODO: fix ts
|
|
166
|
-
copyFileWithStream(output.srcPath, outFile)
|
|
167
|
-
) : (
|
|
168
|
-
// @ts-expect-error TODO: fix ts
|
|
169
|
-
fsp.writeFile(outFile, output.contents, "utf8")
|
|
170
|
-
));
|
|
171
|
-
writtenFiles.push(outFile);
|
|
172
|
-
if (output.errors) {
|
|
173
|
-
errors.push({ filename: outFile, errors: output.errors });
|
|
174
|
-
}
|
|
175
|
-
} catch (error) {
|
|
176
|
-
const errorMessage = `Failed to write file ${output.path}: ${error instanceof Error ? error.message : "Unknown error"}`;
|
|
177
|
-
errors.push({
|
|
178
|
-
filename: output.path,
|
|
179
|
-
errors: [new TypeError(errorMessage)]
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
writtenCount++;
|
|
183
|
-
const progressUpdateInterval = Math.max(10, Math.floor(outputsToWrite.length / 10));
|
|
184
|
-
if (writtenCount % progressUpdateInterval === 0 || writtenCount === outputsToWrite.length) {
|
|
185
|
-
mainSpinner.setProgress({
|
|
186
|
-
current: writtenCount,
|
|
187
|
-
total: outputsToWrite.length
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
})
|
|
179
|
+
})
|
|
180
|
+
);
|
|
181
|
+
const duration = Date.now() - startTime;
|
|
182
|
+
if (errors.length > 0) {
|
|
183
|
+
relinka("warn", `Build completed with ${errors.length} errors`);
|
|
184
|
+
for (const error of errors.slice(0, 5)) {
|
|
185
|
+
relinka(
|
|
186
|
+
"error",
|
|
187
|
+
`Error in ${error.filename}: ${error.errors[0]?.message || "Unknown error"}`
|
|
191
188
|
);
|
|
192
|
-
if (errors.length > 0) {
|
|
193
|
-
mainSpinner.warn(`Build completed with ${errors.length} errors`);
|
|
194
|
-
for (const error of errors.slice(0, 5)) {
|
|
195
|
-
console.error(`Error in ${error.filename}:`, error.errors[0]?.message || "Unknown error");
|
|
196
|
-
}
|
|
197
|
-
if (errors.length > 5) {
|
|
198
|
-
console.error(`... and ${errors.length - 5} more errors`);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
errors,
|
|
203
|
-
writtenFiles
|
|
204
|
-
};
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
text: "Building using mkdist...",
|
|
208
|
-
color: "cyan",
|
|
209
|
-
successText: "Build completed successfully!",
|
|
210
|
-
failText: "Build failed!"
|
|
211
189
|
}
|
|
212
|
-
|
|
190
|
+
if (errors.length > 5) {
|
|
191
|
+
relinka("error", `... and ${errors.length - 5} more errors`);
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
relinka("success", "Build completed successfully!");
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
result: {
|
|
198
|
+
errors,
|
|
199
|
+
writtenFiles
|
|
200
|
+
},
|
|
201
|
+
duration
|
|
202
|
+
};
|
|
213
203
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { relative, dirname as pathDirname } from "@reliverse/pathkit";
|
|
2
2
|
import { relinka } from "@reliverse/relinka";
|
|
3
|
-
import { useSpinner } from "@reliverse/rempts";
|
|
4
3
|
import { rmdir, symlink, warn } from "../utils.js";
|
|
5
4
|
import { mkdist } from "./mkdist-impl/make.js";
|
|
6
5
|
export async function mkdistBuild(ctx) {
|
|
@@ -8,100 +7,86 @@ export async function mkdistBuild(ctx) {
|
|
|
8
7
|
if (entries.length === 0) {
|
|
9
8
|
return;
|
|
10
9
|
}
|
|
11
|
-
await
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
path: distDir,
|
|
64
|
-
isLib: ctx.options.isLib
|
|
65
|
-
});
|
|
66
|
-
await ctx.hooks.callHook("mkdist:entry:build", ctx, entry, output);
|
|
67
|
-
if (output.errors && output.errors.length > 0) {
|
|
68
|
-
totalErrors += output.errors.length;
|
|
69
|
-
for (const error of output.errors) {
|
|
70
|
-
warn(
|
|
71
|
-
ctx,
|
|
72
|
-
`mkdist build failed for \`${relative(ctx.options.rootDir, error.filename)}\`:
|
|
73
|
-
${error.errors.map((e) => ` - ${e}`).join("\n")}`
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
} catch (error) {
|
|
78
|
-
totalErrors++;
|
|
10
|
+
await ctx.hooks.callHook("mkdist:entries", ctx, entries);
|
|
11
|
+
let processedEntries = 0;
|
|
12
|
+
let totalWrittenFiles = 0;
|
|
13
|
+
let totalErrors = 0;
|
|
14
|
+
relinka("info", `Processing ${entries.length} mkdist entries...`);
|
|
15
|
+
for (const entry of entries) {
|
|
16
|
+
processedEntries++;
|
|
17
|
+
relinka("info", `Processing entry ${processedEntries}/${entries.length}: ${entry.input}`);
|
|
18
|
+
const distDir = entry.outDir || entry.input;
|
|
19
|
+
if (ctx.options.transpileStub) {
|
|
20
|
+
await rmdir(distDir);
|
|
21
|
+
await symlink(entry.input, distDir);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
let srcDir;
|
|
25
|
+
if (typeof entry.input === "string" && !entry.input.endsWith("/")) {
|
|
26
|
+
srcDir = ctx.options.isLib ? pathDirname(entry.input) : entry.input;
|
|
27
|
+
relinka(
|
|
28
|
+
"verbose",
|
|
29
|
+
`[mkdist] Using directory from file path: ${srcDir} (from: ${entry.input})`
|
|
30
|
+
);
|
|
31
|
+
} else {
|
|
32
|
+
srcDir = entry.input;
|
|
33
|
+
relinka("verbose", `[mkdist] Using directory directly: ${srcDir}`);
|
|
34
|
+
}
|
|
35
|
+
const mkdistOptions = {
|
|
36
|
+
cleanDist: false,
|
|
37
|
+
distDir,
|
|
38
|
+
rootDir: ctx.options.rootDir,
|
|
39
|
+
srcDir,
|
|
40
|
+
format: "esm",
|
|
41
|
+
ext: entry.ext || "js",
|
|
42
|
+
...entry
|
|
43
|
+
};
|
|
44
|
+
relinka(
|
|
45
|
+
"info",
|
|
46
|
+
`[mkdist] Building with options: srcDir=${mkdistOptions.srcDir}, distDir=${mkdistOptions.distDir}, rootDir=${mkdistOptions.rootDir}`
|
|
47
|
+
);
|
|
48
|
+
await ctx.hooks.callHook("mkdist:entry:options", ctx, entry, mkdistOptions);
|
|
49
|
+
try {
|
|
50
|
+
const { result: output, duration } = await mkdist(mkdistOptions);
|
|
51
|
+
relinka("verbose", `[mkdist] Entry ${processedEntries} completed in ${duration}ms`);
|
|
52
|
+
totalWrittenFiles += output.writtenFiles.length;
|
|
53
|
+
ctx.buildEntries.push({
|
|
54
|
+
chunks: output.writtenFiles.map((p) => relative(ctx.options.outDir, p)),
|
|
55
|
+
path: distDir,
|
|
56
|
+
isLib: ctx.options.isLib
|
|
57
|
+
});
|
|
58
|
+
await ctx.hooks.callHook("mkdist:entry:build", ctx, entry, output);
|
|
59
|
+
if (output.errors && output.errors.length > 0) {
|
|
60
|
+
totalErrors += output.errors.length;
|
|
61
|
+
for (const error of output.errors) {
|
|
79
62
|
warn(
|
|
80
63
|
ctx,
|
|
81
|
-
`mkdist build failed for
|
|
64
|
+
`mkdist build failed for \`${relative(ctx.options.rootDir, error.filename)}\`:
|
|
65
|
+
${error.errors.map((e) => ` - ${e}`).join("\n")}`
|
|
82
66
|
);
|
|
83
67
|
}
|
|
84
68
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
`Processed ${entries.length} entries with ${totalErrors} errors. ${totalWrittenFiles} files written.`
|
|
92
|
-
);
|
|
93
|
-
} else {
|
|
94
|
-
mainSpinner.setText(
|
|
95
|
-
`Successfully processed ${entries.length} entries. ${totalWrittenFiles} files written.`
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
text: entries.length === 1 ? "Processing mkdist entry..." : `Processing ${entries.length} mkdist entries...`,
|
|
101
|
-
color: "blue",
|
|
102
|
-
successText: entries.length === 1 ? "mkdist entry completed!" : `All ${entries.length} mkdist entries completed!`,
|
|
103
|
-
failText: "mkdist build failed!",
|
|
104
|
-
prefixText: "[mkdist]"
|
|
69
|
+
} catch (error) {
|
|
70
|
+
totalErrors++;
|
|
71
|
+
warn(
|
|
72
|
+
ctx,
|
|
73
|
+
`mkdist build failed for entry ${entry.input}: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
74
|
+
);
|
|
105
75
|
}
|
|
106
|
-
|
|
76
|
+
}
|
|
77
|
+
await ctx.hooks.callHook("mkdist:done", ctx);
|
|
78
|
+
if (entries.length > 0 && ctx.options.transpileWatch) {
|
|
79
|
+
relinka("warn", "`mkdist` builder does not support transpileWatch mode yet.");
|
|
80
|
+
}
|
|
81
|
+
if (totalErrors > 0) {
|
|
82
|
+
relinka(
|
|
83
|
+
"warn",
|
|
84
|
+
`Processed ${entries.length} entries with ${totalErrors} errors. ${totalWrittenFiles} files written.`
|
|
85
|
+
);
|
|
86
|
+
} else {
|
|
87
|
+
relinka(
|
|
88
|
+
"success",
|
|
89
|
+
`Successfully processed ${entries.length} entries. ${totalWrittenFiles} files written.`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
107
92
|
}
|