Skip to content

Commit fcd71f8

Browse files
vite-plugin: ensure that we don't crash when logging Node.js warnings when running in react-router builds (#8702)
1 parent cad99dc commit fcd71f8

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.changeset/cute-dragons-worry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/vite-plugin": patch
3+
---
4+
5+
ensure that we don't crash when logging Node.js warnings when running in react-router builds

packages/vite-plugin-cloudflare/src/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -734,15 +734,16 @@ export function cloudflare(pluginConfig: PluginConfig = {}): vite.Plugin[] {
734734
if (workerConfig && !isNodeCompat(workerConfig)) {
735735
const nodeJsCompatWarnings =
736736
nodeJsCompatWarningsMap.get(workerConfig);
737-
assert(
738-
nodeJsCompatWarnings,
739-
`expected nodeJsCompatWarnings to be defined for Worker "${workerConfig.name}"`
740-
);
737+
// TODO: re-assert this when we work out how to make it function with React Router builds.
738+
// assert(
739+
// nodeJsCompatWarnings,
740+
// `expected nodeJsCompatWarnings to be defined for Worker "${workerConfig.name}"`
741+
// );
741742
if (nodejsBuiltins.has(source)) {
742-
nodeJsCompatWarnings.registerImport(source, importer);
743+
nodeJsCompatWarnings?.registerImport(source, importer);
743744
// We don't have a natural place to trigger the rendering of the warnings
744745
// So we trigger a rendering to happen soon after this round of processing.
745-
nodeJsCompatWarnings.renderWarningsOnIdle();
746+
nodeJsCompatWarnings?.renderWarningsOnIdle();
746747
// Mark this path as external to avoid messy unwanted resolve errors.
747748
// It will fail at runtime but we will log warnings to the user.
748749
return {

0 commit comments

Comments
 (0)