fix(packages): add server-only bundles (#1349)

This commit is contained in:
rahim
2026-04-16 00:59:14 -07:00
committed by GitHub
parent 4ecc870685
commit 3331fdaf25
60 changed files with 654 additions and 215 deletions
+9 -2
View File
@@ -163,6 +163,7 @@ async function measure(entryPoints, external = []) {
write: false,
outdir: '/tmp/bundle-size-out',
external,
conditions: ['browser'],
logLevel: 'silent',
});
@@ -199,6 +200,7 @@ async function measureVirtual(code, resolveDir, external = []) {
write: false,
outdir: '/tmp/bundle-size-out',
external,
conditions: ['browser'],
logLevel: 'silent',
});
@@ -213,12 +215,17 @@ async function measureVirtual(code, resolveDir, external = []) {
}
/**
* Resolve the `default` condition from an export value.
* Handles both `{ default: "./dist/..." }` objects and plain string values.
* Resolve the browser production path from an export value.
*
* Prefers `browser.default` (browser prod bundle) over top-level `default`
* (server bundle) so we measure the code consumers actually ship.
*/
function resolveDefault(exportValue) {
if (typeof exportValue === 'string') return exportValue;
if (typeof exportValue === 'object' && exportValue !== null) {
if (typeof exportValue.browser === 'object' && exportValue.browser !== null) {
return exportValue.browser.default ?? exportValue.default ?? null;
}
return exportValue.default ?? null;
}
return null;