-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Follow-up improvements to error code extraction infra #22516
Commits on Oct 31, 2021
-
Output FIXME during build for unminified errors
The invariant Babel transform used to output a FIXME comment if it could not find a matching error code. This could happen if there were a configuration mistake that caused an unminified message to slip through. Linting the compiled bundles is the most reliable way to do it because there's not a one-to-one mapping between source modules and bundles. For example, the same source module may appear in multiple bundles, some which are minified and others which aren't. This updates the transform to output the same messages for Error calls. The source lint rule is still useful for catching mistakes during development, to prompt you to update the error codes map before pushing the PR to CI.
Configuration menu - View commit details
-
Copy full SHA for cc24142 - Browse repository at this point
Copy the full SHA cc24142View commit details -
Don't run error transform in development
We used to run the error transform in both production and development, because in development it was used to convert `invariant` calls into throw statements. Now that don't use `invariant` anymore, we only have to run the transform for production builds.
Configuration menu - View commit details
-
Copy full SHA for 5a290b1 - Browse repository at this point
Copy the full SHA 5a290b1View commit details -
Add ! to FIXME comment so Closure doesn't strip it
Don't love this solution because Closure could change this heuristic, or we could switch to a differnt compiler that doesn't support it. But it works. Could add a bundle that contains an unminified error solely for the purpose of testing it, but that seems like overkill.
Configuration menu - View commit details
-
Copy full SHA for 9e61bbb - Browse repository at this point
Copy the full SHA 9e61bbbView commit details -
Alternate extract-errors that scrapes artifacts
The build script outputs a special FIXME comment when it fails to minify an error message. CI will detect these comments and fail the workflow. The comments also include the expected error message. So I added an alternate extract-errors that scrapes unminified messages from the build artifacts and updates `codes.json`. This is nice because it works on partial builds. And you can also run it after the fact, instead of needing build all over again.
Configuration menu - View commit details
-
Copy full SHA for 7bb6b69 - Browse repository at this point
Copy the full SHA 7bb6b69View commit details -
Disable error minification in more bundles
Not worth it because the number of errors does not outweight the size of the formatProdErrorMessage runtime.
Configuration menu - View commit details
-
Copy full SHA for bf07c91 - Browse repository at this point
Copy the full SHA bf07c91View commit details -
Run extract-errors script in CI
The lint_build job already checks for unminified errors, but the output isn't super helpful. Instead I've added a new job that runs the extract-errors script and fails the build if `codes.json` changes. It also outputs the expected diff so you can easily see which messages were missing from the map.
Configuration menu - View commit details
-
Copy full SHA for 24feb63 - Browse repository at this point
Copy the full SHA 24feb63View commit details -
Replace old extract-errors script with new one
Deletes the old extract-errors in favor of extract-errors2
Configuration menu - View commit details
-
Copy full SHA for b2e38a9 - Browse repository at this point
Copy the full SHA b2e38a9View commit details