fix(sys): tweak NodeLazyRequire logic around too-high-versions errors #3347
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.
This changes the logic that we use in the
NodeLazyRequire
class toerror out in fewer situations. The changes are:
[string, string]
([minVersion, recommendedVersion]
) to an objectwith
minVersion
recommendedVersion
required properties and anoptional
maxVersion
property.ensure
method onNodeLazyRequire
we check ifmaxVersion
is defined on a given version range requirement.
equal to
minVersion
and less than the major version ofmaxVersion
.minVersion <= installedVersion
This should give us the flexibility to mark certain versions of packages
as incompatible (for instance jest@28) without having to do that for all
packages that we lazy require. This is helpful because for most of them
we just want to set a minimum version and don't have a need for an
enforced maximum version.
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build
) was run locally and any changes were pushednpm test
) were run locally and passednpm run test.karma.prod
) were run locally and passednpm run prettier
) was run locally and passedPull request type
Please check the type of change your PR introduces:
What is the current behavior?
GitHub Issue Number: N/A
In #3346 we added a check that packages that we lazy require for testing and whatnot (basically,
jest
and a few other things) were between the specified minimum version and the recommended version. This will cause an error at runtime if these requirements are not met.On further reflection this isn't quite the behavior that we want. We only want to enforce a maximum version right now for Jest, not for the other packages we load in this manner, but the implementation in #3346 doesn't have any granularity to it.
What is the new behavior?
[string, string]
([minVersion, recommendedVersion]
) to an objectwith
minVersion
recommendedVersion
required properties and anoptional
maxVersion
property.ensure
method onNodeLazyRequire
we check ifmaxVersion
is defined on a given version range requirement.
equal to
minVersion
and less than the major version ofmaxVersion
.minVersion <= installedVersion
This should give us the flexibility to mark certain versions of packages
as incompatible (for instance jest@28) without having to do that for all
packages that we lazy require. This is helpful because for most of them
we just want to set a minimum version and don't have a need for an
enforced maximum version.
Does this introduce a breaking change?
Testing
Unit testing, I also built and tried this out in a test component repo and confirmed that we get errors for Jest but not for other dependencies like puppeteer.
Other information