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 root imports with tilde prefix #852

Closed

Conversation

selbekk
Copy link
Contributor

@selbekk selbekk commented Oct 5, 2016

This commit adds babel-plugin-root-import to the default .babelrc file to define ~ as the absolute path to the src/ folder.

This gives us the possibility to turn code like this:

import SomeUtility from '../../utils/some-utility'

to this

import SomeUtility from '~/utils/some-utility';

The main upside of using this pattern in contrary to the approaches suggested in #741 is that it highlights what is a local import and what is a node_module import.

Fixes #849.

This commit adds `babel-plugin-root-import` to the default .babelrc
file to define `~` as the absolute path to the src/ folder.

This gives us the possibility to turn code like this:

```
import SomeUtility from '../../utils/some-utility'
```

to this

```
import SomeUtility from '~/utils/some-utility';
```
@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks!

@gaearon
Copy link
Contributor

gaearon commented Oct 5, 2016

Thanks for the PR but this is not the approach we’re likely to take because it breaks many integrations and third-party tools.

Instead, we intend to implement this approach: #741. If you could research that, and submit a PR for it, it would be very welcome!

@gaearon gaearon closed this Oct 5, 2016
@selbekk
Copy link
Contributor Author

selbekk commented Oct 5, 2016

Oh... okay.

@selbekk selbekk deleted the add-root-imports-with-tilde-prefix branch October 5, 2016 11:50
@jasan-s
Copy link

jasan-s commented Aug 14, 2017

@selbekk any update on this matter? I'm using the ducks model for my file structure.

@lock lock bot locked and limited conversation to collaborators Jan 20, 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

Successfully merging this pull request may close these issues.

4 participants