|
1 | 1 | #!/usr/bin/env bun |
| 2 | +import path from 'node:path'; |
2 | 3 | import { Chalk } from 'chalk'; |
3 | 4 | import esbuild from 'esbuild'; |
4 | 5 | import tscAlias from 'tsc-alias'; |
@@ -71,7 +72,7 @@ const buildJs = async ( |
71 | 72 | for (const out of result.outputFiles) { |
72 | 73 | await Bun.write(out.path, out.contents); |
73 | 74 | list.push({ |
74 | | - filePath: out.path, |
| 75 | + filePath: path.resolve(out.path), |
75 | 76 | fileContents: out.text |
76 | 77 | }); |
77 | 78 | } |
@@ -101,11 +102,12 @@ const buildDts = (ext?: BuildOutput['extension']) => { |
101 | 102 | } |
102 | 103 | ); |
103 | 104 | const host = ts.createCompilerHost(config.options); |
104 | | - host.writeFile = async (...arg) => { |
| 105 | + const writeFile = host.writeFile; |
| 106 | + host.writeFile = (...arg) => { |
| 107 | + writeFile(...arg); |
105 | 108 | const [filePath, fileContents] = arg; |
106 | | - await Bun.write(filePath, fileContents); |
107 | 109 | list.push({ |
108 | | - filePath, |
| 110 | + filePath: path.resolve(filePath), |
109 | 111 | fileContents |
110 | 112 | }); |
111 | 113 | }; |
@@ -151,18 +153,19 @@ const build = async ( |
151 | 153 | } |
152 | 154 | } |
153 | 155 |
|
| 156 | + await resolveAlias(result); |
| 157 | + |
154 | 158 | return result; |
155 | 159 | }; |
156 | 160 |
|
157 | 161 | const main = async () => { |
158 | 162 | console.info('build dist files...'); |
159 | 163 | const startTime = performance.now(); |
160 | | - const [cjs, esm, dts] = await Promise.all([ |
| 164 | + await Promise.all([ |
161 | 165 | build('cjs', '.cjs'), |
162 | 166 | build('esm', '.mjs'), |
163 | 167 | build('dts', '.d.ts') |
164 | 168 | ]); |
165 | | - await Promise.all([resolveAlias(cjs), resolveAlias(esm), resolveAlias(dts)]); |
166 | 169 | const endTime = performance.now(); |
167 | 170 |
|
168 | 171 | console.info( |
|
0 commit comments