Skip to content

Commit ccb896b

Browse files
committed
fix(cms): keep lexical plugin barrel server-safe so codegen works
1 parent 3940e6a commit ccb896b

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

cms/src/shared/lexical/LexicalBlocksDiffComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createLexicalBlocksDiffComponent } from './plugin'
1+
import { createLexicalBlocksDiffComponent } from './plugin/createLexicalBlocksDiffComponent'
22

33
/**
44
* Renders Lexical blocks in the admin version diff view. Every block in the

cms/src/shared/lexical/plugin/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ bespoke layout.
1515
`cms/src/shared/lexical/LexicalBlocksDiffComponent.tsx`
1616

1717
```tsx
18-
import { createLexicalBlocksDiffComponent } from './plugin'
18+
// Import the client component directly from its module — NOT from the `./plugin`
19+
// barrel. It pulls in `@payloadcms/ui` (which imports `.scss`), so re-exporting
20+
// it from the barrel would break `payload generate:types`/`generate:importmap`
21+
// (tsx can't load `.scss`). The barrel stays server-safe for the config graph.
22+
import { createLexicalBlocksDiffComponent } from './plugin/createLexicalBlocksDiffComponent'
1923

2024
export const LexicalBlocksDiffComponent = createLexicalBlocksDiffComponent()
2125

@@ -83,7 +87,7 @@ export const blockOverrides = defineBlockConverters({
8387
```tsx
8488
// LexicalBlocksDiffComponent.tsx
8589
import { blockOverrides } from './blockDiffConverters'
86-
import { createLexicalBlocksDiffComponent } from './plugin'
90+
import { createLexicalBlocksDiffComponent } from './plugin/createLexicalBlocksDiffComponent'
8791

8892
export const LexicalBlocksDiffComponent = createLexicalBlocksDiffComponent({
8993
overrides: blockOverrides,

cms/src/shared/lexical/plugin/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
export { createAutoBlockConverter } from './autoBlockConverter'
2-
export {
3-
createLexicalBlocksDiffComponent,
4-
type CreateLexicalBlocksDiffComponentOptions,
5-
} from './createLexicalBlocksDiffComponent'
2+
// `createLexicalBlocksDiffComponent` is intentionally NOT re-exported here: it
3+
// pulls in `@payloadcms/ui` (which `import`s `.scss`), and this barrel is loaded
4+
// by the Payload config graph. `payload generate:types`/`generate:importmap`
5+
// load that graph through tsx, which cannot handle `.scss` and would throw
6+
// `ERR_UNKNOWN_FILE_EXTENSION`. Import it directly from its module instead (only
7+
// the Next-loaded diff component needs it — see ../LexicalBlocksDiffComponent).
8+
export type { CreateLexicalBlocksDiffComponentOptions } from './createLexicalBlocksDiffComponent'
69
export {
710
blockContainer,
811
coordinates,

0 commit comments

Comments
 (0)