1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Remove aliasing of react and react-dom (#3731)

* Remove aliasing of react and react-dom
We need that functionality, but React does it automatically.
So, we don't need to do that.
This also fixes #3711 otherwise we need to add a few more aliases.

* Revert "Remove aliasing of react and react-dom"

This reverts commit 929d9567bbdc3f369f13888e846e848a25c9c261.

* Allow to import modules like 'react-dom/server'.
We do this by doing an extact match for 'react' and 'react-dom'
This commit is contained in:
Arunoda Susiripala 2018-02-08 14:21:01 +05:30 committed by GitHub
parent d7941438dd
commit efe9afb2be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -149,10 +149,15 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer
],
alias: {
next: nextDir,
// This bypasses React's check for production mode. Since we know it is in production this way.
// This allows us to exclude React from being uglified. Saving multiple seconds per build.
react: dev ? 'react/cjs/react.development.js' : 'react/cjs/react.production.min.js',
'react-dom': dev ? 'react-dom/cjs/react-dom.development.js' : 'react-dom/cjs/react-dom.production.min.js'
// React already does something similar to this.
// But if the user has react-devtools, it'll throw an error showing that
// we haven't done dead code elimination (via uglifyjs).
// We purposly do not uglify React code to save the build time.
// (But it didn't increase the overall build size)
// Here we are doing an exact match with '$'
// So, you can still require nested modules like `react-dom/server`
react$: dev ? 'react/cjs/react.development.js' : 'react/cjs/react.production.min.js',
'react-dom$': dev ? 'react-dom/cjs/react-dom.development.js' : 'react-dom/cjs/react-dom.production.min.js'
}
},
resolveLoader: {