Skip to content

Commit 747f62f

Browse files
fjakobsclaude
andauthored
chore: tune tsdown configuration to reduce bundle size (#5)
* chore: tune tsdown configuration to reduce bundle size * fix: resolve TypeScript path aliases in tsdown bundler Modified the external function in tsdown configs to properly handle @/ path aliases: - Added check to prevent @/ imports from being treated as external dependencies - This allows tsdown to resolve these paths to actual file paths during bundling - Applied to both @databricks/app-kit and @databricks/app-kit-ui packages The issue was that the regex /^[^./]/ was marking all non-relative imports (including @/ aliases) as external, preventing proper resolution. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Fabian Jakobs <[email protected]> --------- Signed-off-by: Fabian Jakobs <[email protected]> Co-authored-by: Claude <[email protected]>
1 parent d1e0808 commit 747f62f

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/app-kit-ui/tsdown.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ export default defineConfig([
1515
hash: false,
1616
unbundle: true,
1717
format: "esm",
18-
skipNodeModulesBundle: true,
1918
noExternal: ["shared"],
20-
external: ["react", "react-dom", "recharts"],
19+
external: (id) => {
20+
// Bundle "shared" workspace package and @/ path aliases
21+
if (id === "shared" || id.startsWith("shared/")) return false;
22+
if (id.startsWith("@/")) return false;
23+
return /^[^./]/.test(id) || id.includes("/node_modules/");
24+
},
2125
tsconfig: "./tsconfig.json",
2226
exports: {
2327
devExports: "development",

packages/app-kit/tsdown.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ export default defineConfig([
1414
resolve: true,
1515
},
1616
sourcemap: false,
17-
skipNodeModulesBundle: true,
1817
clean: false,
1918
unbundle: true,
2019
noExternal: ["shared"],
21-
external: ["vite", "@vitejs/plugin-react"],
20+
external: (id) => {
21+
// Bundle "shared" workspace package and @/ path aliases
22+
if (id === "shared" || id.startsWith("shared/")) return false;
23+
if (id.startsWith("@/")) return false;
24+
return /^[^./]/.test(id) || id.includes("/node_modules/");
25+
},
2226
tsconfig: "./tsconfig.json",
2327
copy: [
2428
{

0 commit comments

Comments
 (0)