Skip to content

Commit 7565631

Browse files
committed
fix build in web
1 parent f83eefb commit 7565631

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

web/oss/next.config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,12 @@ const COMMON_CONFIG: NextConfig = {
8989
"rc-table",
9090
"@ant-design/icons",
9191
"@ant-design/icons-svg",
92+
"@ant-design/x",
9293
]
9394
: []),
9495
],
96+
// Configure ESM packages that need special handling
97+
serverExternalPackages: ["mermaid", "refractor"],
9598
...(!isDevelopment
9699
? {
97100
webpack: (config, {webpack, isServer}) => {
@@ -115,6 +118,23 @@ const COMMON_CONFIG: NextConfig = {
115118
loader: "swc-loader",
116119
})
117120

121+
// Mark ESM packages as external on server side to avoid bundling issues
122+
if (isServer) {
123+
config.externals = config.externals || []
124+
if (Array.isArray(config.externals)) {
125+
config.externals.push("mermaid")
126+
// Handle all refractor language imports as external
127+
config.externals.push(
128+
({request}: {request?: string}, callback: (err?: Error | null, result?: string) => void) => {
129+
if (request && request.startsWith("refractor/")) {
130+
return callback(null, `commonjs ${request}`)
131+
}
132+
callback()
133+
},
134+
)
135+
}
136+
}
137+
118138
if (!isServer) {
119139
config.plugins.push(
120140
new webpack.DefinePlugin({

0 commit comments

Comments
 (0)