Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "/src" to webpack resolve.modulesDirectories? #1136

Closed
amsdamsgram opened this issue Dec 2, 2016 · 3 comments
Closed

Add "/src" to webpack resolve.modulesDirectories? #1136

amsdamsgram opened this issue Dec 2, 2016 · 3 comments

Comments

@amsdamsgram
Copy link

Feature request

Hey,

Since CRA have a src/ folder that should contains all the source files, we could add this config to webpack: (according to the doc)

resolve: {
modulesDirectories: ['src', 'node_modules']

We would have cleaner import paths.

Example: let's say our app structure is this

/src
---actions/
---components/
------MyComponent.js
---containers/

We could import myComponent in any files like this:
import MyComponent from 'components/MyComponent'
instead of having a relative path to import it depending on where we are.

What do you think guys?

@gaearon
Copy link
Contributor

gaearon commented Dec 2, 2016

Please could you search the issues and pull requests for "absolute imports"? There have been many discussions about this. Some of them are ongoing.

@gaearon gaearon closed this as completed Dec 2, 2016
@amsdamsgram
Copy link
Author

Oops, sorry didn't search right. Thanks

@gaearon
Copy link
Contributor

gaearon commented Dec 2, 2016

No worries! In short: this is something we want but not through Webpack config because this breaks any other tooling (IDEs, Flow, Node, etc). So instead we're likely to recommend using src/node_modules for this (you can use symlinks for a nicer folder name) once we fix a few issues with this approach.

marcelmokos added a commit to marcelmokos/create-react-app that referenced this issue Dec 19, 2016
You do not have use alias for thing you do. modulesDirectories should work.

facebook#1136
facebook#276
facebook#253

The change breaks tooling and you should not use it until issues are resolved with it.
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants