[BUGFIX release] Ensure ember-testing is loaded lazily #19540
Merged
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.
The recently modules API update means we are now loading real modules,
not polyfills based on the global. This means that the modules
themselves are eagerly required, rather than being references to a
value on the global. For example, previously, this:
Would become this:
In either example,
registerWaiter
may or may not be called based onthe state of
someCondition
. However, in the second case, ifEmber.Test
is not defined at all, it's completely ok as long assomeCondition
isfalse
. It's never called, so we never get an errortelling us
Ember.Test
is undefined.Without the transform, the module is eagerly required, along with all of
its dependencies. If no one included
ember-testing
, then that meansit will throw an error immediately.
This PR makes the
@ember/test
module loadember-testing
lazily, andif it's not available (e.g. in a production environment) it replaces the
values with a function that throws a helpful error.
Fixes #19538, emberjs/ember-cli-babel#406