Skip to content
This repository has been archived by the owner on Apr 23, 2019. It is now read-only.

Different files that yield same normalizedId collisions are not detected, production issues #142

Open
irae opened this issue Dec 8, 2017 · 1 comment

Comments

@irae
Copy link
Collaborator

irae commented Dec 8, 2017

Sometimes, Mendel is resolving files in weird behavior. Although the problem is on my code, it is super hard to track and I only catch this in my CI environment. Here is a summary of the issue:

That's a redacted version of my actual repository.

src/client/base/selectors/
├──...
├── network
│   ├── index.js
│   └── ...
├── network.js
└── ...

Internally mendel represent both of those files with the same normalizedId of selectors/network.
In fact, my code reads require('../selectors/network').

The problem is worst because in development, it is inconsistent. For some developers it will give selectors/network/index.js and it will give selectors/network.js for others.

In production middleware it seems to be 100% consistent to selectors/network.js.

This behavior is not necessarily wrong by mendel. It is doing whatever it is capable of with a tough situation. Nevertheless, I think my compiled bundle could instead, at least in development, throw a meaningful invariant error, since I should not be doing this in my repository anyway.

@irae irae added the bug label Jan 30, 2018
@irae
Copy link
Collaborator Author

irae commented Jan 30, 2018

Marking as a bug, as well as a enhancement.

The bug: Development can be different than production
The enhancement: Throw warnings or errors during development explaining the collision

Research: What does NodeJS do in this situation, what is the priority order with ambiguous paths?

Fix option 1: Make it all stable, even across dev/prod, follow NodeJS resolution
Fix option 2: Same as 1 + warnings
Fix option 3: Throw during development, force developer to pick have only one file or use full path with extension

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant