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 Apr 20, 2021
1 parent 8b2c20d commit e89708f
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 @@ -176,7 +176,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/shared-internals/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 e89708f

Please sign in to comment.