@reliverse/dler 1.7.7 → 1.7.9
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/LICENSES +1 -0
- package/README.md +1 -1
- package/bin/app/agg/impl.js +9 -25
- package/bin/app/agg/run.js +1 -6
- package/bin/app/build/impl.js +3 -17
- package/bin/app/check/cmd.js +3 -12
- package/bin/app/conv/cmd.js +7 -25
- package/bin/app/copy/cmd.js +2 -7
- package/bin/app/init/cmd.js +1 -5
- package/bin/app/init/init-const.js +2 -11
- package/bin/app/init/init-impl.js +9 -30
- package/bin/app/init/{templates/t-readme.d.ts → init-tmpl.d.ts} +2 -0
- package/bin/app/init/{templates/t-readme.js → init-tmpl.js} +27 -0
- package/bin/app/inject/impl.js +4 -7
- package/bin/app/libs/cmd.js +4 -13
- package/bin/app/merge/cmd.js +8 -28
- package/bin/app/migrate/cmd.js +11 -44
- package/bin/app/migrate/codemods/anything-bun.js +13 -34
- package/bin/app/migrate/codemods/commander-rempts.js +4 -12
- package/bin/app/migrate/codemods/console-relinka.js +12 -27
- package/bin/app/migrate/codemods/fs-relifso.js +20 -43
- package/bin/app/migrate/codemods/nodenext-bundler.js +6 -14
- package/bin/app/migrate/codemods/path-pathkit.js +16 -42
- package/bin/app/migrate/codemods/readdir-glob.js +11 -22
- package/bin/app/mkdist/cmd.d.ts +83 -0
- package/bin/app/mkdist/cmd.js +121 -0
- package/bin/app/rempts/cmd.js +13 -35
- package/bin/app/rename/cmd.js +6 -15
- package/bin/app/spell/cmd.js +1 -3
- package/bin/app/split/cmd.js +1 -5
- package/bin/app/split/impl.js +1 -6
- package/bin/libs/sdk/sdk-impl/build/build-library.js +36 -123
- package/bin/libs/sdk/sdk-impl/build/build-regular.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/build/build-regular.js +28 -66
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/auto.js +4 -16
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +97 -89
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/{copy.js → copy-mod.js} +4 -18
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loader.d.ts +4 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loader.js +26 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/js.d.ts +2 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/js.js +49 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/loaders-mod.d.ts +12 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/loaders-mod.js +30 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/postcss.d.ts +3 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/postcss.js +28 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/sass.d.ts +2 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/sass.js +31 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/vue.d.ts +17 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/vue.js +145 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.d.ts +8 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.js +133 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/dts.d.ts +11 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/dts.js +94 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/fs.d.ts +1 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/fs.js +15 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/vue-dts.d.ts +3 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/vue-dts.js +175 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/{mkdist.js → mkdist-mod.js} +5 -19
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/build.js +2 -7
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/config.js +2 -9
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/stub.js +8 -26
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/utils.js +1 -4
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/watch.js +1 -4
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/{index.js → untyped-mod.js} +8 -22
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.js +3 -11
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/validate.js +4 -15
- package/bin/libs/sdk/sdk-impl/cfg/default.js +1 -9
- package/bin/libs/sdk/sdk-impl/cfg/info.js +1 -1
- package/bin/libs/sdk/sdk-impl/cfg/init.js +4 -16
- package/bin/libs/sdk/sdk-impl/cfg/load.js +1 -4
- package/bin/libs/sdk/sdk-impl/library-flow.js +3 -11
- package/bin/libs/sdk/sdk-impl/pub/pub-library.js +5 -22
- package/bin/libs/sdk/sdk-impl/pub/pub-regular.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/pub/pub-regular.js +3 -6
- package/bin/libs/sdk/sdk-impl/regular-flow.js +8 -26
- package/bin/libs/sdk/sdk-impl/rules/reliverse/file-extensions/file-extensions.js +1 -5
- package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/analyzer.js +2 -9
- package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/formatter.js +8 -20
- package/bin/libs/sdk/sdk-impl/rules/reliverse/package-json-health/package-json-health.js +1 -7
- package/bin/libs/sdk/sdk-impl/rules/reliverse/path-extensions/path-extensions.js +2 -5
- package/bin/libs/sdk/sdk-impl/rules/reliverse/self-include/self-include.js +3 -8
- package/bin/libs/sdk/sdk-impl/rules/rules-mod.js +4 -14
- package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.js +4 -8
- package/bin/libs/sdk/sdk-impl/spell/spell-parser.js +1 -3
- package/bin/libs/sdk/sdk-impl/utils/finalize.js +3 -14
- package/bin/libs/sdk/sdk-impl/utils/tools/tools-agg.js +5 -16
- package/bin/libs/sdk/sdk-impl/utils/utils-build.js +3 -11
- package/bin/libs/sdk/sdk-impl/utils/utils-clean.js +2 -5
- package/bin/libs/sdk/sdk-impl/utils/utils-consts.js +1 -8
- package/bin/libs/sdk/sdk-impl/utils/utils-cwd.js +1 -4
- package/bin/libs/sdk/sdk-impl/utils/utils-deps.js +14 -25
- package/bin/libs/sdk/sdk-impl/utils/utils-error.js +1 -5
- package/bin/libs/sdk/sdk-impl/utils/utils-fs.d.ts +14 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-fs.js +145 -37
- package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.js +2 -7
- package/bin/libs/sdk/sdk-impl/utils/utils-package-json-libraries.js +32 -86
- package/bin/libs/sdk/sdk-impl/utils/utils-package-json-regular.js +13 -61
- package/bin/libs/sdk/sdk-mod.d.ts +3 -3
- package/bin/libs/sdk/sdk-mod.js +3 -3
- package/bin/libs/sdk/sdk-types.d.ts +76 -12
- package/package.json +8 -3
- package/bin/app/init/templates/t-gitignore.d.ts +0 -1
- package/bin/app/init/templates/t-gitignore.js +0 -9
- package/bin/app/init/templates/t-license.d.ts +0 -1
- package/bin/app/init/templates/t-license.js +0 -18
- /package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/{copy.d.ts → copy-mod.d.ts} +0 -0
- /package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/{mkdist.d.ts → mkdist-mod.d.ts} +0 -0
- /package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/{index.d.ts → untyped-mod.d.ts} +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import defu from "defu";
|
|
2
|
+
import fsp from "node:fs/promises";
|
|
3
|
+
import { resolve, extname, join, basename, dirname } from "pathe";
|
|
4
|
+
import { glob } from "tinyglobby";
|
|
5
|
+
import { createLoader } from "./loader.js";
|
|
6
|
+
import { getDeclarations, normalizeCompilerOptions } from "./utils/dts.js";
|
|
7
|
+
import { copyFileWithStream } from "./utils/fs.js";
|
|
8
|
+
import { getVueDeclarations } from "./utils/vue-dts.js";
|
|
9
|
+
export async function mkdist(options = {}) {
|
|
10
|
+
options.rootDir = resolve(process.cwd(), options.rootDir || ".");
|
|
11
|
+
options.srcDir = resolve(options.rootDir, options.srcDir || "src");
|
|
12
|
+
options.distDir = resolve(options.rootDir, options.distDir || "dist");
|
|
13
|
+
if (options.cleanDist !== false) {
|
|
14
|
+
await fsp.unlink(options.distDir).catch(() => {
|
|
15
|
+
});
|
|
16
|
+
await fsp.rm(options.distDir, { recursive: true, force: true });
|
|
17
|
+
await fsp.mkdir(options.distDir, { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
const filePaths = await glob(options.pattern || "**", {
|
|
20
|
+
absolute: false,
|
|
21
|
+
ignore: ["**/node_modules", "**/coverage", "**/.git"],
|
|
22
|
+
cwd: options.srcDir,
|
|
23
|
+
dot: true,
|
|
24
|
+
...options.globOptions
|
|
25
|
+
});
|
|
26
|
+
const files = filePaths.map((path) => {
|
|
27
|
+
const sourcePath = resolve(options.srcDir, path);
|
|
28
|
+
return {
|
|
29
|
+
path,
|
|
30
|
+
srcPath: sourcePath,
|
|
31
|
+
extension: extname(path),
|
|
32
|
+
getContents: () => fsp.readFile(sourcePath, { encoding: "utf8" })
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
options.typescript ||= {};
|
|
36
|
+
if (options.typescript.compilerOptions) {
|
|
37
|
+
options.typescript.compilerOptions = await normalizeCompilerOptions(
|
|
38
|
+
options.typescript.compilerOptions
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
options.typescript.compilerOptions = defu(
|
|
42
|
+
{ noEmit: false },
|
|
43
|
+
options.typescript.compilerOptions,
|
|
44
|
+
{
|
|
45
|
+
allowJs: true,
|
|
46
|
+
declaration: true,
|
|
47
|
+
skipLibCheck: true,
|
|
48
|
+
strictNullChecks: true,
|
|
49
|
+
emitDeclarationOnly: true,
|
|
50
|
+
allowImportingTsExtensions: true,
|
|
51
|
+
allowNonTsExtensions: true
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
const { loadFile } = createLoader(options);
|
|
55
|
+
const outputs = [];
|
|
56
|
+
for (const file of files) {
|
|
57
|
+
outputs.push(...await loadFile(file) || []);
|
|
58
|
+
}
|
|
59
|
+
for (const output of outputs.filter((o) => o.extension)) {
|
|
60
|
+
const renamed = basename(output.path, extname(output.path)) + output.extension;
|
|
61
|
+
output.path = join(dirname(output.path), renamed);
|
|
62
|
+
if (outputs.some((o) => o !== output && o.path === output.path)) {
|
|
63
|
+
output.skip = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const dtsOutputs = outputs.filter((o) => o.declaration && !o.skip);
|
|
67
|
+
if (dtsOutputs.length > 0) {
|
|
68
|
+
const vfs = new Map(dtsOutputs.map((o) => [o.srcPath, o.contents || ""]));
|
|
69
|
+
const declarations = /* @__PURE__ */ Object.create(null);
|
|
70
|
+
for (const loader of [getVueDeclarations, getDeclarations]) {
|
|
71
|
+
Object.assign(declarations, await loader(vfs, options));
|
|
72
|
+
}
|
|
73
|
+
for (const output of dtsOutputs) {
|
|
74
|
+
const result = declarations[output.srcPath];
|
|
75
|
+
output.contents = result?.contents || "";
|
|
76
|
+
if (result.errors) {
|
|
77
|
+
output.errors = result.errors;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const outPaths = new Set(outputs.map((o) => o.path));
|
|
82
|
+
const resolveId = (from, id = "", resolveExtensions) => {
|
|
83
|
+
if (!id.startsWith(".")) {
|
|
84
|
+
return id;
|
|
85
|
+
}
|
|
86
|
+
for (const extension of resolveExtensions) {
|
|
87
|
+
if (outPaths.has(join(dirname(from), id + extension))) {
|
|
88
|
+
return id + extension;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return id;
|
|
92
|
+
};
|
|
93
|
+
const esmResolveExtensions = ["", "/index.mjs", "/index.js", ".mjs", ".ts", ".js"];
|
|
94
|
+
for (const output of outputs.filter((o) => o.extension === ".mjs" || o.extension === ".js")) {
|
|
95
|
+
output.contents = output.contents.replace(
|
|
96
|
+
/(import|export)(\s+(?:.+|{[\s\w,]+})\s+from\s+["'])(.*)(["'])/g,
|
|
97
|
+
(_, type, head, id, tail) => type + head + resolveId(output.path, id, esmResolveExtensions) + tail
|
|
98
|
+
).replace(
|
|
99
|
+
/import\((["'])(.*)(["'])\)/g,
|
|
100
|
+
(_, head, id, tail) => "import(" + head + resolveId(output.path, id, esmResolveExtensions) + tail + ")"
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const cjsResolveExtensions = ["", "/index.cjs", ".cjs"];
|
|
104
|
+
for (const output of outputs.filter((o) => o.extension === ".cjs")) {
|
|
105
|
+
output.contents = output.contents.replace(
|
|
106
|
+
/require\((["'])(.*)(["'])\)/g,
|
|
107
|
+
(_, head, id, tail) => "require(" + head + resolveId(output.path, id, cjsResolveExtensions) + tail + ")"
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
const writtenFiles = [];
|
|
111
|
+
const errors = [];
|
|
112
|
+
await Promise.all(
|
|
113
|
+
outputs.filter((o) => !o.skip).map(async (output) => {
|
|
114
|
+
const outFile = join(options.distDir, output.path);
|
|
115
|
+
await fsp.mkdir(dirname(outFile), { recursive: true });
|
|
116
|
+
await (output.raw ? (
|
|
117
|
+
// @ts-expect-error TODO: fix ts
|
|
118
|
+
copyFileWithStream(output.srcPath, outFile)
|
|
119
|
+
) : (
|
|
120
|
+
// @ts-expect-error TODO: fix ts
|
|
121
|
+
fsp.writeFile(outFile, output.contents, "utf8")
|
|
122
|
+
));
|
|
123
|
+
writtenFiles.push(outFile);
|
|
124
|
+
if (output.errors) {
|
|
125
|
+
errors.push({ filename: outFile, errors: output.errors });
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
);
|
|
129
|
+
return {
|
|
130
|
+
errors,
|
|
131
|
+
writtenFiles
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TSConfig } from "pkg-types";
|
|
2
|
+
import type { CompilerHost, EmitResult } from "typescript";
|
|
3
|
+
import type { MkdistOptions } from "../../../../../../../sdk-types.js";
|
|
4
|
+
export declare function normalizeCompilerOptions(_options: TSConfig["compilerOptions"]): Promise<any>;
|
|
5
|
+
export type DeclarationOutput = Record<string, {
|
|
6
|
+
contents: string;
|
|
7
|
+
errors?: Error[];
|
|
8
|
+
}>;
|
|
9
|
+
export declare function getDeclarations(vfs: Map<string, string>, opts?: MkdistOptions): Promise<DeclarationOutput>;
|
|
10
|
+
export declare function extractDeclarations(vfs: Map<string, string>, inputFiles: string[], opts?: MkdistOptions): DeclarationOutput;
|
|
11
|
+
export declare function augmentWithDiagnostics(result: EmitResult, output: DeclarationOutput, tsHost: CompilerHost, ts: typeof import("typescript")): void;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { findStaticImports, findDynamicImports, findExports, findTypeExports } from "mlly";
|
|
2
|
+
import { statSync } from "node:fs";
|
|
3
|
+
import { resolve } from "pathe";
|
|
4
|
+
export async function normalizeCompilerOptions(_options) {
|
|
5
|
+
const ts = await import("typescript").then((r) => r.default || r);
|
|
6
|
+
return ts.convertCompilerOptionsFromJson(_options, process.cwd()).options;
|
|
7
|
+
}
|
|
8
|
+
export async function getDeclarations(vfs, opts) {
|
|
9
|
+
const ts = await import("typescript").then((r) => r.default || r);
|
|
10
|
+
const inputFiles = [...vfs.keys()];
|
|
11
|
+
const tsHost = ts.createCompilerHost(opts.typescript.compilerOptions);
|
|
12
|
+
tsHost.writeFile = (fileName, declaration) => {
|
|
13
|
+
vfs.set(fileName, declaration);
|
|
14
|
+
};
|
|
15
|
+
const _readFile = tsHost.readFile;
|
|
16
|
+
tsHost.readFile = (filename) => {
|
|
17
|
+
if (vfs.has(filename)) {
|
|
18
|
+
return vfs.get(filename);
|
|
19
|
+
}
|
|
20
|
+
return _readFile(filename);
|
|
21
|
+
};
|
|
22
|
+
const program = ts.createProgram(inputFiles, opts.typescript.compilerOptions, tsHost);
|
|
23
|
+
const result = program.emit();
|
|
24
|
+
const output = extractDeclarations(vfs, inputFiles, opts);
|
|
25
|
+
augmentWithDiagnostics(result, output, tsHost, ts);
|
|
26
|
+
return output;
|
|
27
|
+
}
|
|
28
|
+
const JS_EXT_RE = /\.(m|c)?(ts|js)$/;
|
|
29
|
+
const JSX_EXT_RE = /\.(m|c)?(ts|js)x?$/;
|
|
30
|
+
const RELATIVE_RE = /^\.{1,2}[/\\]/;
|
|
31
|
+
export function extractDeclarations(vfs, inputFiles, opts) {
|
|
32
|
+
const output = {};
|
|
33
|
+
for (const filename of inputFiles) {
|
|
34
|
+
const dtsFilename = filename.replace(JSX_EXT_RE, ".d.$1ts");
|
|
35
|
+
let contents = vfs.get(dtsFilename) || "";
|
|
36
|
+
if (opts?.addRelativeDeclarationExtensions) {
|
|
37
|
+
const ext = filename.match(JS_EXT_RE)?.[0].replace(/ts$/, "js") || ".js";
|
|
38
|
+
const imports = findStaticImports(contents);
|
|
39
|
+
const exports = findExports(contents);
|
|
40
|
+
const typeExports = findTypeExports(contents);
|
|
41
|
+
const dynamicImports = findDynamicImports(contents).map((dynamicImport) => {
|
|
42
|
+
let specifier;
|
|
43
|
+
try {
|
|
44
|
+
const value = JSON.parse(dynamicImport.expression);
|
|
45
|
+
if (typeof value === "string") {
|
|
46
|
+
specifier = value;
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
code: dynamicImport.code,
|
|
52
|
+
specifier
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
for (const spec of [...exports, ...typeExports, ...imports, ...dynamicImports]) {
|
|
56
|
+
if (!spec.specifier || !RELATIVE_RE.test(spec.specifier)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const srcPath = resolve(filename, "..", spec.specifier);
|
|
60
|
+
const srcDtsPath = srcPath + ext.replace(JS_EXT_RE, ".d.$1ts");
|
|
61
|
+
let specifier = spec.specifier;
|
|
62
|
+
try {
|
|
63
|
+
if (!vfs.get(srcDtsPath)) {
|
|
64
|
+
const stat = statSync(srcPath);
|
|
65
|
+
if (stat.isDirectory()) {
|
|
66
|
+
specifier += "/index";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
} catch {
|
|
70
|
+
}
|
|
71
|
+
contents = contents.replace(spec.code, spec.code.replace(spec.specifier, specifier + ext));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
output[filename] = { contents };
|
|
75
|
+
vfs.delete(filename);
|
|
76
|
+
}
|
|
77
|
+
return output;
|
|
78
|
+
}
|
|
79
|
+
export function augmentWithDiagnostics(result, output, tsHost, ts) {
|
|
80
|
+
if (result.diagnostics?.length) {
|
|
81
|
+
for (const diagnostic of result.diagnostics) {
|
|
82
|
+
const filename = diagnostic.file?.fileName;
|
|
83
|
+
if (filename in output) {
|
|
84
|
+
output[filename].errors = output[filename].errors || [];
|
|
85
|
+
output[filename].errors.push(
|
|
86
|
+
new TypeError(ts.formatDiagnostics([diagnostic], tsHost), {
|
|
87
|
+
cause: diagnostic
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
console.error(ts.formatDiagnostics(result.diagnostics, tsHost));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copyFileWithStream(sourcePath: string, outPath: string): Promise<unknown>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createReadStream, createWriteStream } from "node:fs";
|
|
2
|
+
import { pipeline } from "node:stream";
|
|
3
|
+
export function copyFileWithStream(sourcePath, outPath) {
|
|
4
|
+
const sourceStream = createReadStream(sourcePath);
|
|
5
|
+
const outStream = createWriteStream(outPath);
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
pipeline(sourceStream, outStream, (error) => {
|
|
8
|
+
if (error) {
|
|
9
|
+
reject(error);
|
|
10
|
+
} else {
|
|
11
|
+
resolve();
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { normalize } from "pathe";
|
|
3
|
+
import { satisfies } from "semver";
|
|
4
|
+
import { augmentWithDiagnostics, extractDeclarations } from "./dts.js";
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
export async function getVueDeclarations(vfs, opts) {
|
|
7
|
+
const fileMapping = getFileMapping(vfs);
|
|
8
|
+
const srcFiles = Object.keys(fileMapping);
|
|
9
|
+
const originFiles = Object.values(fileMapping);
|
|
10
|
+
if (originFiles.length === 0) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const { readPackageJSON } = await import("pkg-types");
|
|
14
|
+
const pkgInfo = await readPackageJSON("vue-tsc").catch(() => {
|
|
15
|
+
});
|
|
16
|
+
if (!pkgInfo) {
|
|
17
|
+
console.warn("[mkdist] Please install `vue-tsc` to generate Vue SFC declarations.");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const { version } = pkgInfo;
|
|
21
|
+
let output;
|
|
22
|
+
switch (true) {
|
|
23
|
+
// @ts-expect-error TODO: fix ts
|
|
24
|
+
case satisfies(version, "^1.8.27"): {
|
|
25
|
+
output = await emitVueTscV1(vfs, srcFiles, originFiles, opts);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
// @ts-expect-error TODO: fix ts
|
|
29
|
+
case satisfies(version, "~v2.0.0"): {
|
|
30
|
+
output = await emitVueTscV2(vfs, srcFiles, originFiles, opts);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
default: {
|
|
34
|
+
output = await emitVueTscLatest(vfs, srcFiles, originFiles, opts);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return output;
|
|
38
|
+
}
|
|
39
|
+
const SFC_EXT_RE = /\.vue\.[cm]?[jt]s$/;
|
|
40
|
+
function getFileMapping(vfs) {
|
|
41
|
+
const files = /* @__PURE__ */ Object.create(null);
|
|
42
|
+
for (const [srcPath] of vfs) {
|
|
43
|
+
if (SFC_EXT_RE.test(srcPath)) {
|
|
44
|
+
files[srcPath.replace(SFC_EXT_RE, ".vue")] = srcPath;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return files;
|
|
48
|
+
}
|
|
49
|
+
async function emitVueTscV1(vfs, inputFiles, originFiles, opts) {
|
|
50
|
+
const vueTsc = await import("vue-tsc").then((r) => r.default || r).catch(() => void 0);
|
|
51
|
+
const ts = require("typescript");
|
|
52
|
+
const tsHost = ts.createCompilerHost(opts.typescript.compilerOptions);
|
|
53
|
+
const _tsSysWriteFile = ts.sys.writeFile;
|
|
54
|
+
ts.sys.writeFile = (filename, content) => {
|
|
55
|
+
vfs.set(filename, content);
|
|
56
|
+
};
|
|
57
|
+
const _tsSysReadFile = ts.sys.readFile;
|
|
58
|
+
ts.sys.readFile = (filename, encoding) => {
|
|
59
|
+
if (vfs.has(filename)) {
|
|
60
|
+
return vfs.get(filename);
|
|
61
|
+
}
|
|
62
|
+
return _tsSysReadFile(filename, encoding);
|
|
63
|
+
};
|
|
64
|
+
try {
|
|
65
|
+
const program = vueTsc.createProgram({
|
|
66
|
+
rootNames: inputFiles,
|
|
67
|
+
// @ts-expect-error TODO: fix ts
|
|
68
|
+
options: opts.typescript.compilerOptions,
|
|
69
|
+
host: tsHost
|
|
70
|
+
});
|
|
71
|
+
const result = program.emit();
|
|
72
|
+
const output = extractDeclarations(vfs, originFiles, opts);
|
|
73
|
+
augmentWithDiagnostics(result, output, tsHost, ts);
|
|
74
|
+
return output;
|
|
75
|
+
} finally {
|
|
76
|
+
ts.sys.writeFile = _tsSysWriteFile;
|
|
77
|
+
ts.sys.readFile = _tsSysReadFile;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function emitVueTscV2(vfs, inputFiles, originFiles, opts) {
|
|
81
|
+
const { resolve: resolveModule } = await import("mlly");
|
|
82
|
+
const ts = await import("typescript").then((r) => r.default || r);
|
|
83
|
+
const vueTsc = await import("vue-tsc");
|
|
84
|
+
const requireFromVueTsc = createRequire(await resolveModule("vue-tsc"));
|
|
85
|
+
const vueLanguageCore = requireFromVueTsc("@vue/language-core");
|
|
86
|
+
const volarTs = requireFromVueTsc("@volar/typescript");
|
|
87
|
+
const tsHost = ts.createCompilerHost(opts.typescript.compilerOptions);
|
|
88
|
+
tsHost.writeFile = (filename, content) => {
|
|
89
|
+
vfs.set(filename, vueTsc.removeEmitGlobalTypes(content));
|
|
90
|
+
};
|
|
91
|
+
const _tsReadFile = tsHost.readFile.bind(tsHost);
|
|
92
|
+
tsHost.readFile = (filename) => {
|
|
93
|
+
if (vfs.has(filename)) {
|
|
94
|
+
return vfs.get(filename);
|
|
95
|
+
}
|
|
96
|
+
return _tsReadFile(filename);
|
|
97
|
+
};
|
|
98
|
+
const _tsFileExist = tsHost.fileExists.bind(tsHost);
|
|
99
|
+
tsHost.fileExists = (filename) => {
|
|
100
|
+
return vfs.has(filename) || _tsFileExist(filename);
|
|
101
|
+
};
|
|
102
|
+
const programOptions = {
|
|
103
|
+
rootNames: inputFiles,
|
|
104
|
+
// @ts-expect-error TODO: fix ts
|
|
105
|
+
options: opts.typescript.compilerOptions,
|
|
106
|
+
host: tsHost
|
|
107
|
+
};
|
|
108
|
+
const createProgram = volarTs.proxyCreateProgram(ts, ts.createProgram, (ts2, options) => {
|
|
109
|
+
const vueLanguagePlugin = vueLanguageCore.createVueLanguagePlugin(
|
|
110
|
+
ts2,
|
|
111
|
+
// @ts-expect-error TODO: fix ts
|
|
112
|
+
(id) => id,
|
|
113
|
+
() => "",
|
|
114
|
+
(fileName) => {
|
|
115
|
+
const fileMap = /* @__PURE__ */ new Set();
|
|
116
|
+
for (const vueFileName of options.rootNames.map((rootName) => normalize(rootName))) {
|
|
117
|
+
fileMap.add(vueFileName);
|
|
118
|
+
}
|
|
119
|
+
return fileMap.has(fileName);
|
|
120
|
+
},
|
|
121
|
+
// @ts-expect-error TODO: fix ts
|
|
122
|
+
options.options,
|
|
123
|
+
vueLanguageCore.resolveVueCompilerOptions({})
|
|
124
|
+
);
|
|
125
|
+
return [vueLanguagePlugin];
|
|
126
|
+
});
|
|
127
|
+
const program = createProgram(programOptions);
|
|
128
|
+
const result = program.emit();
|
|
129
|
+
const output = extractDeclarations(vfs, originFiles, opts);
|
|
130
|
+
augmentWithDiagnostics(result, output, tsHost, ts);
|
|
131
|
+
return output;
|
|
132
|
+
}
|
|
133
|
+
async function emitVueTscLatest(vfs, inputFiles, originFiles, opts) {
|
|
134
|
+
const { resolve: resolveModule } = await import("mlly");
|
|
135
|
+
const ts = await import("typescript").then((r) => r.default || r);
|
|
136
|
+
const requireFromVueTsc = createRequire(await resolveModule("vue-tsc"));
|
|
137
|
+
const vueLanguageCore = requireFromVueTsc("@vue/language-core");
|
|
138
|
+
const volarTs = requireFromVueTsc("@volar/typescript");
|
|
139
|
+
const tsHost = ts.createCompilerHost(opts.typescript.compilerOptions);
|
|
140
|
+
tsHost.writeFile = (filename, content) => {
|
|
141
|
+
vfs.set(filename, content);
|
|
142
|
+
};
|
|
143
|
+
const _tsReadFile = tsHost.readFile.bind(tsHost);
|
|
144
|
+
tsHost.readFile = (filename) => {
|
|
145
|
+
if (vfs.has(filename)) {
|
|
146
|
+
return vfs.get(filename);
|
|
147
|
+
}
|
|
148
|
+
return _tsReadFile(filename);
|
|
149
|
+
};
|
|
150
|
+
const _tsFileExist = tsHost.fileExists.bind(tsHost);
|
|
151
|
+
tsHost.fileExists = (filename) => {
|
|
152
|
+
return vfs.has(filename) || _tsFileExist(filename);
|
|
153
|
+
};
|
|
154
|
+
const programOptions = {
|
|
155
|
+
rootNames: inputFiles,
|
|
156
|
+
// @ts-expect-error TODO: fix ts
|
|
157
|
+
options: opts.typescript.compilerOptions,
|
|
158
|
+
host: tsHost
|
|
159
|
+
};
|
|
160
|
+
const createProgram = volarTs.proxyCreateProgram(ts, ts.createProgram, (ts2, options) => {
|
|
161
|
+
const vueLanguagePlugin = vueLanguageCore.createVueLanguagePlugin(
|
|
162
|
+
ts2,
|
|
163
|
+
options.options,
|
|
164
|
+
// @ts-expect-error TODO: fix ts
|
|
165
|
+
vueLanguageCore.createParsedCommandLineByJson(ts2, ts2.sys, opts.rootDir, {}, void 0, true).vueOptions,
|
|
166
|
+
(id) => id
|
|
167
|
+
);
|
|
168
|
+
return [vueLanguagePlugin];
|
|
169
|
+
});
|
|
170
|
+
const program = createProgram(programOptions);
|
|
171
|
+
const result = program.emit();
|
|
172
|
+
const output = extractDeclarations(vfs, originFiles, opts);
|
|
173
|
+
augmentWithDiagnostics(result, output, tsHost, ts);
|
|
174
|
+
return output;
|
|
175
|
+
}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { relative, dirname as pathDirname } from "@reliverse/pathkit";
|
|
2
2
|
import { relinka } from "@reliverse/relinka";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
rmdir,
|
|
6
|
-
symlink,
|
|
7
|
-
warn
|
|
8
|
-
} from "../utils.js";
|
|
3
|
+
import { rmdir, symlink, warn } from "../utils.js";
|
|
4
|
+
import { mkdist } from "./mkdist-impl/make.js";
|
|
9
5
|
export async function mkdistBuild(ctx) {
|
|
10
|
-
const entries = ctx.options.entries.filter(
|
|
11
|
-
(e) => e.builder === "mkdist"
|
|
12
|
-
);
|
|
6
|
+
const entries = ctx.options.entries.filter((e) => e.builder === "mkdist");
|
|
13
7
|
await ctx.hooks.callHook("mkdist:entries", ctx, entries);
|
|
14
8
|
for (const entry of entries) {
|
|
15
9
|
const distDir = entry.outDir || entry.input;
|
|
@@ -41,12 +35,7 @@ export async function mkdistBuild(ctx) {
|
|
|
41
35
|
"verbose",
|
|
42
36
|
`[mkdist] Building with options: srcDir=${mkdistOptions.srcDir}, distDir=${mkdistOptions.distDir}, rootDir=${mkdistOptions.rootDir}`
|
|
43
37
|
);
|
|
44
|
-
await ctx.hooks.callHook(
|
|
45
|
-
"mkdist:entry:options",
|
|
46
|
-
ctx,
|
|
47
|
-
entry,
|
|
48
|
-
mkdistOptions
|
|
49
|
-
);
|
|
38
|
+
await ctx.hooks.callHook("mkdist:entry:options", ctx, entry, mkdistOptions);
|
|
50
39
|
const output = await mkdist(mkdistOptions);
|
|
51
40
|
ctx.buildEntries.push({
|
|
52
41
|
chunks: output.writtenFiles.map((p) => relative(ctx.options.outDir, p)),
|
|
@@ -67,9 +56,6 @@ ${error.errors.map((e) => ` - ${e}`).join("\n")}`
|
|
|
67
56
|
}
|
|
68
57
|
await ctx.hooks.callHook("mkdist:done", ctx);
|
|
69
58
|
if (entries.length > 0 && ctx.options.transpileWatch) {
|
|
70
|
-
relinka(
|
|
71
|
-
"warn",
|
|
72
|
-
"`mkdist` builder does not support transpileWatch mode yet."
|
|
73
|
-
);
|
|
59
|
+
relinka("warn", "`mkdist` builder does not support transpileWatch mode yet.");
|
|
74
60
|
}
|
|
75
61
|
}
|
|
@@ -35,9 +35,7 @@ export async function rollupBuild(ctx) {
|
|
|
35
35
|
if (entry.isEntry) {
|
|
36
36
|
ctx.buildEntries.push({
|
|
37
37
|
bytes: Buffer.byteLength(entry.code, "utf8"),
|
|
38
|
-
chunks: entry.imports.filter(
|
|
39
|
-
(i) => outputChunks.find((c) => c.fileName === i)
|
|
40
|
-
),
|
|
38
|
+
chunks: entry.imports.filter((i) => outputChunks.find((c) => c.fileName === i)),
|
|
41
39
|
exports: entry.exports,
|
|
42
40
|
modules: Object.entries(entry.modules).map(([id, mod]) => ({
|
|
43
41
|
bytes: mod.renderedLength,
|
|
@@ -55,10 +53,7 @@ export async function rollupBuild(ctx) {
|
|
|
55
53
|
if (ctx.options.transpileWatch) {
|
|
56
54
|
rollupWatch(rollupOptions);
|
|
57
55
|
if (ctx.options.declaration && ctx.options.transpileWatch) {
|
|
58
|
-
relinka(
|
|
59
|
-
"warn",
|
|
60
|
-
"`rollup` DTS builder does not support transpileWatch mode yet."
|
|
61
|
-
);
|
|
56
|
+
relinka("warn", "`rollup` DTS builder does not support transpileWatch mode yet.");
|
|
62
57
|
}
|
|
63
58
|
return;
|
|
64
59
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { isAbsolute, resolve } from "@reliverse/pathkit";
|
|
2
2
|
import { resolveAlias } from "@reliverse/pathkit";
|
|
3
3
|
import { parseNodeModulePath } from "mlly";
|
|
4
|
-
import {
|
|
5
|
-
arrayIncludes,
|
|
6
|
-
getpkg,
|
|
7
|
-
warn
|
|
8
|
-
} from "../utils.js";
|
|
4
|
+
import { arrayIncludes, getpkg, warn } from "../utils.js";
|
|
9
5
|
import { cjsPlugin } from "./plugins/cjs.js";
|
|
10
6
|
import { esbuild } from "./plugins/esbuild.js";
|
|
11
7
|
import { JSONPlugin } from "./plugins/json.js";
|
|
@@ -41,10 +37,7 @@ export function getRollupOptions(ctx) {
|
|
|
41
37
|
return false;
|
|
42
38
|
},
|
|
43
39
|
input: Object.fromEntries(
|
|
44
|
-
ctx.options.entries.filter((entry) => entry.builder === "rollup").map((entry) => [
|
|
45
|
-
entry.name,
|
|
46
|
-
resolve(ctx.options.rootDir, entry.input)
|
|
47
|
-
])
|
|
40
|
+
ctx.options.entries.filter((entry) => entry.builder === "rollup").map((entry) => [entry.name, resolve(ctx.options.rootDir, entry.input)])
|
|
48
41
|
),
|
|
49
42
|
onwarn(warning, rollupWarn) {
|
|
50
43
|
if (!warning.code || !["CIRCULAR_DEPENDENCY"].includes(warning.code)) {
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
basename,
|
|
3
|
-
dirname,
|
|
4
|
-
extname,
|
|
5
|
-
relative,
|
|
6
|
-
resolve
|
|
7
|
-
} from "@reliverse/pathkit";
|
|
1
|
+
import { basename, dirname, extname, relative, resolve } from "@reliverse/pathkit";
|
|
8
2
|
import { fileURLToPath, resolveModuleExportNames, resolvePath } from "mlly";
|
|
9
3
|
import { promises as fsp } from "node:fs";
|
|
10
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
@@ -37,18 +31,13 @@ export async function rollupStub(ctx) {
|
|
|
37
31
|
if (Array.isArray(plugin)) {
|
|
38
32
|
const [name, ...args] = plugin;
|
|
39
33
|
importedBabelPlugins.push(name);
|
|
40
|
-
return `[${[
|
|
41
|
-
`plugin${i}`,
|
|
42
|
-
...args.map((val) => JSON.stringify(val))
|
|
43
|
-
].join(", ")}]`;
|
|
34
|
+
return `[${[`plugin${i}`, ...args.map((val) => JSON.stringify(val))].join(", ")}]`;
|
|
44
35
|
}
|
|
45
36
|
importedBabelPlugins.push(plugin);
|
|
46
37
|
return `plugin${i}`;
|
|
47
38
|
}).join(",")}]` : "[]"
|
|
48
39
|
);
|
|
49
|
-
for (const entry of ctx.options.entries.filter(
|
|
50
|
-
(entry2) => entry2.builder === "rollup"
|
|
51
|
-
)) {
|
|
40
|
+
for (const entry of ctx.options.entries.filter((entry2) => entry2.builder === "rollup")) {
|
|
52
41
|
const output = resolve(
|
|
53
42
|
ctx.options.rootDir,
|
|
54
43
|
ctx.options.outDir,
|
|
@@ -82,19 +71,14 @@ export async function rollupStub(ctx) {
|
|
|
82
71
|
"",
|
|
83
72
|
`const jiti = createJiti(__filename, ${serializedJitiOptions})`,
|
|
84
73
|
"",
|
|
85
|
-
`/** @type {import(${JSON.stringify(
|
|
86
|
-
resolvedEntryForTypeImport
|
|
87
|
-
)})} */`,
|
|
74
|
+
`/** @type {import(${JSON.stringify(resolvedEntryForTypeImport)})} */`,
|
|
88
75
|
`module.exports = jiti(${JSON.stringify(resolvedEntry)})`
|
|
89
76
|
].join("\n")
|
|
90
77
|
);
|
|
91
78
|
}
|
|
92
|
-
const namedExports = await resolveModuleExportNames(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
extensions: DEFAULT_EXTENSIONS
|
|
96
|
-
}
|
|
97
|
-
).catch((error) => {
|
|
79
|
+
const namedExports = await resolveModuleExportNames(resolvedEntry, {
|
|
80
|
+
extensions: DEFAULT_EXTENSIONS
|
|
81
|
+
}).catch((error) => {
|
|
98
82
|
warn(ctx, `Cannot analyze ${resolvedEntry} for exports:${error}`);
|
|
99
83
|
return [];
|
|
100
84
|
});
|
|
@@ -117,9 +101,7 @@ export async function rollupStub(ctx) {
|
|
|
117
101
|
`const jiti = createJiti(import.meta.url, ${serializedJitiOptions})`,
|
|
118
102
|
"",
|
|
119
103
|
`/** @type {import(${JSON.stringify(resolvedEntryForTypeImport)})} */`,
|
|
120
|
-
`const _module = await jiti.import(${JSON.stringify(
|
|
121
|
-
resolvedEntry
|
|
122
|
-
)});`,
|
|
104
|
+
`const _module = await jiti.import(${JSON.stringify(resolvedEntry)});`,
|
|
123
105
|
hasDefaultExport ? "\nexport default _module?.default ?? _module;" : "",
|
|
124
106
|
...namedExports.filter((name) => name !== "default").map((name) => `export const ${name} = _module.${name};`)
|
|
125
107
|
].join("\n")
|
|
@@ -31,10 +31,7 @@ export function resolveAliases(ctx) {
|
|
|
31
31
|
)
|
|
32
32
|
);
|
|
33
33
|
} else {
|
|
34
|
-
Object.assign(
|
|
35
|
-
aliases,
|
|
36
|
-
ctx.options.rollup.alias.entries || ctx.options.rollup.alias
|
|
37
|
-
);
|
|
34
|
+
Object.assign(aliases, ctx.options.rollup.alias.entries || ctx.options.rollup.alias);
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
return aliases;
|
|
@@ -15,10 +15,7 @@ export function rollupWatch(rollupOptions) {
|
|
|
15
15
|
"log",
|
|
16
16
|
`[dler] [rollup] Starting watchers for entries: ${inputs.map((input) => `./${relative(process.cwd(), input)}`).join(", ")}`
|
|
17
17
|
);
|
|
18
|
-
relinka(
|
|
19
|
-
"warn",
|
|
20
|
-
"[dler] [rollup] Watch mode is experimental and may be unstable"
|
|
21
|
-
);
|
|
18
|
+
relinka("warn", "[dler] [rollup] Watch mode is experimental and may be unstable");
|
|
22
19
|
transpileWatcher.on("change", (id, { event }) => {
|
|
23
20
|
relinka("log", `${relative(".", id)} was ${event}d`);
|
|
24
21
|
});
|
|
@@ -3,11 +3,7 @@ import { relinka } from "@reliverse/relinka";
|
|
|
3
3
|
import { createJiti } from "jiti";
|
|
4
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
5
|
import { pascalCase } from "scule";
|
|
6
|
-
import {
|
|
7
|
-
generateMarkdown,
|
|
8
|
-
generateTypes,
|
|
9
|
-
resolveSchema
|
|
10
|
-
} from "untyped";
|
|
6
|
+
import { generateMarkdown, generateTypes, resolveSchema } from "untyped";
|
|
11
7
|
import untypedPlugin from "untyped/babel-plugin";
|
|
12
8
|
export async function typesBuild(ctx) {
|
|
13
9
|
const entries = ctx.options.entries.filter(
|
|
@@ -33,12 +29,7 @@ export async function typesBuild(ctx) {
|
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
31
|
};
|
|
36
|
-
await ctx.hooks.callHook(
|
|
37
|
-
"untyped:entry:options",
|
|
38
|
-
ctx,
|
|
39
|
-
entry,
|
|
40
|
-
jitiOptions
|
|
41
|
-
);
|
|
32
|
+
await ctx.hooks.callHook("untyped:entry:options", ctx, entry, jitiOptions);
|
|
42
33
|
const untypedJiti = createJiti(ctx.options.rootDir, jitiOptions);
|
|
43
34
|
const inputPath = resolve(ctx.options.rootDir, entry.input);
|
|
44
35
|
let rawSchemaModule;
|
|
@@ -94,20 +85,15 @@ export async function typesBuild(ctx) {
|
|
|
94
85
|
if (!output) continue;
|
|
95
86
|
const fullOutputPath = resolve(distDir, output.fileName);
|
|
96
87
|
writePromises.push(
|
|
97
|
-
writeFile(fullOutputPath, output.contents, "utf8").catch(
|
|
98
|
-
(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
)
|
|
88
|
+
writeFile(fullOutputPath, output.contents, "utf8").catch((writeError) => {
|
|
89
|
+
console.error(
|
|
90
|
+
`[untyped] Failed to write output file ${fullOutputPath} for entry '${entry.name}': ${writeError.message}`
|
|
91
|
+
);
|
|
92
|
+
})
|
|
104
93
|
);
|
|
105
94
|
}
|
|
106
95
|
await Promise.all(writePromises);
|
|
107
|
-
relinka(
|
|
108
|
-
"verbose",
|
|
109
|
-
`[untyped] Generated outputs for '${entry.name}' in ${distDir}`
|
|
110
|
-
);
|
|
96
|
+
relinka("verbose", `[untyped] Generated outputs for '${entry.name}' in ${distDir}`);
|
|
111
97
|
} catch (error) {
|
|
112
98
|
console.error(
|
|
113
99
|
`[untyped] Failed to process entry '${entry.name}': ${error.message}`,
|