Create-react-app: ES6 Import Statement Without Relative Paths

Created on 27 Aug 2016  路  1Comment  路  Source: facebook/create-react-app

Is it planned to add import statements without relative paths (webpack) feature to create-react-app?

You can found info regarding this here and here.

With this we can do

import Header from 'components/Header';
import Grid from 'components/Grid';
import TransactionForm from 'containers/TransactionForm';
import TransactionSummary from 'containers/TransactionSummary';
import * as AppActions from 'actions';

instead of

import Header from '../../components/Header';
import Grid from '../../components/Grid';
import TransactionForm from '../TransactionForm';
import TransactionSummary from '../TransactionSummary';
import * as AppActions from '../../actions';

Most helpful comment

We will likely support this via #476 but you would have to add the current directory to NODE_PATH yourself. We want to keep this explicit because it is quite prone to breakage.

Here is an example: https://github.com/reactjs/redux/issues/1681#issuecomment-216508641. We don鈥檛 want people to have issues like this so we won鈥檛 enable it by default.

>All comments

We will likely support this via #476 but you would have to add the current directory to NODE_PATH yourself. We want to keep this explicit because it is quite prone to breakage.

Here is an example: https://github.com/reactjs/redux/issues/1681#issuecomment-216508641. We don鈥檛 want people to have issues like this so we won鈥檛 enable it by default.

Was this page helpful?
0 / 5 - 0 ratings