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

Remove deprecated injections in Ember 4.x #900

Closed

Conversation

backspace
Copy link

This is an attempt to fix #869. I don’t have much experience with addon development, but this seemed like a conventional way to check whether .inject could still be used.

Thanks for the years of work on this, all!

@@ -70,6 +70,7 @@
"ember-cli-inject-live-reload": "^2.0.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-terser": "^4.0.1",
"ember-compatibility-helpers": "^1.2.6",
Copy link
Contributor

Choose a reason for hiding this comment

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

@backspace this should be in dependencies as it's used in run-time by comsumer apps rather than dev time

Copy link
Author

Choose a reason for hiding this comment

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

Okay, fixed, thanks!

@SergeAstapov
Copy link
Contributor

I think @mansona spend quite some time on these deprecation and has very good context here

@gilest
Copy link

gilest commented Nov 23, 2022

Thanks for your contributions.

Tried installing from this branch and it broke the build.

Build Error (WaitForTrees)

The "path" argument must be of type string. Received undefined
  - broccoliBuilderErrorStack: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:387:5)
    at validateString (node:internal/validators:162:11)
    at join (node:path:1172:7)
    at CompatAddons.linkNonCopiedDeps (/application/node_modules/@embroider/compat/src/compat-addons.js:210:77)
    at CompatAddons.build (/application/node_modules/@embroider/compat/src/compat-addons.js:131:14)
    at WaitForTrees.build (/application/node_modules/@embroider/core/src/wait-for-trees.js:60:21)
    at TransformNodeWrapper.build (/application/node_modules/broccoli/dist/wrappers/transform-node.js:68:39)
    at /application/node_modules/broccoli/dist/builder.js:185:30
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Builder.build (/application/node_modules/broccoli/dist/builder.js:204:13)
  - code: [undefined]
  - codeFrame: The "path" argument must be of type string. Received undefined
  - errorMessage: The "path" argument must be of type string. Received undefined
        at WaitForTrees (@embroider/compat/addons)
-~- created here: -~-
    at new Plugin (/application/node_modules/@embroider/core/node_modules/broccoli-plugin/dist/index.js:47:36)
    at new WaitForTrees (/application/node_modules/@embroider/core/src/wait-for-trees.js:30:9)
    at CompatAddons.get tree [as tree] (/application/node_modules/@embroider/compat/src/compat-addons.js:56:16)
    at CompatApp.augment (/application/node_modules/@embroider/core/src/build-stage.js:53:64)
    at CompatApp.get tree (/application/node_modules/@embroider/core/src/build-stage.js:25:50)
    at CompatApp.<anonymous> (/application/node_modules/typescript-memoize/dist/memoize-decorator.js:132:52)
    at new PackagerRunner (/application/node_modules/@embroider/core/src/to-broccoli-plugin.js:11:26)
    at Object.defaultPipeline (/application/node_modules/@embroider/compat/src/default-pipeline.js:49:12)
    at module.exports (/application/ember-cli-build.js:111:39)
    at Builder.readBuildFile (/application/node_modules/ember-cli/lib/models/builder.js:49:14)
-~- (end) -~-
  - errorType: Build Error
  - location:
    - column: [undefined]
    - file: [undefined]
    - line: [undefined]
    - treeDir: [undefined]
  - message: The "path" argument must be of type string. Received undefined
        at WaitForTrees (@embroider/compat/addons)
-~- created here: -~-
    at new Plugin (/application/node_modules/@embroider/core/node_modules/broccoli-plugin/dist/index.js:47:36)
    at new WaitForTrees (/application/node_modules/@embroider/core/src/wait-for-trees.js:30:9)
    at CompatAddons.get tree [as tree] (/application/node_modules/@embroider/compat/src/compat-addons.js:56:16)
    at CompatApp.augment (/application/node_modules/@embroider/core/src/build-stage.js:53:64)
    at CompatApp.get tree (/application/node_modules/@embroider/core/src/build-stage.js:25:50)
    at CompatApp.<anonymous> (/application/node_modules/typescript-memoize/dist/memoize-decorator.js:132:52)
    at new PackagerRunner (/application/node_modules/@embroider/core/src/to-broccoli-plugin.js:11:26)
    at Object.defaultPipeline (/application/node_modules/@embroider/compat/src/default-pipeline.js:49:12)
    at module.exports (/application/ember-cli-build.js:111:39)
    at Builder.readBuildFile (/application/node_modules/ember-cli/lib/models/builder.js:49:14)
