Skip to content

Commit c140d4d

Browse files
committed
fix: unresolved path alias from dist files
1 parent 5b3b47b commit c140d4d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

scripts/dist.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bun
2+
import path from 'node:path';
23
import { Chalk } from 'chalk';
34
import esbuild from 'esbuild';
45
import tscAlias from 'tsc-alias';
@@ -71,7 +72,7 @@ const buildJs = async (
7172
for (const out of result.outputFiles) {
7273
await Bun.write(out.path, out.contents);
7374
list.push({
74-
filePath: out.path,
75+
filePath: path.resolve(out.path),
7576
fileContents: out.text
7677
});
7778
}
@@ -101,11 +102,12 @@ const buildDts = (ext?: BuildOutput['extension']) => {
101102
}
102103
);
103104
const host = ts.createCompilerHost(config.options);
104-
host.writeFile = async (...arg) => {
105+
const writeFile = host.writeFile;
106+
host.writeFile = (...arg) => {
107+
writeFile(...arg);
105108
const [filePath, fileContents] = arg;
106-
await Bun.write(filePath, fileContents);
107109
list.push({
108-
filePath,
110+
filePath: path.resolve(filePath),
109111
fileContents
110112
});
111113
};
@@ -151,18 +153,19 @@ const build = async (
151153
}
152154
}
153155

156+
await resolveAlias(result);
157+
154158
return result;
155159
};
156160

157161
const main = async () => {
158162
console.info('build dist files...');
159163
const startTime = performance.now();
160-
const [cjs, esm, dts] = await Promise.all([
164+
await Promise.all([
161165
build('cjs', '.cjs'),
162166
build('esm', '.mjs'),
163167
build('dts', '.d.ts')
164168
]);
165-
await Promise.all([resolveAlias(cjs), resolveAlias(esm), resolveAlias(dts)]);
166169
const endTime = performance.now();
167170

168171
console.info(

0 commit comments

Comments
 (0)