Skip to content

Commit

Permalink
Merge pull request #1428 from embroider-build/test-waiters-compat
Browse files Browse the repository at this point in the history
Add compat adapter for @ember/test-waiters
  • Loading branch information
ef4 authored May 16, 2023
2 parents 16dc72c + d2cc83e commit c58f146
Show file tree
Hide file tree
Showing 4 changed files with 380 additions and 599 deletions.
24 changes: 24 additions & 0 deletions packages/compat/src/compat-adapters/@ember/test-waiters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import V1Addon from '../../v1-addon';
import { satisfies } from 'semver';

export default class extends V1Addon {
// our heuristic for detecting tree suppression can't deal with the way
// test-waiters patches treeFor on other copies of its addon instances all
// over the place. It causes us to falsely detect that it's trying to suppress
// all tree output, reducing in empty copies.
protected suppressesTree(_name: string): boolean {
return false;
}

reduceInstances(instances: V1Addon[]): V1Addon[] {
if (!satisfies(this.packageJSON.version, '>=3.0.2')) {
throw new Error(
`@ember/test-waiters cannot work safely under embroider before version 3.0.2 due to https://github.com/emberjs/ember-test-waiters/pull/388. You have a copy at version ${this.packageJSON.version}.`
);
}

// we know test waiters tries to dedup itself, so there's no point in building
// and smooshing many copies.
return [instances[0]];
}
}
2 changes: 1 addition & 1 deletion packages/compat/src/v1-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ export default class V1Addon {
// But there is a very common use case that we *can* handle opportunisticaly,
// which is a treeFor() that's used purely to guard whether `_super` will be
// called or not.
private suppressesTree(name: string): boolean {
protected suppressesTree(name: string): boolean {
if (!this.customizes('treeFor')) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"prepack": "rollup --config"
},
"dependencies": {
"@ember/test-waiters": "^3.0.0",
"@ember/test-waiters": "^3.0.2",
"@embroider/addon-shim": "workspace:^"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit c58f146

Please sign in to comment.