Rollup script can now extract error codes and build in a single pass #11291
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relates to this comment.
Now we no longer have to run:
yarn build --extract-errors yarn build # This second run isn't necessary anymoreThis PR contains 2 changes:
scripts/rollup/build.jsThe main fix was swapping the order of error-code-extraction and replacement.
I verified this by first emptying out the contents of
error-codes.json({}) and running:This built the bundle and extracted error codes in a single pass. I copied the resulting build artifacts to an external location and then ran
yarn build dom-fibera second time (after error codes had already been extracted). Then I useddiffto compare the bundles and verify that the following files were identical:scripts/error-codes/replace-invariant-error-codes.jsI also changed this file to always convert invariants to ternaries:
Regardless of whether the error message is in our error codes map. This shouldn't actually matter but...the 2nd format can be faster and so I thought I might as well do it while I was in there. (I'll revert this if anyone thinks it's overkill.)
I tested this change with AST explorer by transforming the following JavaScript:
With an error map that only contained 1 of the strings:
And the resulting transform looked good: