-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1167 from NullVoxPopuli/centralize-compat-things
Extract ember-compat stuff to a central location
- Loading branch information
Showing
3 changed files
with
26 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { dependencySatisfies, importSync, macroCondition } from '@embroider/macros'; | ||
|
||
import type Owner from '@ember/owner'; | ||
|
||
interface CompatOwner { | ||
getOwner: (context: unknown) => Owner | undefined; | ||
setOwner: (context: unknown, owner: Owner) => void; | ||
} | ||
|
||
export const compatOwner = {} as CompatOwner; | ||
|
||
if (macroCondition(dependencySatisfies('ember-source', '>=4.12.0'))) { | ||
// In no version of ember where `@ember/owner` tried to be imported did it exist | ||
// if (macroCondition(false)) { | ||
// Using 'any' here because importSync can't lookup types correctly | ||
compatOwner.getOwner = (importSync('@ember/owner') as any).getOwner; | ||
compatOwner.setOwner = (importSync('@ember/owner') as any).setOwner; | ||
} else { | ||
// Using 'any' here because importSync can't lookup types correctly | ||
compatOwner.getOwner = (importSync('@ember/application') as any).getOwner; | ||
compatOwner.setOwner = (importSync('@ember/application') as any).setOwner; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters