-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Add experimental cra-to-next transform in codemod cli #24969
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
packages/next/cra-compat.js
Outdated
// these need to be the last rule to prevent catching other items | ||
// https://github.com/facebook/create-react-app/blob/fddce8a9e21bf68f37054586deb0c8636a45f50b/packages/react-scripts/config/webpack.config.js#L594 | ||
|
||
const isWebpack5 = config.future && config.future.webpack5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't be used to detect webpack 5. Should be:
const isWebpack5 = config.future && config.future.webpack5 | |
const isWebpack5 = parseInt(ctx.webpack.version) === 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using the CRA migration it would be a good opportunity to force webpack 5 usage as this is for a "new" app. That also means we don't get a divergence of config here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't force it when @svgr/webpack
is used for the import {ReactComponent as Something} from './some.svg'
since it's not yet compatible with webpack 5, it's enabled by default when this import isn't used though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we codemod / ask users to change that import instead? I don't want converted apps to run on webpack 4 in any case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we could ask users to switch to the standard SVG import and use img
instead, we could potentially run svgr during the transform and output the svg -> react component files so the loader isn't needed although any future svg -> react component usage would need to be done manually 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in 4feec9b to show an error when we detect this type of import and asks them to migrate to a normal SVG import instead to continue to prevent de-opting webpack 5
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
buildDuration | 13.3s | 13.7s | |
buildDurationCached | 3.4s | 3.2s | -158ms |
nodeModulesSize | 46.5 MB | 46.5 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.654 | 2.674 | |
/ avg req/sec | 941.86 | 935.04 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.457 | 1.388 | -0.07 |
/error-in-render avg req/sec | 1716.2 | 1801.68 | +85.48 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
framework-HASH.js gzip | 39.3 kB | 39.3 kB | ✓ |
main-HASH.js gzip | 20.2 kB | 20.2 kB | ✓ |
webpack-HASH.js gzip | 804 B | 804 B | ✓ |
Overall change | 60.3 kB | 60.3 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.1 kB | 31.1 kB | ✓ |
Overall change | 31.1 kB | 31.1 kB | ✓ |
Client Pages
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
_app-HASH.js gzip | 801 B | 801 B | ✓ |
_error-HASH.js gzip | 3.07 kB | 3.07 kB | ✓ |
amp-HASH.js gzip | 527 B | 527 B | ✓ |
css-HASH.js gzip | 334 B | 334 B | ✓ |
hooks-HASH.js gzip | 890 B | 890 B | ✓ |
index-HASH.js gzip | 263 B | 263 B | ✓ |
link-HASH.js gzip | 1.64 kB | 1.64 kB | ✓ |
routerDirect..HASH.js gzip | 333 B | 333 B | ✓ |
withRouter-HASH.js gzip | 330 B | 330 B | ✓ |
bb14e60e810b..30f.css gzip | 125 B | 125 B | ✓ |
Overall change | 8.31 kB | 8.31 kB | ✓ |
Client Build Manifests
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
_buildManifest.js gzip | 392 B | 392 B | ✓ |
Overall change | 392 B | 392 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
index.html gzip | 573 B | 573 B | ✓ |
link.html gzip | 580 B | 580 B | ✓ |
withRouter.html gzip | 567 B | 567 B | ✓ |
Overall change | 1.72 kB | 1.72 kB | ✓ |
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
buildDuration | 15.2s | 15.1s | -90ms |
buildDurationCached | 4.4s | 4.4s | -48ms |
nodeModulesSize | 46.5 MB | 46.5 MB |
Client Bundles (main, webpack, commons)
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
framework-HASH.js gzip | 39.3 kB | 39.3 kB | ✓ |
main-HASH.js gzip | 20.2 kB | 20.2 kB | ✓ |
webpack-HASH.js gzip | 804 B | 804 B | ✓ |
Overall change | 60.3 kB | 60.3 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.1 kB | 31.1 kB | ✓ |
Overall change | 31.1 kB | 31.1 kB | ✓ |
Client Pages
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
_app-HASH.js gzip | 801 B | 801 B | ✓ |
_error-HASH.js gzip | 3.07 kB | 3.07 kB | ✓ |
amp-HASH.js gzip | 527 B | 527 B | ✓ |
css-HASH.js gzip | 334 B | 334 B | ✓ |
hooks-HASH.js gzip | 890 B | 890 B | ✓ |
index-HASH.js gzip | 263 B | 263 B | ✓ |
link-HASH.js gzip | 1.64 kB | 1.64 kB | ✓ |
routerDirect..HASH.js gzip | 333 B | 333 B | ✓ |
withRouter-HASH.js gzip | 330 B | 330 B | ✓ |
bb14e60e810b..30f.css gzip | 125 B | 125 B | ✓ |
Overall change | 8.31 kB | 8.31 kB | ✓ |
Client Build Manifests
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
_buildManifest.js gzip | 392 B | 392 B | ✓ |
Overall change | 392 B | 392 B | ✓ |
Serverless bundles Overall increase ⚠️
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
_error.js | 16.9 kB | 16.9 kB | |
404.html | 2.44 kB | 2.44 kB | ✓ |
500.html | 2.43 kB | 2.43 kB | ✓ |
amp.amp.html | 10.8 kB | 10.8 kB | ✓ |
amp.html | 1.63 kB | 1.63 kB | ✓ |
css.html | 1.81 kB | 1.81 kB | ✓ |
hooks.html | 1.69 kB | 1.69 kB | ✓ |
index.js | 17.2 kB | 17.2 kB | |
link.js | 17.4 kB | 17.4 kB | |
routerDirect.js | 17.4 kB | 17.4 kB | ✓ |
withRouter.js | 17.4 kB | 17.4 kB | ✓ |
Overall change | 107 kB | 107 kB |
Webpack 4 Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
buildDuration | 11.6s | 11.8s | |
buildDurationCached | 4.8s | 4.9s | |
nodeModulesSize | 46.5 MB | 46.5 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.693 | 2.685 | -0.01 |
/ avg req/sec | 928.5 | 931.15 | +2.65 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.331 | 1.376 | |
/error-in-render avg req/sec | 1878.49 | 1816.79 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
677f882d2ed8..HASH.js gzip | 13.4 kB | 13.4 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-HASH.js gzip | 7.99 kB | 7.99 kB | ✓ |
webpack-HASH.js gzip | 751 B | 751 B | ✓ |
Overall change | 61.1 kB | 61.1 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.3 kB | 31.3 kB | ✓ |
Overall change | 31.3 kB | 31.3 kB | ✓ |
Client Pages
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
_app-HASH.js gzip | 1.07 kB | 1.07 kB | ✓ |
_error-HASH.js gzip | 3.74 kB | 3.74 kB | ✓ |
amp-HASH.js gzip | 536 B | 536 B | ✓ |
css-HASH.js gzip | 339 B | 339 B | ✓ |
hooks-HASH.js gzip | 887 B | 887 B | ✓ |
index-HASH.js gzip | 227 B | 227 B | ✓ |
link-HASH.js gzip | 1.63 kB | 1.63 kB | ✓ |
routerDirect..HASH.js gzip | 303 B | 303 B | ✓ |
withRouter-HASH.js gzip | 302 B | 302 B | ✓ |
e025d2764813..52f.css gzip | 125 B | 125 B | ✓ |
Overall change | 9.17 kB | 9.17 kB | ✓ |
Client Build Manifests
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
_buildManifest.js gzip | 420 B | 420 B | ✓ |
Overall change | 420 B | 420 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | ijjk/next.js feat/cra-to-next-cli | Change | |
---|---|---|---|
index.html gzip | 625 B | 625 B | ✓ |
link.html gzip | 632 B | 632 B | ✓ |
withRouter.html gzip | 620 B | 620 B | ✓ |
Overall change | 1.88 kB | 1.88 kB | ✓ |
Co-authored-by: Tim Neutkens <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This adds a new codemod to allow transforming a CRA project into a Next.js project automatically
Note: while testing locally the
next/cra-compat
needs to updated to the absolute path locally since the file doesn't exist in the installed version of Next.js until after this has been merged and published.Feature
fixes #number