Skip to content

Commit

Permalink
remove OwningAddon custom package subclass
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Jun 8, 2023
1 parent 3ae3a06 commit ec433a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
8 changes: 3 additions & 5 deletions packages/compat/src/compat-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { WriteV1AppBoot, ReadV1AppBoot } from './v1-appboot';
import { AddonMeta, EmberAppInstance, OutputFileToInputFileMap, PackageInfo, AddonInstance } from '@embroider/core';
import { writeJSONSync, ensureDirSync, copySync, readdirSync, pathExistsSync, existsSync } from 'fs-extra';
import AddToTree from './add-to-tree';
import DummyPackage, { OwningAddon } from './dummy-package';
import DummyPackage from './dummy-package';
import { TransformOptions } from '@babel/core';
import { isEmbroiderMacrosPlugin, MacrosConfig } from '@embroider/macros/src/node';
import resolvePackagePath from 'resolve-package-path';
Expand Down Expand Up @@ -793,10 +793,8 @@ export default class CompatApp {
let movablePackageCache = new MovablePackageCache(this.macrosConfig, this.root);

if (this.isDummy) {
let owningAddon = new OwningAddon(this.legacyEmberAppInstance.project.root, movablePackageCache);
movablePackageCache.seed(owningAddon);
movablePackageCache.seed(new DummyPackage(this.root, owningAddon, movablePackageCache));
this.macrosConfig.enablePackageDevelopment(owningAddon.root);
movablePackageCache.seed(new DummyPackage(this.root, this.legacyEmberAppInstance.project.root, movablePackageCache));
this.macrosConfig.enablePackageDevelopment(this.legacyEmberAppInstance.project.root);
}
return movablePackageCache;
}
Expand Down
19 changes: 4 additions & 15 deletions packages/compat/src/dummy-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import cloneDeep from 'lodash/cloneDeep';
// A specialized Package that represents a Dummy App (the app that comes along
// with an addon for purposes of testing that addon).
export default class DummyPackage extends Package {
constructor(root: string, private owningAddon: Package, packageCache: PackageCache) {
constructor(root: string, private owningAddonRoot: string, packageCache: PackageCache) {
super(root, packageCache, true);
}

@Memoize()
protected get internalPackageJSON() {
let pkg = cloneDeep(this.owningAddon.packageJSON);
let pkg = cloneDeep(this.packageCache.get(this.owningAddonRoot).packageJSON);
pkg.name = 'dummy';
return pkg;
}
Expand All @@ -22,19 +22,8 @@ export default class DummyPackage extends Package {
if (!deps) {
deps = new Map();
}
deps.set(this.owningAddon.name, this.owningAddon);
const owningAddon = this.packageCache.get(this.owningAddonRoot);
deps.set(owningAddon.name, owningAddon);
return deps;
}
}

// A specialized Package that represents an Addon that owns the current Dummy
// App. It's special because it always supports rebuilds.
export class OwningAddon extends Package {
constructor(root: string, packageCache: PackageCache) {
super(root, packageCache, false);
}

get mayRebuild(): boolean {
return true;
}
}

0 comments on commit ec433a3

Please sign in to comment.