Cookie banner layout options; keep admin UI out of /client
CookieBanner: order, settings="modal", controls="switch", settingsActions, icon and a class slot for every element. Cookie Settings gains eyebrow, title, settingsDescription, alwaysActiveLabel and buttons.close. MaskedField, TestEmailButton and IntegrationStatusBanner import @payloadcms/ui and moved from /client to /admin; with sideEffects in package.json the site bundle no longer ships ~235 KB gz of admin code. A test walks the /client import graph to keep it that way. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -35,3 +35,29 @@ describe('package exports', () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('client entry', () => {
|
||||
// Wszystko, co importuje /client, trafia do bundla strony publicznej — panel (@payloadcms/ui) to ~235 KB gz
|
||||
test('does not pull admin UI (@payloadcms/ui, @payloadcms/next) into the site bundle', () => {
|
||||
const seen = new Set<string>()
|
||||
const offenders: string[] = []
|
||||
const resolve = (from: string, spec: string) => {
|
||||
const base = path.resolve(path.dirname(from), spec).replace(/\.js$/, '')
|
||||
return ['.ts', '.tsx', '/index.ts', '/index.tsx'].map((ext) => base + ext).find((f) => existsSync(f))
|
||||
}
|
||||
const walk = (file: string) => {
|
||||
if (seen.has(file)) {return}
|
||||
seen.add(file)
|
||||
for (const m of readFileSync(file, 'utf8').matchAll(/(?:import|export)\s[^'"]*?from\s+['"](?<spec>[^'"]+)['"]/g)) {
|
||||
const spec = m.groups!.spec
|
||||
if (/^@payloadcms\/(?:ui|next)(?:\/|$)/.test(spec)) {offenders.push(`${path.relative(root, file)} → ${spec}`)}
|
||||
if (spec.startsWith('.')) {
|
||||
const next = resolve(file, spec)
|
||||
if (next) {walk(next)}
|
||||
}
|
||||
}
|
||||
}
|
||||
walk(path.join(root, 'src/exports/client.ts'))
|
||||
expect(offenders).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user