Skip to content

Commit 2f47670

Browse files
authored
Replace assertion in node-js compat transform hook with early return (#8806)
* Replace assertion in node-js compat transform hook with early return * Added changeset
1 parent 93267cf commit 2f47670

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/big-trees-drum.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+
Replace assertion in vite-plugin-cloudflare:nodejs-compat plugin transform hook with early return. This prevents an error from being logged when building with React Router and TailwindCSS.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,9 @@ export function cloudflare(pluginConfig: PluginConfig = {}): vite.Plugin[] {
599599
async transform(code, id) {
600600
// Inject the Node.js compat globals into the entry module for Node.js compat environments.
601601
const workerConfig = getWorkerConfig(this.environment.name);
602-
assert(workerConfig, "Expected a worker config");
602+
if (!workerConfig) {
603+
return;
604+
}
603605
const resolvedId = await this.resolve(workerConfig.main);
604606
if (id === resolvedId?.id) {
605607
return injectGlobalCode(id, code);

0 commit comments

Comments
 (0)