-
Notifications
You must be signed in to change notification settings - Fork 143
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 #732 from embroider-build/v2-shim
v2 addon shim
- Loading branch information
Showing
20 changed files
with
377 additions
and
35 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import type { Node } from 'broccoli-node-api'; | ||
export interface Project { | ||
targets: unknown; | ||
ui: { | ||
write(...args: any[]): void; | ||
}; | ||
pkg: { name: string; version: string }; | ||
root: string; | ||
addons: AddonInstance[]; | ||
name(): string; | ||
} | ||
|
||
export interface AppInstance { | ||
env: 'development' | 'test' | 'production'; | ||
project: Project; | ||
options: any; | ||
addonPostprocessTree: (which: string, tree: Node) => Node; | ||
} | ||
|
||
interface BaseAddonInstance { | ||
project: Project; | ||
pkg: { name: string; version: string }; | ||
root: string; | ||
options: any; | ||
addons: AddonInstance[]; | ||
name: string; | ||
_super: any; | ||
treeGenerator(path: string): Node; | ||
_findHost(): AppInstance; | ||
} | ||
|
||
export interface DeepAddonInstance extends BaseAddonInstance { | ||
// this is how it looks when an addon is beneath another addon | ||
parent: AddonInstance; | ||
} | ||
|
||
export interface ShallowAddonInstance extends BaseAddonInstance { | ||
// this is how it looks when an addon is directly beneath the app | ||
parent: Project; | ||
app: AppInstance; | ||
} | ||
|
||
export type AddonInstance = DeepAddonInstance | ShallowAddonInstance; | ||
|
||
export function isDeepAddonInstance(addon: AddonInstance): addon is DeepAddonInstance { | ||
return addon.parent !== addon.project; | ||
} | ||
|
||
export function findTopmostAddon(addon: AddonInstance): ShallowAddonInstance { | ||
if (isDeepAddonInstance(addon)) { | ||
return findTopmostAddon(addon.parent); | ||
} else { | ||
return addon; | ||
} | ||
} |
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,27 @@ | ||
// I'm doing this as a json import because even though that's not standard JS, | ||
// it's relaively easy to consume into builds for the web. As opposed to doing | ||
// something like fs.readFile, which is harder. | ||
// | ||
// @ts-ignore | ||
import mappings from 'ember-rfc176-data/mappings.json'; | ||
|
||
// these are packages that available to import in standard ember code that don't | ||
// exist as real packages. If a build system encounters them in stage 3, it | ||
// should convert them to runtime AMD require. | ||
// | ||
// Some of them (like @embroider/macros) won't ever be seen in stage 3, because | ||
// earlier plugins should take care of them. | ||
// | ||
// In embroider builds using ember-source >= 3.28, you won't see *any* of these | ||
// in stage3 because ember-source uses the standard rename-modules feature to | ||
// map them into real modules within ember-source. | ||
export const emberVirtualPackages = new Set<string>(mappings.map((m: any) => m.module)); | ||
|
||
// these are *real* packages that every ember addon is allow to resolve *as if | ||
// they were peerDepenedencies, because the host application promises to have | ||
// these packages. In principle, we could force every addon to declare these as | ||
// real peerDeps all the way down the dependency graph, but in practice that | ||
// makes the migration from v1 to v2 addons more painful than necessary, because | ||
// a v1 addon in between the app and a v2 addon might not declare the peerDep, | ||
// breaking the deeper v2 addon. | ||
export const emberVirtualPeerDeps = new Set<string>(['@glimmer/component']); |
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
File renamed without changes.
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
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.