Hey everyone! We know progress on [email protected]
has been stagnating for a while.
We put together a lofty set of goals when we first started v2.
The scope of these changes have proven themselves to be too large to effectively polish everything and create a stable build.
To remediate this, we're going to reduce the scope of v2, polish completed features, and release v2 as stable within the next two (2) weeks.
Our proposed plan of action is as follows (in no particular order):
:white_check_mark: Fix vendor chunking (https://github.com/facebook/create-react-app/issues/4977, https://github.com/facebook/create-react-app/issues/4769, https://github.com/facebook/create-react-app/issues/4633, https://github.com/facebook/create-react-app/issues/4632)
:white_check_mark: Switch to Terser (https://github.com/facebook/create-react-app/issues/4948, https://github.com/facebook/create-react-app/issues/4902, https://github.com/facebook/create-react-app/issues/4711, https://github.com/facebook/create-react-app/issues/4692, https://github.com/facebook/create-react-app/issues/4683, https://github.com/facebook/create-react-app/issues/4665, https://github.com/facebook/create-react-app/issues/4329, https://github.com/facebook/create-react-app/issues/4116, https://github.com/facebook/create-react-app/issues/4100)
:white_check_mark: Revert monoreport support (https://github.com/facebook/create-react-app/pull/3741, https://github.com/facebook/create-react-app/pull/3997, https://github.com/facebook/create-react-app/pull/4001) because there's too many issues (https://github.com/facebook/create-react-app/issues/4569, https://github.com/facebook/create-react-app/issues/4410, https://github.com/facebook/create-react-app/issues/4249, https://github.com/facebook/create-react-app/issues/4092, https://github.com/facebook/create-react-app/pull/4570, https://github.com/facebook/create-react-app/issues/3031, https://github.com/facebook/create-react-app/pull/3967)
nwb
and provide excellent documentation on how to do so. This is arguably the best way.:white_check_mark: Fix edge-cases for compiling node_modules
and polish Babel 7 upgrade
node_modules
has surfaced some issues, particularly around async
/await
and regenerator
.:white_check_mark: Remove mjs
support
mjs
support and we're going to remove support to fix complex edge cases with resolving modules. There are alternative resolve orders based on source file and supported features which are concepts Jest does not have support for yet.:white_check_mark: Drop advanced proxy configuration and replace it with express
middleware
express
app instance. You can attach any middleware or routes to this express
app that you'd like.:white_check_mark: Remove support for targeting newer browsers
node_modules
, so you can consume any package using newer syntax without worry.Please let us know your thoughts and if we missed anything.
We'll be more than happy to explain our rationale around these decisions if there's any further questions.
If there's anything you (and the community) feel strongly about but is not found on this list, please make an effort to send a PR!
We'll be more than happy to accept contributions.
Cheers, everyone!
To summarize the existing changes and the above proposed changes:
node_modules
to support packages using newer language featuresbrowserslist
package.json keypropTypes
definitions in the production buildpackage.json
(moving to src/setupProxy.js
instead)mjs
extension supportThis list looks good! One ask I have, with "Compiling node_modules to support packages using newer language features", can we get support for dynamic imports in node_modules
included in 2.0? CRA supports dynamic imports for "app code". Would like to extend that support for dynamic imports used in dependencies.
I am curious about the Monorepo support via nwb
? I always understood nwb
is something similar to create-react-app
? Are you talking about a different package? I am interested in this because I would like to do some code sharing between two CRA projects and looking for a good solution to do without publish a package to npm
The plan (@Timer correct me if I'm wrong) is that we'll support putting CRA in a monorepo but we won't attempt to compile any code outside the project folder (e.g. JSX). You can compile it with tools like nwb
though.
re @weyert @gaearon: spot on!
re @bjankord: We have that on our list of considerations. We're not ready to make a final decision.
Unfortunately, the proposal is only stage 3 so we're leaning towards a no.
I've got a working monorepo with a [email protected]
project inside. I also documented some of the gotchas I encountered along the way. Most of them tended to be that I have to use the same version of certain packages in my other sibling projects due to react-scripts@2's feature of tooling version validation and a bit of yarn's version resolution system.
I'd be happy to share what I've discovered with someone if they wanted to reach out to me. Unfortunately, I don't have the time to directly contribute on documentation at this time, but I do have time for a quick chat and knowledge share.
"Parallelization of webpack builds to speed up compilation" What does this mean? That a single build will have webpack tasks spread across the various CPU cores? Or that multiple build configurations will run in parallel?
"Parallelization of webpack builds to speed up compilation" What does this mean? That a single build will have webpack tasks spread across the various CPU cores? Or that multiple build configurations will run in parallel?
That a single build will have webpack tasks spread across the various CPU cores.
re @bjankord: Dan and I spoke, we will support dynamic import (import()
) in node_modules
!
@Timer I'm asking ya'll what you mean by that statement. I don't know what it means, and I'm asking for clarification. I proposed some speculations.
Sorry @tbranyen, I didn't mean to leave the question mark -- your speculation was correct. I edited my comment to reflect this.
Processing files through ESLint, Babel, and Minification all happen in worker processes. It'll use all but 1 available cores.
@Timer @gaearon
You're awesome!
I would love to see CRA v2 consider referencing create-react-library as a mature sister project for solving the monorepo use case of defining reusable component libraries, especially if this is just going to be a docs update.
Nothing against nwb
-- CRL
just seems more similar in spirit and simplicity to CRA
.
(note that I am the maintainer of create-react-library
)
Nice that v2 will finally be released!
Sad about the drop of monorepo support.
Uglify has been the source of a lot of problems, and is no longer maintained. We should switch to Terser (the more maintained fork of Uglify) to fix obscure bugs resulting from production builds.
Just adding 2 cents on this. UglifyJS itself is still maintained (from what I know), it is UglifyES that got discontinued and it's the one that is now maintained by Fabio as Terser. UglifyJS should still be a good enough choice for CRA (at this point in time) as from what I read you plan to output es5 for now and that is exactly what is supported by UglifyJS.
UglifyJS should still be a good enough choice for CRA (at this point in time) as from what I read you plan to output es5 for now and that is exactly what is supported by UglifyJS.
We only plan on outputting es5 for the short term. We want to add a modern mode that outputs ESNext.
Sorry I didn't get the semantics quite right, I'll edit for clarity!
is there any possibility to also make it Server side rendered app?
Sorry I didn't get the semantics quite right, I'll edit for clarity!
No problem, that is an easy mistake to make. I'm not involved in those projects, but felt that this could be clarified in the post. Cheers!
Maybe we could land support for modern browsers (https://github.com/facebook/create-react-app/pull/4964) in v2? I would do whatever it takes to make it happen.
Great!
Re: modern browsers please don't miss this in the original post:
In a follow up release, (potentially v2.1) we will explore adding a "modern"/evergreen browser mode which outputs modern, (nearly) uncompiled ESnext. This should give users the best of both worlds, and is in line with what we see in the community. A proposal going into more detail will be put together after the release of v2.
Does https://github.com/facebook/create-react-app/pull/4772 not give the desired vendor chunking behavior?
I don't think creating a vendor chunk per application chunk should be the goal. The point for the vendor chunk is to contain a lot of the commonly-used dependencies so each application chunk does not have to load them (things like react etc).
is there any possibility to also make it Server side rendered app?
@rawris
Sorry, but this is out of scope at this time. Please consider something like Next.js in the meantime.
Does #4772 not give the desired vendor chunking behavior?
@TLadd
Sorry, I didn't see that PR -- but that PR uses the default behavior which names chunks via what's included (instead of numbering them) causing unnecessary cache invalidations.
Using { name: false }
is recommended for production.
No worries; glad to have it fixed!
While I've downgraded to 1.x, my issue with 2.x beta was that it's memory exploded and it couldn't build a project that 1.x could build without issues.
The app had the following dependencies:
"dependencies": {
"aws-sdk": "^2.287.0",
"d3": "^5.5.0",
"firebase": "^5.3.1",
"immutable": "^3.8.2",
"lunr": "^2.3.1",
"mapbox-gl": "^0.47.0",
"mousetrap": "^1.6.2",
"numeraljs": "^1.5.6",
"pandas-js": "^0.2.4",
"plotly.js": "^1.39.4",
"qs": "^6.5.2",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-offline": "^0.1.0",
"react-plotly.js": "^2.2.0",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-semantic-ui-range": "^0.6.2",
"react-spinners": "^0.3.3",
"react-tap-event-plugin": "^3.0.3",
"redux": "^4.0.0",
"redux-thunk": "^2.3.0",
"semantic-ui-css": "^2.3.3",
"semantic-ui-react": "^0.82.1"
},
I understand that these imports could be optimised and separated or partially loaded from CDN, like plotly.js, but just wanted to show a use case where 2.x couldn't build something what 1.x could.
Can you please share a reproducing project of something that can't build but built with v1 please, @hyperknot?
@Timer I cannot share the project I'm working on, but maybe I can just create a new app and import these ones to repro.
That'd be helpful! I'm not sure if it requires some to be dynamic imports, etc. Please make it as close to your app as possible. :-)
@Timer it was all ES imports, but I'll try to create a repro case.
Understandable that the monorepo support was dropped for now, any chance it will be considered for a future 2.x release?
Adding another tooling layer to compile internal monorepo packages that do not need to be published is less than ideal.
We might consider it but it needs to be a more concrete proposal and ideally there would be some consensus between different tools on how to do it.
The final beta has been released! Please see issue https://github.com/facebook/create-react-app/issues/5103.
Hey, sorry if this is already documented, I can't find it:
Monorepo support (supplanted via documentation)
Can you point me to the documentation on how to import transpiled JS that is outside the CRA /src folder? Or am I misunderstanding?
@mdavid88 that is under the "removed features" section. It did not ship with v2, maybe with v3!
@Timer Hey thanks. I was unclear. I get that it's been removed, but it sounds like the functionality still exists to do what I want:
We're going to revert monorepo support in favor of consuming library packages via nwb and provide excellent documentation on how to do so. This is arguably the best way.
I have a shared-components directory as a sibling to the CRA directory, with built components using nwb. Is there a way to import ComponentName from 'shared-components'
in my CRA app, or am I misunderstanding?
Sure, that behavior should "just work" assuming your package.json is configured correctly to point at compiled sources and not original source. Can we file a new issue for continued discussion? I don't want to make more noise on this closed issue. Thanks!
Most helpful comment
To summarize the existing changes and the above proposed changes:
v2 Features
node_modules
to support packages using newer language featuresbrowserslist
package.json keypropTypes
definitions in the production buildFeatures removed from v2
package.json
(moving tosrc/setupProxy.js
instead)mjs
extension support