Skip to content
This repository has been archived by the owner on Dec 13, 2017. It is now read-only.

Commit

Permalink
Fix absolute imports.
Browse files Browse the repository at this point in the history
Solution using .env to set NODE_PATH (commit c148630) appears unreliable.

Discussions about absolute imports for create-react-app are ongoing;
making a symlink seems the currently recommended approach. I call it
'src' for clarity.
See e.g. facebook/create-react-app#1065
  • Loading branch information
benoccrp committed Nov 30, 2017
1 parent c6d0d1d commit 96fec99
Show file tree
Hide file tree
Showing 30 changed files with 52 additions and 51 deletions.
1 change: 0 additions & 1 deletion .env

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
*.css

# dependencies
/node_modules
/node_modules/*
!/node_modules/src

# testing
/coverage
Expand Down
1 change: 1 addition & 0 deletions node_modules/src

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {endpoint} from 'app/api';
import {endpoint} from 'src/app/api';

export const fetchCollections = () => (dispatch) => {
const limit = 5000;
Expand Down
2 changes: 1 addition & 1 deletion src/actions/sessionActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {endpoint} from 'app/api';
import {endpoint} from 'src/app/api';

export const loginWithToken = token => dispatch => {
dispatch({type: 'LOGIN', token});
Expand Down
4 changes: 2 additions & 2 deletions src/app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import de from 'react-intl/locale-data/de';
import ru from 'react-intl/locale-data/ru';
import es from 'react-intl/locale-data/es';

import translations from 'content/translations.json';
import PageLayout from 'components/PageLayout';
import translations from 'src/content/translations.json';
import PageLayout from 'src/components/PageLayout';
import store from './store';

import './App.css';
Expand Down
2 changes: 1 addition & 1 deletion src/app/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import thunk from 'redux-thunk';
import logger from 'redux-logger';
import {throttle} from 'lodash';

import rootReducer from 'reducers';
import rootReducer from 'src/reducers';
import {loadState, saveState} from './storage';

const persistedState = loadState();
Expand Down
4 changes: 2 additions & 2 deletions src/components/CollectionScreen/CollectionContent.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { Component } from 'react';
import { withRouter } from 'react-router';

import DualPane from 'components/common/DualPane';
import SearchScreen_ from 'components/SearchScreen';
import DualPane from 'src/components/common/DualPane';
import SearchScreen_ from 'src/components/SearchScreen';
const SearchScreen = withRouter(SearchScreen_);

class CollectionContent extends Component {
Expand Down
4 changes: 2 additions & 2 deletions src/components/CollectionScreen/CollectionInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import { Icon } from '@blueprintjs/core';

import DualPane from 'components/common/DualPane';
import Breadcrumbs from 'components/common/Breadcrumbs';
import DualPane from 'src/components/common/DualPane';
import Breadcrumbs from 'src/components/common/Breadcrumbs';

function getPath(url) {
return new URL(url).pathname;
Expand Down
2 changes: 1 addition & 1 deletion src/components/CollectionScreen/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';

import DualPane from 'components/common/DualPane';
import DualPane from 'src/components/common/DualPane';
import CollectionContent from './CollectionContent';
import CollectionInfo from './CollectionInfo';

Expand Down
2 changes: 1 addition & 1 deletion src/components/EntityScreen/EntityContent.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';

import DualPane from 'components/common/DualPane';
import DualPane from 'src/components/common/DualPane';

class EntityContent extends Component {
render() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/EntityScreen/EntityInfo.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';

import DualPane from 'components/common/DualPane';
import DualPane from 'src/components/common/DualPane';

class EntityInfo extends Component {
render() {
Expand Down
4 changes: 2 additions & 2 deletions src/components/EntityScreen/index.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';

import { fetchEntity } from 'actions';
import DualPane from 'components/common/DualPane';
import { fetchEntity } from 'src/actions';
import DualPane from 'src/components/common/DualPane';
import EntityInfo from './EntityInfo';
import EntityContent from './EntityContent';

Expand Down
2 changes: 1 addition & 1 deletion src/components/HomeScreen/HomeContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { groupBy, map } from 'lodash';

import DualPane from 'components/common/DualPane';
import DualPane from 'src/components/common/DualPane';

function getPath(url) {
return new URL(url).pathname;
Expand Down
4 changes: 2 additions & 2 deletions src/components/HomeScreen/HomeInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Icon } from '@blueprintjs/core';

import DualPane from 'components/common/DualPane';
import Breadcrumbs from 'components/common/Breadcrumbs';
import DualPane from 'src/components/common/DualPane';
import Breadcrumbs from 'src/components/common/Breadcrumbs';

import './HomeInfo.css';

Expand Down
2 changes: 1 addition & 1 deletion src/components/HomeScreen/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';

import DualPane from 'components/common/DualPane';
import DualPane from 'src/components/common/DualPane';
import HomeInfo from './HomeInfo';
import HomeContent from './HomeContent';

Expand Down
2 changes: 1 addition & 1 deletion src/components/PageLayout/PageNavbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {FormattedMessage} from 'react-intl';
import {Button} from '@blueprintjs/core';
import {Link} from 'react-router-dom';

import AuthButton from 'components/auth/AuthButton';
import AuthButton from 'src/components/auth/AuthButton';

const SignupButton = () => <Link to="/signup">
<Button iconName="user" className="pt-minimal">
Expand Down
18 changes: 9 additions & 9 deletions src/components/PageLayout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { Route, Switch } from 'react-router-dom';
import { connect } from 'react-redux';
import { Spinner } from '@blueprintjs/core';

import { fetchCollections, fetchMetadata } from 'actions';
import LoginScreen from 'components/auth/LoginScreen';
import LogoutScreen from 'components/auth/LogoutScreen';
import SignupScreen from 'components/auth/SignupScreen';
import ActivateScreen from 'components/auth/ActivateScreen';
import EntityScreen from 'components/EntityScreen';
import HomeScreen from 'components/HomeScreen';
import CollectionScreen from 'components/CollectionScreen';
import ErrorScreen from 'components/ErrorScreen';
import { fetchCollections, fetchMetadata } from 'src/actions';
import LoginScreen from 'src/components/auth/LoginScreen';
import LogoutScreen from 'src/components/auth/LogoutScreen';
import SignupScreen from 'src/components/auth/SignupScreen';
import ActivateScreen from 'src/components/auth/ActivateScreen';
import EntityScreen from 'src/components/EntityScreen';
import HomeScreen from 'src/components/HomeScreen';
import CollectionScreen from 'src/components/CollectionScreen';
import ErrorScreen from 'src/components/ErrorScreen';
import PageNavbar from './PageNavbar';

import './PageLayout.css';
Expand Down
4 changes: 2 additions & 2 deletions src/components/SearchScreen/SearchFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { Component } from 'react';
import { connect } from 'react-redux';
import { mapValues, size, xor } from 'lodash';

import { endpoint } from 'app/api';
import filters from 'constants/searchfilters';
import { endpoint } from 'src/app/api';
import filters from 'src/constants/searchfilters';

import SearchFilterCountries from './SearchFilterCountries';
import SearchFilterCollections from './SearchFilterCollections';
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchScreen/SearchFilterCollections.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FormattedMessage } from 'react-intl';
import { Button, Checkbox, Dialog, NonIdealState, Spinner } from '@blueprintjs/core';
import { debounce, fromPairs, xor } from 'lodash';

import { endpoint } from 'app/api';
import { endpoint } from 'src/app/api';

import SearchFilterList from './SearchFilterList';
import SearchFilterText from './SearchFilterText';
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchScreen/SearchFilterSchema.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FormattedMessage, FormattedNumber } from 'react-intl';
import c from 'classnames';
import sumBy from 'lodash/sumBy';

import SchemaIcon from 'components/common/SchemaIcon';
import SchemaIcon from 'src/components/common/SchemaIcon';

import './SearchFilterSchema.css';

Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchScreen/SearchResultList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { connect } from 'react-redux';
import { NonIdealState, Spinner } from '@blueprintjs/core';
import Waypoint from 'react-waypoint';

import { fetchNextSearchResults } from 'actions';
import { fetchNextSearchResults } from 'src/actions';

import SearchResultListItem from './SearchResultListItem';

Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchScreen/SearchResultListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';

import SchemaIcon from 'components/common/SchemaIcon';
import SchemaIcon from 'src/components/common/SchemaIcon';

function getPath(url) {
return new URL(url).pathname;
Expand Down
4 changes: 2 additions & 2 deletions src/components/SearchScreen/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import queryString from 'query-string';
import { debounce, isEqual, pick, pickBy, isArray } from 'lodash';
import { mergeWith } from 'lodash/fp'; // use fp version to not mutate the array

import { fetchSearchResults } from 'actions';
import filters from 'constants/searchfilters';
import { fetchSearchResults } from 'src/actions';
import filters from 'src/constants/searchfilters';

import SearchResultList from './SearchResultList';
import SearchFilter from './SearchFilter';
Expand Down
6 changes: 3 additions & 3 deletions src/components/auth/ActivateScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {connect} from 'react-redux';
import {Redirect} from 'react-router';
import {injectIntl, FormattedMessage} from 'react-intl';

import {endpoint} from 'app/api';
import {loginWithPassword} from 'actions/sessionActions';
import {xhrErrorToast} from 'components/common/XhrToast';
import {endpoint} from 'src/app/api';
import {loginWithPassword} from 'src/actions/sessionActions';
import {xhrErrorToast} from 'src/components/common/XhrToast';
import {PasswordAuthActivate} from './PasswordAuth';

class ActivateScreen extends Component {
Expand Down
4 changes: 2 additions & 2 deletions src/components/auth/LoginScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {connect} from 'react-redux'
import {Redirect} from 'react-router';
import {NonIdealState} from '@blueprintjs/core';

import messages from 'content/messages';
import {loginWithPassword, loginWithToken} from 'actions/sessionActions';
import messages from 'src/content/messages';
import {loginWithPassword, loginWithToken} from 'src/actions/sessionActions';
import OAuthLogin, {handleOAuthCallback} from './OAuthLogin';
import {PasswordAuthLogin} from './PasswordAuth';

Expand Down
6 changes: 3 additions & 3 deletions src/components/auth/LogoutScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {connect} from 'react-redux'
import {withRouter} from 'react-router';
import {injectIntl} from 'react-intl';

import {logout} from 'actions/sessionActions';
import messages from 'content/messages';
import {showSuccessToast} from 'components/common/Toast';
import {logout} from 'src/actions/sessionActions';
import messages from 'src/content/messages';
import {showSuccessToast} from 'src/components/common/Toast';

class LogoutScreen extends Component {
componentWillMount() {
Expand Down
6 changes: 3 additions & 3 deletions src/components/auth/SignupScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {connect} from 'react-redux';
import {Redirect} from 'react-router';
import {Callout, Intent, NonIdealState} from '@blueprintjs/core';

import messages from 'content/messages';
import {endpoint} from 'app/api';
import {xhrErrorToast} from 'components/common/XhrToast';
import messages from 'src/content/messages';
import {endpoint} from 'src/app/api';
import {xhrErrorToast} from 'src/components/common/XhrToast';
import OAuthLogin from './OAuthLogin';
import {PasswordAuthSignup} from './PasswordAuth';

Expand Down
2 changes: 1 addition & 1 deletion src/components/common/XhrToast.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {showErrorToast, showSuccessToast} from './Toast';
import messages from 'content/messages';
import messages from 'src/content/messages';

const defaultStatusMap = {
400: messages.status.bad_request,
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';

import App from 'app/App';
import App from 'src/app/App';

ReactDOM.render(
React.createElement(App),
Expand Down

0 comments on commit 96fec99

Please sign in to comment.