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] Refine Ember Global deprecation message #19557

Merged
merged 1 commit into from May 26, 2021

Conversation

chancancode
Copy link
Member

@chancancode chancancode commented May 25, 2021

Example message:

Example message:

Usage of the Ember Global is deprecated. You should import the Ember module or the specific API instead.

See https://deprecations.emberjs.com/v3.x/#toc_ember-global for details.

Usages of the Ember Global may be caused by an outdated ember-cli-babel dependency. The following steps may help:

* Upgrade your `devDependencies` on `ember-cli-babel` to `^7.26.6`.
* Upgrade the following addons to the latest version:
  * active-model-adapter
  * ember-animated
  * ember-async-await-helper
  * ember-attacher
  * ember-cli-showdown
  * ember-freestyle
  * ember-md5

### Important ###

In order to avoid repeatedly showing the same deprecation messages, no further deprecation messages will be shown for usages of the Ember Global until ember-cli-babel is upgraded to v7.26.6 or above.

To see all instances of this deprecation message at runtime, set the `EMBER_GLOBAL_DEPRECATIONS` environment variable to "all", e.g. `EMBER_GLOBAL_DEPRECATIONS=all ember test`.

### Details ###

Prior to v7.26.6, ember-cli-babel sometimes transpiled imports into the equivalent Ember Global API, potentially triggering this deprecation message even when you did not directly reference the Ember Global.

The following outdated versions are found in your project:

* ember-cli-babel@6.11.0, currently used by:
  * ember-md5@6.11.0
    * Depends on ember-cli-babel@6.11.0

* ember-cli-babel@6.18.0, currently used by:
  * active-model-adapter@6.18.0
    * Depends on ember-cli-babel@^6.8.2
  * ember-angle-bracket-invocation-polyfill@6.18.0
    * Depends on ember-cli-babel@^6.17.0
    * Added by ember-animated@0.11.0
  * ember-async-await-helper@6.18.0
    * Depends on ember-cli-babel@^6.16.0
  * ember-cli-deploy-bugsnag@6.18.0 (Dormant)
    * Depends on ember-cli-babel@^6.16.0
  * ember-cli-showdown@6.18.0
    * Depends on ember-cli-babel@^6.8.1
  * ember-inflector@6.18.0
    * Depends on ember-cli-babel@^6.0.0
    * Added by active-model-adapter@2.2.0
  * ember-maybe-import-regenerator@6.18.0 (Dormant)
    * Depends on ember-cli-babel@^6.0.0-beta.4
    * Added by ember-animated@0.11.0
  * ember-named-arguments-polyfill@6.18.0 (Dormant)
    * Depends on ember-cli-babel@^6.6.0
    * Added by ember-animated@0.11.0
  * ember-raf-scheduler@6.18.0
    * Depends on ember-cli-babel@^6.6.0
    * Added by ember-attacher@1.2.3 > ember-popper@0.11.3
  * ember-runtime-enumerable-includes-polyfill@6.18.0 (Dormant)
    * Depends on ember-cli-babel@^6.9.0
    * Added by ember-freestyle@0.12.11

* ember-cli-babel@7.26.5, currently used by:
  * @embroider/macros@7.26.5 (Compatible)
    * Depends on ember-cli-babel@^7.23.0
    * Added by ember-cli-mirage@2.2.0
    * Added by ember-exam@6.1.0
  * direwolf (your app)
    * Depends on ember-cli-babel@7.26.5
  * ember-attacher@7.26.5 (Compatible)
    * Depends on ember-cli-babel@^7.23.0
  * ember-fetch@7.26.5 (Compatible)
    * Depends on ember-cli-babel@^7.23.0
  * ember-freestyle@7.26.5 (Compatible)
    * Depends on ember-cli-babel@^7.23.0
  * ember-inflector@7.26.5 (Compatible)
    * Depends on ember-cli-babel@^7.23.0
    * Added by ember-data@3.26.0
    * Added by ember-cli-mirage@2.2.0
  * ember-source@7.26.5 (Dormant)
    * Depends on ember-cli-babel@^7.23.0
  * qunit-dom@7.26.5 (Dormant)
    * Depends on ember-cli-babel@^7.23.0

Note: Addons marked as "Dormant" does not appear to have any JavaScript files. Therefore, even if they are using an old version ember-cli-babel, they are unlikely to be the cuplrit of this deprecation and can likely be ignored.

Note: Addons marked as "Compatible" are already compatible with ember-cli-babel@7.26.6. Try upgrading your `devDependencies` on `ember-cli-babel` to `^7.26.6`.

lib/index.js Outdated Show resolved Hide resolved
@chancancode chancancode force-pushed the refine-globals-deprecation branch 3 times, most recently from 14f4a40 to f2934b1 Compare May 26, 2021 01:30

_issueGlobalsDeprecation() {
if (process.env.EMBER_ENV === 'production') {
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we still need to set the bootstrap string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a default (same as the current one) on the prototype (?)

@@ -64,11 +76,14 @@ module.exports = {
name: 'ember-source',
paths,
absolutePaths,
_bootstrapEmber: "require('@ember/-internals/bootstrap').default();",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, gotcha sorry

Example message:

```
Usage of the Ember Global is deprecated. You should import the Ember module or the specific API instead.

See https://deprecations.emberjs.com/v3.x/#toc_ember-global for details.

Usages of the Ember Global may be caused by an outdated ember-cli-babel dependency. The following steps may help:

* Upgrade your `devDependencies` on `ember-cli-babel` to `^7.26.6`.
* Upgrade the following addons to the latest version:
  * active-model-adapter
  * ember-animated
  * ember-async-await-helper
  * ember-attacher
  * ember-cli-showdown
  * ember-freestyle
  * ember-md5

### Important ###

In order to avoid repeatedly showing the same deprecation messages, no further deprecation messages will be shown for usages of the Ember Global until ember-cli-babel is upgraded to v7.26.6 or above.

To see all instances of this deprecation message at runtime, set the `EMBER_GLOBAL_DEPRECATIONS` environment variable to "all", e.g. `EMBER_GLOBAL_DEPRECATIONS=all ember test`.

### Details ###

Prior to v7.26.6, ember-cli-babel sometimes transpiled imports into the equivalent Ember Global API, potentially triggering this deprecation message even when you did not directly reference the Ember Global.

The following outdated versions are found in your project:

* ember-cli-babel@6.11.0, currently used by:
  * ember-md5@6.11.0
    * Depends on ember-cli-babel@6.11.0

* ember-cli-babel@6.18.0, currently used by:
  * active-model-adapter@6.18.0
    * Depends on ember-cli-babel@^6.8.2
  * ember-angle-bracket-invocation-polyfill@6.18.0
    * Depends on ember-cli-babel@^6.17.0
    * Added by ember-animated@0.11.0
  * ember-async-await-helper@6.18.0
    * Depends on ember-cli-babel@^6.16.0
  * ember-cli-deploy-bugsnag@6.18.0 (Dormant)
    * Depends on ember-cli-babel@^6.16.0
  * ember-cli-showdown@6.18.0
    * Depends on ember-cli-babel@^6.8.1
  * ember-inflector@6.18.0
    * Depends on ember-cli-babel@^6.0.0
    * Added by active-model-adapter@2.2.0
  * ember-maybe-import-regenerator@6.18.0 (Dormant)
    * Depends on ember-cli-babel@^6.0.0-beta.4
    * Added by ember-animated@0.11.0
  * ember-named-arguments-polyfill@6.18.0 (Dormant)
    * Depends on ember-cli-babel@^6.6.0
    * Added by ember-animated@0.11.0
  * ember-raf-scheduler@6.18.0
    * Depends on ember-cli-babel@^6.6.0
    * Added by ember-attacher@1.2.3 > ember-popper@0.11.3
  * ember-runtime-enumerable-includes-polyfill@6.18.0 (Dormant)
    * Depends on ember-cli-babel@^6.9.0
    * Added by ember-freestyle@0.12.11

* ember-cli-babel@7.26.5, currently used by:
  * @embroider/macros@7.26.5 (Compatible)
    * Depends on ember-cli-babel@^7.23.0
    * Added by ember-cli-mirage@2.2.0
    * Added by ember-exam@6.1.0
  * direwolf (your app)
    * Depends on ember-cli-babel@7.26.5
  * ember-attacher@7.26.5 (Compatible)
    * Depends on ember-cli-babel@^7.23.0
  * ember-fetch@7.26.5 (Compatible)
    * Depends on ember-cli-babel@^7.23.0
  * ember-freestyle@7.26.5 (Compatible)
    * Depends on ember-cli-babel@^7.23.0
  * ember-inflector@7.26.5 (Compatible)
    * Depends on ember-cli-babel@^7.23.0
    * Added by ember-data@3.26.0
    * Added by ember-cli-mirage@2.2.0
  * ember-source@7.26.5 (Dormant)
    * Depends on ember-cli-babel@^7.23.0
  * qunit-dom@7.26.5 (Dormant)
    * Depends on ember-cli-babel@^7.23.0

Note: Addons marked as "Dormant" does not appear to have any JavaScript files. Therefore, even if they are using an old version ember-cli-babel, they are unlikely to be the cuplrit of this deprecation and can likely be ignored.

Note: Addons marked as "Compatible" are already compatible with ember-cli-babel@7.26.6. Try upgrading your `devDependencies` on `ember-cli-babel` to `^7.26.6`.

```
@rwjblue rwjblue merged commit 825c1b1 into master May 26, 2021
@rwjblue rwjblue deleted the refine-globals-deprecation branch May 26, 2021 13:23
@stefanpenner
Copy link
Member

This may have broken embroider builds: embroider-build/embroider#833

@stefanpenner
Copy link
Member

stefanpenner commented Jun 2, 2021

The contract between Embroider & ideal Add-ons is that they are statically consumable. This change, takes a step backwards from that approach. As it requires the code which invokes the "bootstrapping" code to be generated dynamically at build time. Each such dynamic injection of code must either be avoided, or replicated both here and in embroider which seems like an anti pattern, or rely on embroider's macro system to achieve.

let projectInfo;

for (let [addon, pathToAddon] of walkAddonTree(this.project)) {
let version = addon.pkg.version;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may (speculation, and untested) want to skip the current iteration if the pathToAddon has already appeared. Some large applications, especially those using engines can have a very LARGE number of add-ons that must be considered (10s or 100s of thousands), and it is often the case that these extra traversals can cause CLI boot-time regressions.

But if the pathToAddon has already been considered it is safe to use the previous result, and skip the upcoming work.

@@ -309,4 +324,236 @@ module.exports = {

return debugTree(new MergeTrees([ember, templateCompiler, jquery]), 'vendor:final');
},

_issueGlobalsDeprecation() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function looks quite complex, but I don't see any tests ensuring it is both accurate and remains accurate overtime. Are these present elsewhere or is this an oversight?

@stefanpenner
Copy link
Member

stefanpenner commented Jun 2, 2021

Reading this further given that https://github.com/emberjs/ember.js/blob/master/lib/index.js#L305-L317 exists, do these deprecations run for folks lucky enough to get a prebuilt version of ember? If i'm reading this correctly folks lucky enough to get a prebuilt ember will get 1) helpful console message while building 2) the huge number of warnings this PR attempted to correct, at runtime.

@stefanpenner
Copy link
Member

stefanpenner commented Jun 2, 2021

Speaking with @rwjblue, it would appear the following might be the best course of action:

  1. restore this bootstrap code to be an IFFE (good default, an preserves the existing hand-shake with embroider)
  2. if the above detection detects the problematic case (improper duplicate versions of ember-cli babel) overlay a new IFFE file with the appropriate error message and merge it in.

This is viable because embroider versions aren't effected by this issue, nor are peoples applications which aren't detected to be invalid, also folks with prebuilt versions of ember don't benefit from the newly built bootstrap file.

(we are working on this now)

rwjblue added a commit that referenced this pull request Jun 3, 2021
Fixes a few things:

* Ensures that Embroider has a consistent protocol for ensuring the global is bootstrapped
* Allows our override code to be transpiled
* Ensures that any bootstrapping tweaks force us out of "prebuilt" mode (allowing that customized bootstrap code to actually run)

Refactors the work in #19557 to address some of the recent comments there.

(cherry picked from commit 5ad6f79)
rwjblue added a commit that referenced this pull request Jun 3, 2021
Fixes a few things:

* Ensures that Embroider has a consistent protocol for ensuring the global is bootstrapped
* Allows our override code to be transpiled
* Ensures that any bootstrapping tweaks force us out of "prebuilt" mode (allowing that customized bootstrap code to actually run)

Refactors the work in #19557 to address some of the recent comments there.

(cherry picked from commit 5ad6f79)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants