Skip to content

Commit

Permalink
Exclude peerDependencies from Engines 'app' directory
Browse files Browse the repository at this point in the history
  • Loading branch information
charlespierce committed Mar 18, 2021
1 parent 75344d8 commit 3dc22c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/compat/src/compat-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class CompatAppAdapter implements AppAdapter<TreeNames> {

@Memoize()
activeAddonChildren(pkg: Package = this.appPackage): AddonPackage[] {
let result = pkg.dependencies.filter(this.isActiveAddon) as AddonPackage[];
let result = pkg.addonDependencies.filter(this.isActiveAddon) as AddonPackage[];
if (pkg === this.appPackage) {
let extras = [this.synthVendor, this.synthStyles].filter(this.isActiveAddon) as AddonPackage[];
result = [...result, ...extras];
Expand Down
3 changes: 3 additions & 0 deletions packages/compat/src/moved-package-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ function packageProxy(pkg: Package, getMovedPackage: (pkg: Package) => Package)
if (prop === 'dependencies') {
return pkg.dependencies.map(getMovedPackage);
}
if (prop === 'addonDependencies') {
return pkg.addonDependencies.map(getMovedPackage);
}
if (prop === 'nonResolvableDeps') {
if (!pkg.nonResolvableDeps) {
return pkg.nonResolvableDeps;
Expand Down
15 changes: 13 additions & 2 deletions packages/core/src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,22 @@ export default class Package {

@Memoize()
get dependencies(): Package[] {
let names = flatMap(this.dependencyKeys, key => Object.keys(this.packageJSON[key] || {}));
return this.loadDependencies(this.dependencyKeys);
}

@Memoize()
get addonDependencies(): Package[] {
// When looking for child addons, we want to ignore 'peerDependencies' of a given package, to
// align with how ember-cli resolves addons
return this.loadDependencies(this.dependencyKeys.filter(key => key !== 'peerDependencies'));
}

loadDependencies(keys: ('dependencies' | 'devDependencies' | 'peerDependencies')[]): Package[] {
const names = flatMap(keys, key => Object.keys(this.packageJSON[key] || {}));
return names
.map(name => {
if (this.nonResolvableDeps) {
let dep = this.nonResolvableDeps.get(name);
const dep = this.nonResolvableDeps.get(name);
if (dep) {
return dep;
}
Expand Down

0 comments on commit 3dc22c7

Please sign in to comment.