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

Alias to pre-built react and react-dom in development mode #139

Closed
insin opened this issue Jul 25, 2016 · 2 comments
Closed

Alias to pre-built react and react-dom in development mode #139

insin opened this issue Jul 25, 2016 · 2 comments

Comments

@insin
Copy link
Owner

insin commented Jul 25, 2016

Good idea from facebook/create-react-app#164 to increase development perf by reducing the number of modules.

Would need to check it with a few apps too see if anyone is replying on deep imports from the react package, and will the way the dist version of react-dom loads react work as expected?

{
  resolve: {
    alias: {
      'react': 'react/dist/react.js',
      'react-dom': 'react-dom/dist/react-dom.js'
    }
  }
}

NormalModuleReplacementPlugin is also an option if there are any problems.

I know off-hand that Enzyme would need react-dom/serve aliased too, while react-addons-test-utils is just a deep import into react/lib/ReactTestUtils, but this config would initially only be happening when running a hot-reloading development server.

@Restuta
Copy link

Restuta commented Jul 25, 2016

I use this in prod and there is little caveat. Just setting alias won't improve performance, it also should be added to 'noParse' and to make it work with reactDom or Router imports loader has to be used:

    /* tells webpack to skip parsing following libraries
     requires use of "import loader" for certain modules, based on https://github.com/christianalfoni/react-webpack-cookbook/issues/30
    */
    noParse: [ pathToReact, pathToReactDom, pathToReactRouter ], 
    loaders: [{
      test: pathToReactDOM,
      loader: 'imports'
    }, {
      test: pathToReactRouter,
      loader: 'imports'
    }, {....

Also useful for facebook/create-react-app#164

@insin
Copy link
Owner Author

insin commented Dec 12, 2017

This isn't needed any more - React now publishes development and production bundles

@insin insin closed this as completed Dec 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants