question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Browser Bundles include @remix/server-runtime

See original GitHub issue

Which Remix packages are impacted?

  • @remix-run/dev

What version of Remix are you using?

1.0.4

Steps to Reproduce

  1. install Remix
  2. create resource route
  3. use redirect or json
  4. 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:closed
  • Created 2 years ago
  • Comments:17

github_iconTop GitHub Comments

3reactions
JimmayVVcommented, Mar 30, 2022

I can confirm that I am seeing the @remix-run/server-runtime error outlined above with the version 1.3.3 of remix - I am simply following the Jokes App tutorial on MacOS 12.0.1 in ZSH - using Node v16.13.0, and npm v8.1.0

Here’s a screenshot of the error as soon as I run the npm run build command as outlined right at the start of the jokes tutorial

Untitled

2reactions
goran-paunoviccommented, Mar 31, 2022

Getting the same error following the instruction in the documentation. The package @remix-run/server-runtime is not present

Same here. When I installed @remix-run/server-runtime the error is gone.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found