Skip to content

Conversation

randycoulman
Copy link
Contributor

@randycoulman randycoulman commented Jun 14, 2017

This updates ReactGen to zeal/react-scripts 2.0.0 (see CodingZeal/create-react-app#13).

Notes:

  • Adapts to the change in how we resolve modules. We now provide a .env file that sets NODE_PATH to ./client.

  • Supports the new APP_PORT environment variable; this allows react-scripts to open the browser to the correct location when hosting in a back-end application. By default, we set it to the same port as the webpack dev server; client applications should edit this as appropriate to their context.

  • Modifies the eslint configuration for Webpack 2. Because we need to use the webpack resolver, we have to update our configuration. See the comment in that file for all of the gory details of why I couldn't do it the way I wanted.

  • I had to add an explicit dependency on eslint 3.19.0. sass-lint pulls in a 2.x version of eslint, and the eslint loader would pull in that version instead of 3.19.0, resulting in numerous warnings about unknown rules. A better solution is Switch from sass-lint to stylelint #81 which will eliminate the old dependency.

create-react-app was designed to look at `NODE_PATH` when resolving imports; we were making a bunch of changes in `@zeal/react-scripts` to do the same job, but the upcoming version of `@zeal/react-scripts` will no longer do that.

Instead, we add `NODE_PATH` to a `.env` file and that is used to resolve module imports.
The webpack options for resolver settings has changed with Webpack 2 (which is what the upcoming version of `@zeal/react-scripts` uses, so we need to change our configuration a bit.

Ideally, we'd just point at `@zeal/react-scripts`' webpack configuration file, but that doesn't work (yet).  See the comments in `app/templates/.eslintrc.js` for details.
Because of the way yarn resolves dependencies, we can sometimes end up in a situation where the eslint-loader depends on eslint@2.x instead of eslint@3.19.0, resulting in a number of lint warnings about unknown rules.

The issue is that we only transitively depend on eslint via @zeal/react-scripts, but sass-lint depends on eslint@2.x.

Since eslint-loader (and eslint-plugin-import) have peerDependencies that allow eslint@2.x, that's what they sometimes get.

By depending directly on 3.19.0, those peerDependencies get resolved to that version because direct dependencies have priority over transitive dependencies.
Since we can't refer directly to our webpack config file, at least we can use the same paths as it configures instead of duplicating them.
The latest react-scripts will use this to open the browser to the correct location.  By default, it's set to the same port as the front-end app, but can be changed when embedded in a back-end host application.
@randycoulman randycoulman force-pushed the chores/update-to-cra-1.0-scripts branch from 2e8cdcb to e935869 Compare June 16, 2017 17:58
Also, minor fixes/cleanups.
@randycoulman randycoulman changed the title **DO NOT MERGE YET** Update to latest zeal/react-scripts Update to latest zeal/react-scripts Jun 17, 2017
@randycoulman randycoulman merged commit 5c29588 into master Jun 17, 2017
@randycoulman randycoulman deleted the chores/update-to-cra-1.0-scripts branch June 17, 2017 00:16
@randycoulman randycoulman mentioned this pull request Jun 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants