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

[BUGFIX release] Ensure ember-testing is loaded lazily #19540

Merged
merged 1 commit into from May 12, 2021

Commits on May 11, 2021

  1. [BUGFIX release] Ensure ember-testing is loaded lazily

    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:
    
    ```js
    import { registerWaiter } from '@ember/test';
    
    if (someCondition) {
      registerWaiter(() => {});
    }
    ```
    
    Would become this:
    
    ```js
    if (someCondition) {
      Ember.Test.registerWaiter(() => {});
    }
    ```
    
    In either example, `registerWaiter` may or may not be called based on
    the state of `someCondition`. However, in the second case, if
    `Ember.Test` is not defined at all, it's completely ok as long as
    `someCondition` is `false`. It's never called, so we never get an error
    telling 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 means
    it will throw an error immediately.
    
    This PR makes the `@ember/test` module load `ember-testing` lazily, and
    if it's not available (e.g. in a production environment) it replaces the
    values with a function that throws a helpful error.
    Chris Garrett committed May 11, 2021
    Configuration menu
    Copy the full SHA
    995d6a7 View commit details
    Browse the repository at this point in the history