-~- (end) -~-
  - name: Error
  - nodeAnnotation: @embroider/compat/addons
  - nodeName: WaitForTrees
  - originalErrorMessage: The "path" argument must be of type string. Received undefined
  - stack: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:387:5)
    at validateString (node:internal/validators:162:11)
    at join (node:path:1172:7)
    at CompatAddons.linkNonCopiedDeps (/application/node_modules/@embroider/compat/src/compat-addons.js:210:77)
    at CompatAddons.build (/application/node_modules/@embroider/compat/src/compat-addons.js:131:14)
    at WaitForTrees.build (/application/node_modules/@embroider/core/src/wait-for-trees.js:60:21)
    at TransformNodeWrapper.build (/application/node_modules/broccoli/dist/wrappers/transform-node.js:68:39)
    at /application/node_modules/broccoli/dist/builder.js:185:30
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Builder.build (/application/node_modules/broccoli/dist/builder.js:204:13)

@mikrostew
Copy link
Contributor

@gilest are you using Node 16? I ran into that same error in #902, and fixed it by updating workerpool in the lock file.

@gilest
Copy link

gilest commented Dec 1, 2022

@mikrostew yes I am using node 16 – thanks for pointing that out 😄

Comment on lines +35 to +38
if (!gte('4.0.0')) {
application.inject('adapter', '_ajaxRequest', 'ajax:node');
application.inject('adapter', 'fastboot', 'service:fastboot');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this check is needed, and these lines can just be removed. This would have to be released as a breaking change though.

That way apps using versions of Ember prior to 4.x would be able to use this without the implicit injections, to make the transition to 4.x easier. That's what we're running into where I work - we want to get rid of the deprecations on 3.28 before moving to 4.x.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's also an odd behavior to have a version that both does and doesn't inject based on the Ember version. I agree that removing them and cutting a new major is the way to go

Copy link
Contributor

@mikrostew mikrostew left a comment

Choose a reason for hiding this comment

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

So my suggestion would be to just remove the injections (and compatibility helpers that were added), and cut a new major.

@@ -1,5 +1,6 @@
/* globals najax */
import Ember from 'ember';
import { gte } from 'ember-compatibility-helpers';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import { gte } from 'ember-compatibility-helpers';

Comment on lines +34 to +38

if (!gte('4.0.0')) {
application.inject('adapter', '_ajaxRequest', 'ajax:node');
application.inject('adapter', 'fastboot', 'service:fastboot');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (!gte('4.0.0')) {
application.inject('adapter', '_ajaxRequest', 'ajax:node');
application.inject('adapter', 'fastboot', 'service:fastboot');
}

@@ -39,6 +39,7 @@
"ember-cli-lodash-subset": "^2.0.1",
"ember-cli-preprocess-registry": "^3.3.0",
"ember-cli-version-checker": "^5.1.2",
"ember-compatibility-helpers": "^1.2.6",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"ember-compatibility-helpers": "^1.2.6",

Comment on lines +8333 to +8343
ember-compatibility-helpers@^1.2.6:
version "1.2.6"
resolved "https://registry.yarnpkg.com/ember-compatibility-helpers/-/ember-compatibility-helpers-1.2.6.tgz#603579ab2fb14be567ef944da3fc2d355f779cd8"
integrity sha512-2UBUa5SAuPg8/kRVaiOfTwlXdeVweal1zdNPibwItrhR0IvPrXpaqwJDlEZnWKEoB+h33V0JIfiWleSG6hGkkA==
dependencies:
babel-plugin-debug-macros "^0.2.0"
ember-cli-version-checker "^5.1.1"
find-up "^5.0.0"
fs-extra "^9.1.0"
semver "^5.4.1"

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ember-compatibility-helpers@^1.2.6:
version "1.2.6"
resolved "https://registry.yarnpkg.com/ember-compatibility-helpers/-/ember-compatibility-helpers-1.2.6.tgz#603579ab2fb14be567ef944da3fc2d355f779cd8"
integrity sha512-2UBUa5SAuPg8/kRVaiOfTwlXdeVweal1zdNPibwItrhR0IvPrXpaqwJDlEZnWKEoB+h33V0JIfiWleSG6hGkkA==
dependencies:
babel-plugin-debug-macros "^0.2.0"
ember-cli-version-checker "^5.1.1"
find-up "^5.0.0"
fs-extra "^9.1.0"
semver "^5.4.1"

@ef4
Copy link
Contributor

ef4 commented Dec 12, 2022

Thanks everyone, this work landed in #904.

@ef4 ef4 closed this Dec 12, 2022
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.

Deprecations with ember-4.0.0
6 participants