Skip to content

Commit 4af67d6

Browse files
committed
Extend ssr.noExternal with CJS dependency closure
1 parent cd2584d commit 4af67d6

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

astro.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,15 @@ export default defineConfig({
198198
* Bundle the sanitizer and its parser dependency chain into the ESM
199199
* server output so no runtime require() of these packages occurs.
200200
*
201+
* The sanitizer's CommonJS runtime dependencies must be bundled for the
202+
* same reason. Rolldown emits externalized require() calls through a
203+
* createRequire() helper imported from a shared runtime chunk, and
204+
* @vercel/nft's static analysis cannot follow that indirection across
205+
* module boundaries — untraced packages are absent from the deployed
206+
* function and crash every action cold start with MODULE_NOT_FOUND.
207+
* Bundling the full dependency closure (launder -> dayjs, postcss ->
208+
* nanoid/picocolors/source-map-js) leaves no runtime require() behind.
209+
*
201210
* Build-only: in the dev server, Vite's SSR module runner evaluates
202211
* noExternal'd CommonJS packages as ESM, crashing the same action with
203212
* "ReferenceError: require is not defined". When the chain is
@@ -214,6 +223,16 @@ export default defineConfig({
214223
'domhandler',
215224
'domutils',
216225
'entities',
226+
'deepmerge',
227+
'escape-string-regexp',
228+
'is-plain-object',
229+
'launder',
230+
'dayjs',
231+
'parse-srcset',
232+
'postcss',
233+
'nanoid',
234+
'picocolors',
235+
'source-map-js',
217236
]
218237
: [],
219238
},

0 commit comments

Comments
 (0)