Skip to content
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

Merged
merged 7 commits into from
Oct 31, 2021

Commits on Oct 31, 2021

  1. 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.
    acdlite committed Oct 31, 2021
    Configuration menu
    Copy the full SHA
    cc24142 View commit details
    Browse the repository at this point in the history
  2. 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.
    acdlite committed Oct 31, 2021
    Configuration menu
    Copy the full SHA
    5a290b1 View commit details
    Browse the repository at this point in the history
  3. 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.
    acdlite committed Oct 31, 2021
    Configuration menu
    Copy the full SHA
    9e61bbb View commit details
    Browse the repository at this point in the history
  4. 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.
    acdlite committed Oct 31, 2021
    Configuration menu
    Copy the full SHA
    7bb6b69 View commit details
    Browse the repository at this point in the history
  5. Disable error minification in more bundles

    Not worth it because the number of errors does not outweight the size
    of the formatProdErrorMessage runtime.
    acdlite committed Oct 31, 2021
    Configuration menu
    Copy the full SHA
    bf07c91 View commit details
    Browse the repository at this point in the history
  6. 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.
    acdlite committed Oct 31, 2021
    Configuration menu
    Copy the full SHA
    24feb63 View commit details
    Browse the repository at this point in the history
  7. Replace old extract-errors script with new one

    Deletes the old extract-errors in favor of extract-errors2
    acdlite committed Oct 31, 2021
    Configuration menu
    Copy the full SHA
    b2e38a9 View commit details
    Browse the repository at this point in the history