Erronous import of identically named files
Reproduction
So, this has started happening recently, so I assume due to an automatic ^ upgrade. I have an environment where we use modules that have directory and file structures that are identical. So, each module will have a file config.ts with a config.path representing the route for this module.
The problem is that if a single route loads various components that end up using config files from different modules on different import paths. remix will end up referencing a config file different than the one being imported inside a single file. So, using the "wrong" import path. I debugged this and found that the block context would contain multiple config file references within the block context for a file, and it would pick the first one available. Which will end up being the wrong one for some files.
The workaround is importing a config file with a different name import { config as clazzConfig } from ~my-package/module/config.ts
Not sure if this easily reproduceable but it started occurring only recently. I think this only happens in dev but I didn't verify that.
System Info
System:
OS: macOS 14.2.1
CPU: (11) arm64 Apple M3 Pro
Memory: 80.53 MB / 18.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v20.11.1/bin/yarn
npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
Browsers:
Chrome: 124.0.6367.201
Safari: 17.2.1
Used Package Manager
yarn
Expected Behavior
Any imported file should get the reference file contents.
Actual Behavior
Remix references an identically named file import on a different import path
Can you provide a repo? That seems very specific to how your app works.
Could be. If you guys have a base repo I can copy and customize, that would save me the time I don't have to do it from scratch
The easiest would be to create a stackblitz. https://remix.new will create a basic Remix app.