Skip to content

Commit

Permalink
feat: import @ember/polyfills assign conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
BobrImperator committed Apr 14, 2023
1 parent fd94e0d commit 62d5d49
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/ember-cookies/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"test": "echo 'A v2 addon does not have tests, run tests in test-app'"
},
"dependencies": {
"@embroider/addon-shim": "^1.7.1"
"@embroider/addon-shim": "^1.7.1",
"@embroider/macros": "^1.10.0"
},
"devDependencies": {
"@babel/core": "^7.18.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-cookies/src/services/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { get } from '@ember/object';
import { assert } from '@ember/debug';
import { getOwner } from '@ember/application';
import Service from '@ember/service';
import { assign as emberAssign } from '@ember/polyfills';
import { serializeCookie } from '../utils/serialize-cookie';
import emberAssign from 'ember-cookies/utils/assign';
const { keys } = Object;
const assign = Object.assign || emberAssign;
const DEFAULTS = { raw: false };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from '@ember/debug';
import { assign as emberAssign } from '@ember/polyfills';
import emberAssign from 'ember-cookies/utils/assign';
import { isEmpty } from '@ember/utils';
import { serializeCookie } from '../utils/serialize-cookie';

Expand Down
12 changes: 12 additions & 0 deletions packages/ember-cookies/src/utils/assign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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.
// This is needed for Ember v5 support where the polyfill is already removed.
}

export default Object.assign || assign;
28 changes: 28 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,20 @@
resolve "^1.20.0"
semver "^7.3.2"

"@embroider/macros@^1.10.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==
dependencies:
"@embroider/shared-internals" "2.0.0"
assert-never "^1.2.1"
babel-import-util "^1.1.0"
ember-cli-babel "^7.26.6"
find-up "^5.0.0"
lodash "^4.17.21"
resolve "^1.20.0"
semver "^7.3.2"

"@embroider/[email protected]", "@embroider/shared-internals@^1.0.0", "@embroider/shared-internals@^1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@embroider/shared-internals/-/shared-internals-1.8.3.tgz#52d868dc80016e9fe983552c0e516f437bf9b9f9"
Expand All @@ -1137,6 +1151,20 @@
semver "^7.3.5"
typescript-memoize "^1.0.1"

"@embroider/[email protected]":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@embroider/shared-internals/-/shared-internals-2.0.0.tgz#d8205ec6944362aeecfbb51143db352430ced316"
integrity sha512-qZ2/xky9mWm5YC6noOa6AiAwgISEQ78YTZNv4SNu2PFgEK/H+Ha/3ddngzGSsnXkVnIHZyxIBzhxETonQYHY9g==
dependencies:
babel-import-util "^1.1.0"
ember-rfc176-data "^0.3.17"
fs-extra "^9.1.0"
js-string-escape "^1.0.1"
lodash "^4.17.21"
resolve-package-path "^4.0.1"
semver "^7.3.5"
typescript-memoize "^1.0.1"

"@embroider/[email protected]":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@embroider/test-setup/-/test-setup-1.8.3.tgz#445b9fe5a363ce50367ac2114750597f98d7806d"
Expand Down

0 comments on commit 62d5d49

Please sign in to comment.