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

Support for absolute import #276

Closed
ap13p opened this issue Jul 29, 2016 · 3 comments
Closed

Support for absolute import #276

ap13p opened this issue Jul 29, 2016 · 3 comments

Comments

@ap13p
Copy link

ap13p commented Jul 29, 2016

For example, I have the following structure

+ src
|--img
|   |-- logo.svg
|
|--containers
|   |-- App.js

Instead of doing
import logo from "../img/logo.svg"
inside App.js it will be nice to do
import logo from "img/logo.svg"

and it will be easier to read if I have a component placed in deep directory like components/Sidebar/index.js.

@mxstbr
Copy link
Contributor

mxstbr commented Jul 29, 2016

Good idea! We're having a discussion about this in #253!

@mxstbr mxstbr closed this as completed Jul 29, 2016
@gaearon
Copy link
Contributor

gaearon commented Jul 29, 2016

What is the reason behind top-level “file type” folders? Seems like this is exactly why you want to group assets by component instead, e.g.

src
  components
    Logo
      Logo.js
      Logo.css
      logo.svg

@mxstbr
Copy link
Contributor

mxstbr commented Jul 29, 2016

Well, but you might still need to import a component from a different component:

// src/containers/NavBar/Navbar.js

import NavItem from 'components/NavItem';

is a lot nicer than

// src/containers/NavBar/Navbar.js

import NavItem from '../components/NavItem';

It gets even worse if you're following a nested, route-hirarchic structure.

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 23, 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

3 participants