Skip to content

Commit 08afcb6

Browse files
rafalzawadzkiclaude
andcommitted
fix: resolve @/ path aliases in tsup build config
The tsup build fails because esbuild cannot resolve the @/ path aliases defined in tsconfig.json. Add esbuild alias configuration to tsup.config.ts to map @ to the project root, matching the tsconfig paths setting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2830319 commit 08afcb6

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tsup.config.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
import { readFileSync } from 'node:fs';
2+
import { resolve } from 'node:path';
23
import { defineConfig } from 'tsup';
34

45
const package_ = JSON.parse(
56
readFileSync(new URL('package.json', import.meta.url), 'utf8'),
67
);
78

9+
const sharedConfig = {
10+
define: {
11+
__PACKAGE_VERSION__: JSON.stringify(package_.version),
12+
},
13+
esbuildOptions(options: { alias?: Record<string, string> }) {
14+
options.alias = {
15+
'@': resolve(import.meta.dirname),
16+
};
17+
},
18+
};
19+
820
export default defineConfig([
921
{
1022
entry: ['src/index.ts'],
1123
format: ['cjs', 'esm'],
1224
dts: true,
1325
sourcemap: true,
14-
define: {
15-
__PACKAGE_VERSION__: JSON.stringify(package_.version),
16-
},
26+
...sharedConfig,
1727
},
1828
{
1929
entry: ['src/internal/index.ts'],
2030
outDir: 'dist/internal',
2131
format: ['cjs', 'esm'],
2232
dts: true,
2333
sourcemap: true,
24-
define: {
25-
__PACKAGE_VERSION__: JSON.stringify(package_.version),
26-
},
34+
...sharedConfig,
2735
},
2836
]);

0 commit comments

Comments
 (0)