next.js
97056e0d - Add a --webpack flag and default --turbopack to true (#84216)

Commit
87 days ago
Add a --webpack flag and default --turbopack to true (#84216) Make Turbopack the default bundler for Next 🚀 ## What Add a `--webpack` flag so users can select webpack Change behavior so if neither `--turbopack` or `--webpack` is set we default to Turbopack. If we have defaulted the build to turbopack and we observe that the user has a `webpack` config in their next config but no turbopack config, then we issue a warning about this being a potential problem, if this happens during `next build` the warning becomes an error and fails the build. The solution for users is just to explicitly set `--webpack` or `--turbopack` There were a number of subtle issues * some users directly set the `TURBOPACK` environment variable, this PR adds support for that though users should really be passing `--turbopack` so it will not be documented * rspack is enabled via a plugin that sets an environment variable when loading next config, which means it happens way too late! * For builds this isn't too bad, we just have to recompute the `Bundler` after loading the config. For `dev` the parent process can get out of sync with the child, but this is only really relevant for telemetry and for that we already load the config in the parent so just defer computing `isTurboSession`. Most of this is about fixing package.json scripts and CI builds configs. * For package.json * i added aliases e.g. `test-dev` == `test-dev-webpack` but preserved the old names. In the long run we will want to remove the unsuffixed aliases * this required some modifications to existing configs to ensure everything was setting the correct env variables * For ci, i added a new `IS_WEBPACK_TEST` variable to a number of tests but preserved all names. * Again, in the future it would make sense to rename ci jobs but that is deferred for right now. * This also makes it clear that a set of tests scenarios (e.g. ppr, experimental, test-new-tests-*) never run with turbopack. This is not addressed right now but should be in the future. ## Why Today, the default bundler for next is webpack but with turbopack becoming stable it is time to just ship it. Turbopack is already recommended for dev and builds. Create Next App also steers users towards Turbopack. According to telemetry we already have about 50% of all dev sessions and build adoption is growing. So fundamentally why are we even asking users to make a decision?
Author
Parents
Loading