Skip to content

Commit 5fc7b21

Browse files
authored
build(shared): nest internal build chunks under _chunks/ (#8717)
1 parent f3dbc3e commit 5fc7b21

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/shared': patch
3+
---
4+
5+
Nest rolldown's shared build chunks under `dist/runtime/_chunks/` instead of emitting them flat next to the entry points. The package exposes `"./*"`, which resolves to `dist/runtime/*`, so the content-hashed internal chunks were being picked up by API-diff tooling whenever a chunk hash shifted. Entry and type resolution are unchanged; the chunks are still referenced by relative path, and external `./_chunks/*` package subpaths are blocked.

packages/shared/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"default": "./dist/runtime/internal/clerk-js/*.js"
3131
}
3232
},
33+
"./_chunks/*": null,
3334
"./*": {
3435
"import": {
3536
"types": "./dist/runtime/*.d.mts",

packages/shared/tsdown.config.mts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ export default defineConfig(({ watch, env }) => {
5555
],
5656
outDir: './dist/runtime',
5757
unbundle: false,
58+
// Route rolldown's shared chunks into a nested `_chunks/` directory. The
59+
// package's `"./*"` wildcard export resolves to `dist/runtime/*`, and
60+
// break-check expands that surface with a single-segment `*`, so
61+
// content-hashed internal chunks sitting flat in `dist/runtime` get
62+
// enumerated as phantom public subpaths. Nesting them one level down keeps
63+
// them out of that API-snapshot expansion; package subpath imports are
64+
// blocked separately by the `./_chunks/*` null export.
65+
outputOptions: options => {
66+
const { chunkFileNames } = options;
67+
return {
68+
...options,
69+
chunkFileNames:
70+
typeof chunkFileNames === 'function'
71+
? info => `_chunks/${chunkFileNames(info)}`
72+
: `_chunks/${chunkFileNames ?? '[name]-[hash].js'}`,
73+
};
74+
},
5875
},
5976
];
6077
});

0 commit comments

Comments
 (0)