[Bug]: Browser Bundles include @remix/server-runtime
See original GitHub issueWhich Remix packages are impacted?
@remix-run/dev
What version of Remix are you using?
1.0.4
Steps to Reproduce
- install Remix
- create resource route
- use redirect or json
- lookup browser build folder for
import_server_runtime
I could not get tests to run on wsl2 or windows so here is just a patch to fix this:
diff --git a/node_modules/@remix-run/dev/compiler.js b/node_modules/@remix-run/dev/compiler.js
index be852a2..858d6b4 100644
--- a/node_modules/@remix-run/dev/compiler.js
+++ b/node_modules/@remix-run/dev/compiler.js
@@ -461,7 +461,17 @@ function browserRouteModulesPlugin(config, suffixMatcher) {
};
}
- let spec = exports.length > 0 ? `{ ${exports.join(", ")} }` : "*";
+ if(exports.length === 0) {
+ return {
+ // Use an empty CommonJS module here instead of ESM to avoid "No
+ // matching export" errors in esbuild for stuff that is imported
+ // from this file.
+ contents: "module.exports = {};",
+ loader: "js"
+ }
+ }
+
+ let spec = `{ ${exports.join(", ")} }`
let contents = `export ${spec} from ${JSON.stringify(file)};`;
return {
contents,
Expected Behavior
Resource routes do not get bundled to the browser build.
Actual Behavior
Resource routes are getting bundled to the browser build.
Issue Analytics
- State:
- Created 2 years ago
- Comments:17
Top Results From Across the Web
Module Constraints - Remix
The Remix compiler will automatically remove server code from the browser bundles. Our strategy is actually pretty straightforward, but requires you to follow ......
Read more >dbanisimov/remix-firebase-hosted-bundle - Remix Guide
... and he's focused on tooling to let more people write more accessible software with fewer bugs. Go Remix. Active hobbies include: constructing...
Read more >Remix says "server code in client modules" but that doesn't ...
I get the following error (in the browser): Error: Cannot initialize 'routeModules'. This normally occurs when you have server code in your ...
Read more >components.json fivem
In the 1 st part of the code snippet, we have declared NameArray that stores ... or leave your game server. xul and...
Read more >The Daily Squat Cure - olahio.com
We have to remember that lifting is a skill and that skill has to be learned well for strength to carryover to the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I can confirm that I am seeing the
@remix-run/server-runtimeerror outlined above with the version1.3.3ofremix- I am simply following the Jokes App tutorial on MacOS 12.0.1 in ZSH - using Node v16.13.0, and npm v8.1.0Here’s a screenshot of the error as soon as I run the
npm run buildcommand as outlined right at the start of the jokes tutorialSame here. When I installed
@remix-run/server-runtimethe error is gone.