refactor: make RuntimeError class reusable across packages#44348
refactor: make RuntimeError class reusable across packages#44348AndrewKushnir wants to merge 4 commits intoangular:masterfrom
RuntimeError class reusable across packages#44348Conversation
|
Based on the |
This commit updates the code around the `RuntimeError` class to make it more reusable between packages (currently it's only usable inside the `core` package). Specifically: - the public-facing error code now includes a package id (it was hardcoded before) - there is no special Set that contains a set of error codes for which we have guides on angular.io. Instead, this is now encoded into the error code itself (making such codes negative integers). Having a separate Set makes it non-tree-shakable, which we want to avoid. This change should allow to employ the `RuntimeError` class in other packages to further standardize this subsystem and make the errors thrown by the framework consistent.
This commit moves some scripts around to co-locate RuntimeError-related scipts under `packages/core/src/errors` folder.
This commit performs some refactoring of the AbstractControl-based classes to employ shared `RuntimeError` class and also updates the code to avoid duplication and improve minification.
3bc2efb to
c69f47f
Compare
goldens/circular-deps/packages.json
Outdated
There was a problem hiding this comment.
Note to reviewers: this is a type-only import from util.ts -> index.ts, not a real cycle. We'd need to re-discuss if type-only imports should be excluded from the cycle detection.
There was a problem hiding this comment.
I can inline the code from the util.ts into the index.ts to avoid this cycle, but I'd prefer not to do that as I'm trying to keep the errors/index.ts as small as possible as it contains the structure that I've reused across other packages.
jessicajaniuk
left a comment
There was a problem hiding this comment.
LGTM 🍪
reviewed-for: size-tracking
packages/core/src/errors/index.ts
Outdated
There was a problem hiding this comment.
Document that this minus sign is a code size optimization, so we don't end up shipping a Set or array to runtime.
Previously, the NgSwitch directive used RuntimeError class from core as is. As a result, it was only possible to reuse some existing error codes (which were core-specific, with core prefix in the code). This commit updates the logic to create package-specific version of the `RuntimeError` class that can be used in the common package. This commit also refactors existing code to use that new class.
da8e96a to
0d9e25a
Compare
|
Closing this PR in favor of #44398 where I've changed the implementation to avoid creating a new unique |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This PR contains a few commits that make the
RuntimeErrorclass reusable across packages + performs some refactoring to use the class in the Forms package.PR Type
What kind of change does this PR introduce?
Does this PR introduce a breaking change?