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

feat: import @ember/polyfills assign conditionally #2538

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/ember-simple-auth/addon/utils/assign.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import { assign } from '@ember/polyfills';
import { importSync } from '@embroider/macros';

let assign;

try {
assign = importSync('@ember/polyfills').assign;
} catch (error) {
// Couldn't import @ember/polyfills
// Doesn't exist in v5
}
Comment on lines +5 to +10
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It wraps importSync in try catch becasue dependencySatisfies macro can't reliably work if the dependency isn't a direct dependency or a peer dependency.
Seems like ember-source matching in addons misbehaves especially

Copy link
Contributor

Choose a reason for hiding this comment

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

ember-source needs to be a peerDependency of this addon, I think. That should make it work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the pointer 👍 , I also realized this later on but I did get some breakage under fastboot while working on mainmatter/ember-cookies#782


export default Object.assign || assign;
3 changes: 3 additions & 0 deletions packages/ember-simple-auth/config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ module.exports = function() {
'ember-qunit': '^5.1.4',
qunit: '^2.17.2',
'ember-cli-app-version': '~5.0.0',
'ember-resolver': '10.0.0',
'@ember/string': '3.0.1',
torii: null,
},
},
},
Expand Down
7 changes: 4 additions & 3 deletions packages/ember-simple-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@
"ember-cli-babel": "^7.20.5",
"ember-cli-is-package-missing": "^1.0.0",
"ember-cookies": "^0.5.0",
"silent-error": "^1.0.0"
"silent-error": "^1.0.0",
"@embroider/macros": "^1.10.0"
},
"devDependencies": {
"@babel/eslint-parser": "^7.11.0",
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "~2.7.0",
"@embroider/test-setup": "^2.0.0",
"@glimmer/component": "^1.0.0",
"@glimmer/tracking": "^1.0.0",
"@babel/eslint-parser": "^7.11.0",
"broccoli-asset-rev": "^3.0.0",
"ember-auto-import": "^2.4.2",
"ember-cli": "~4.3.0",
Expand All @@ -45,7 +46,6 @@
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-htmlbars": "^6.0.0",
"ember-cli-inject-live-reload": "^2.0.1",
"pretender": "3.4.7",
"ember-cli-sri": "^2.1.1",
"ember-cli-terser": "4.0.2",
"ember-cli-yuidoc": "^0.9.1",
Expand All @@ -70,6 +70,7 @@
"marked": "^4.0.0",
"mocha": "^10.0.0",
"npm-run-all": "^4.1.5",
"pretender": "3.4.7",
"qunit": "^2.17.2",
"qunit-dom": "^2.0.0",
"sinon": "15.0.0",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@
ember-cli-version-checker "^5.1.2"
semver "^7.3.5"

"@embroider/macros@^1.0.0", "@embroider/macros@^1.3.0":
"@embroider/macros@^1.0.0", "@embroider/macros@^1.10.0", "@embroider/macros@^1.3.0":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@embroider/macros/-/macros-1.10.0.tgz#af3844d5db48f001b85cfb096c76727c72ad6c1e"
integrity sha512-LMbfQGk/a+f6xtvAv5fq/wf2LRxETnbgSCLUf/z6ebzmuskOUxrke+uP55chF/loWrARi9g6erFQ7RDOUoBMSg==
Expand Down