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
- 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.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17
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.Same error here. Windows 10, Node 16, Remix 1.3.3. I have chosen express server when creating new app.
Getting the same error following the instruction in the documentation. The package
@remix-run/server-runtimeis not presentOdd. 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