What version of Remix are you using?
v1.18
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
Minimal Reproduction: https://github.com/jrestall/remix-nx-monorepo/
- Create a monorepo using Nx or Turborepo such as Logan's example at https://github.com/mcansh/remix-shared-routes/ that has shared route packages outside the app directory.
- Setup the new dev server.
- Modify files outside the main app directory and note HMR doesn't work.
- Add files outside the main app directory that are used by shared routes that follow the *.server.ts pattern and note they don't get replaced with an empty module.
Expected Behavior
HMR and *.server.ts naming convention works with code outside the app dir that uses shared routes.
Actual Behavior
Following are the areas of code that limit HMR and *.server conventions to only work with routes in the app dir. I'm happy to submit a PR to fix this if a better approach can be agreed.
HMR
|
!fs.existsSync(args.path) || |
|
!args.path.startsWith(config.appDirectory)) |
|
) { |
|
return undefined; |
|
} |
|
args.path.startsWith(config.appDirectory) |
|
? fs.statSync(args.path).mtimeMs |
|
: undefined |
If the goal here is to not add react refresh to node_modules code, could we perhaps explicitly check whether the file is in node_modules instead?
Naming Convention
|
path |
|
.resolve(args.resolveDir, args.path) |
|
.startsWith(config.appDirectory) |
|
) { |
|
return { path: args.path, namespace: "empty-module" }; |
Instead of limiting this convention to the app dir, if the goal is to exclude node_modules, could we change it to something like the following?
!args.path.includes("node_modules")
What version of Remix are you using?
v1.18
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
Minimal Reproduction: https://github.com/jrestall/remix-nx-monorepo/
Expected Behavior
HMR and *.server.ts naming convention works with code outside the app dir that uses shared routes.
Actual Behavior
Following are the areas of code that limit HMR and *.server conventions to only work with routes in the app dir. I'm happy to submit a PR to fix this if a better approach can be agreed.
HMR
remix/packages/remix-dev/compiler/js/plugins/hmr.ts
Lines 118 to 122 in 40a4d7d
remix/packages/remix-dev/compiler/js/plugins/hmr.ts
Lines 134 to 136 in 40a4d7d
If the goal here is to not add react refresh to node_modules code, could we perhaps explicitly check whether the file is in node_modules instead?
Naming Convention
remix/packages/remix-dev/compiler/plugins/emptyModules.ts
Lines 24 to 28 in 40a4d7d
Instead of limiting this convention to the app dir, if the goal is to exclude node_modules, could we change it to something like the following?