module resolve suggestion
See original GitHub issueConsider adding the src
directory to the list of webpack module resolves. This makes imports throughout your app simpler.
before
import Thing from "../../../util/Thing";
after
import Thing from "util/Thing";
This also makes moving files around easier since you don’t have to change the relative paths.
You can already accomplish this today by making an env
file and putting NODE_PATH=src
in it. But it seems like a pretty smart default that CRA could set for people.
Something like this would do it: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/config/webpack.config.dev.js#L89
resolve: {
modules: ['node_modules', path.resolve(`${__dirname}/src`)]
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Resolving require paths with webpack - Stack Overflow
@spencer.sm what if I only want modules to be resolved from the current project? I have a few projects that import from each...
Read more >Suggest changes - GitLab Docs
The suggestion is marked as Applied. The thread is resolved. GitLab creates a new commit with the changes. If the user has the...
Read more >CommonJS modules | Node.js v19.3.0 Documentation
Below we give a suggested directory structure that could work: ... Since modules may resolve to a different filename based on the location...
Read more >TSConfig Reference - Docs on every TSConfig option
undefined (default) provide suggestions as warnings to editors; true unreachable code is ignored ... There is a handbook reference page on Module Resolution....
Read more >@tiptap/suggestion - npm
suggestion plugin for tiptap. Latest version: 2.0.0-beta.209, last published: 6 days ago. Start using @tiptap/suggestion in your project by ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We are not making this a default any time soon. There are too many cases where it causes confusing behavior. Setting
NODE_PATH=src
inside.env
is the best solution currently.FYI, you are supposed to commit your
.env
files (minus .local) so that your teammates have them (in case you were telling them to do this by hand).in previous projects we have generated a local.env.sample (or commit it) and then have the install or build scripts warn the developer if the local.env is missing and using environment variables instead.