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

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.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17

Most upvoted comments

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

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.

Same error here. Windows 10, Node 16, Remix 1.3.3. I have chosen express server when creating new app.

image

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

Odd. I did a clean install and build ran just fine. Did you confirm that you have the proper packages installed in node_modules? Check node_modules/@remix-run image