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

Replace require with @embroider/macros fixing embroider support #741

Merged
merged 1 commit into from
Nov 8, 2023
Merged
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
17 changes: 9 additions & 8 deletions addon/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import { isHTMLSafe } from '@ember/template';
import EmberObject from '@ember/object';
import { typeOf } from '@ember/utils';
import { A as emberArray, isArray } from '@ember/array';
import require from 'require';

function requireModule(module, exportName = 'default') {
if (require.has(module)) {
return require(module)[exportName];
}
import {
macroCondition,
dependencySatisfies,
importSync,
} from '@embroider/macros';

let DS;
if (macroCondition(dependencySatisfies('ember-data', '*'))) {
DS = importSync('ember-data').default;
}

const DS = requireModule('ember-data');

export { getDependentKeys, isDescriptor } from '../-private/ember-internals';

export function unwrapString(s) {
Expand Down
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"test:ember-compatibility": "ember try:each"
},
"dependencies": {
"@embroider/macros": "^1.13.2",
"ember-cli-babel": "^7.26.11",
"ember-validators": "^4.1.1"
},
Expand Down Expand Up @@ -110,6 +111,14 @@
"peerDependencies": {
"ember-source": "^4.0.0"
},
"peerDependencies": {
"ember-data": "*"
},
"peerDependenciesMeta": {
"ember-data": {
"optional": true
}
},
"engines": {
"node": "14.* || 16.* || >= 18"
},
Expand Down
34 changes: 34 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,20 @@
resolve "^1.20.0"
semver "^7.3.2"

"@embroider/macros@^1.13.2":
version "1.13.2"
resolved "https://registry.yarnpkg.com/@embroider/macros/-/macros-1.13.2.tgz#07dda11313a2539f403404881b729e622a80ca17"
integrity sha512-AUgJ71xG8kjuTx8XB1AQNBiebJuXRfhcHr318dCwnQz9VRXdYSnEEqf38XRvGYIoCvIyn/3c72LrSwzaJqknOA==
dependencies:
"@embroider/shared-internals" "2.5.0"
assert-never "^1.2.1"
babel-import-util "^2.0.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@^2.0.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@embroider/shared-internals/-/shared-internals-2.1.0.tgz#4da79fe8b26e4b94819b8313c51b5b24a68c617b"
Expand All @@ -1524,6 +1538,21 @@
semver "^7.3.5"
typescript-memoize "^1.0.1"

"@embroider/[email protected]":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@embroider/shared-internals/-/shared-internals-2.5.0.tgz#4a0b5127c589718fae60fc22f81374ed558b944a"
integrity sha512-7qzrb7GVIyNqeY0umxoeIvjDC+ay1b+wb2yCVuYTUYrFfLAkLEy9FNI3iWCi3RdQ9OFjgcAxAnwsAiPIMZZ3pQ==
dependencies:
babel-import-util "^2.0.0"
debug "^4.3.2"
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/test-setup@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@embroider/test-setup/-/test-setup-2.1.1.tgz#1cf613f479ed120fdc5d71cb834c8fb71514cce1"
Expand Down Expand Up @@ -2913,6 +2942,11 @@ babel-import-util@^1.1.0, babel-import-util@^1.2.2, babel-import-util@^1.3.0:
resolved "https://registry.yarnpkg.com/babel-import-util/-/babel-import-util-1.3.0.tgz#dc9251ea39a7747bd586c1c13b8d785a42797f8e"
integrity sha512-PPzUT17eAI18zn6ek1R3sB4Krc/MbnmT1MkZQFmyhjoaEGBVwNABhfVU9+EKcDSKrrOm9OIpGhjxukx1GCiy1g==

babel-import-util@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/babel-import-util/-/babel-import-util-2.0.1.tgz#263a2963ee9208428c04f05326c6ea32b2206ac6"
integrity sha512-N1ZfNprtf/37x0R05J0QCW/9pCAcuI+bjZIK9tlu0JEkwEST7ssdD++gxHRbD58AiG5QE5OuNYhRoEFsc1wESw==

babel-loader@^8.0.6:
version "8.2.5"
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.5.tgz#d45f585e654d5a5d90f5350a779d7647c5ed512e"
Expand Down
Loading