Closed Treora closed 7 years ago
I really like this technique as it makes refactor easier (you can move files around quicker). On the other side, when I implemented, I had 2 people complaining because this breaks webstorm path resolving (which means cmd+click or "go to source" doesn't work well, and other advantages in debugging and getting support from the IDE might get lost). I'm not against this technique, neither I consider it an "hack" since that's what you normally do with the node modules. Those are the pros and cons I'm aware of, feel free to merge if you want to, it's easy to revert in the future if it creates more issues than advantages.
Thanks for the feedback, always good to hear someone's opinion before merging it.
In the IDE problem you describe, if the IDE does look in the node_modules
folder, one could perhaps create a symlink: ln -s src node_modules/src
the IDE looks in the node_modules folder. what the ide can't do is knowing that the "src/" is mapped to a specific folder, since this is browserify configuration.
Use the
src
folder as a phony npm module to avoid../../..
imports. Relative imports within a subdirectory ofsrc
are left as is.There seem to be many hacky approaches to work around this ugly issue. I'm following slorber's approach of using browserify's
paths
option. I decided to keep thesrc
prefix to each folder in order to make clear they are not external modules. Thanks @AlexMarvelo for the suggestion.