-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Inline dev-only requires #7188
Inline dev-only requires #7188
Conversation
This reduces the production bundled build size.
Should be easy to make it happen // file.js
require('assertOnlyIncludedInDev');
// assertOnlyIncludedInDev.js
if (!__DEV__) {
throw 'This file should only be included in __DEV__';
} |
@vjeux that doesn't fail the build process, just causes the final bundle to break in the browser. It will break FB though (except when inline-requires is on then it should be ok). |
@zpao hopefully there's at least going to be one test failing if the entire React bundle instant fatal :) |
This fixes the tests which were broken due to inlining some requires.
If we add a check for the production bundle, there is still a potential pitfall: any lazy requires (which could be in prod as well) would not be caught. |
There isn't. We don't have anything run tests on the bundles. Best chance would be running the examples but they all use the dev build. |
Haha, you beat me to it. Ideally we won't have lazy requires any more. |
* Inline dev-only requires This reduces the production bundled build size. * Use new references after resetting module registry in tests This fixes the tests which were broken due to inlining some requires. (cherry picked from commit 8fe6b5f)
* Inline dev-only requires This reduces the production bundled build size. * Use new references after resetting module registry in tests This fixes the tests which were broken due to inlining some requires.
* Eagerly evaluate inline requires in Jest I inlined some requires in #7188 to fix the build size regression. However this caused an issue with Jest due to it resetting module registry between tests. This is a temporary fix to #7240. It should be reverted as part of #7178. * Make the hack work in all environments
* Eagerly evaluate inline requires in Jest I inlined some requires in #7188 to fix the build size regression. However this caused an issue with Jest due to it resetting module registry between tests. This is a temporary fix to #7240. It should be reverted as part of #7178. * Make the hack work in all environments (cherry picked from commit 15ae585)
This is inspired by @keyanzhang’s work in #7178 but without Rollup.
He noticed
ReactComponentTreeDevtool
and some other devtools get included into prod build.This fixes it:
Unfortunately it’s way too easy to regress on this. Maybe we should have a way of marking certain files as dev-only and then failing the build if they end up in production bundle?