Skip to content

Commit

Permalink
Always load ember-testing package eagerly
Browse files Browse the repository at this point in the history
In ember-source 5.6 (now in beta), we refactored the way Ember and its test-only pieces find each other to no longer be dependent on the AMD loader.

But this mean it's no longer sufficient to `define()` *and not evaluate* the `ember-testing` package in order to install the test support. It must actually get evaluted first.

Note that this bug does not manifest on embroider `main`, because there implicit-test-modules are eagerly evaluated. This is only a problem on stable, when using `staticEmberSource: true`.
  • Loading branch information
ef4 committed Dec 13, 2023
1 parent 496ab87 commit e5cb780
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/compat/src/compat-adapters/ember-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,16 @@ export default class extends V1Addon {
meta['implicit-modules'] = [];
}
meta['implicit-modules'].push('./ember/index.js');

if (!meta['implicit-test-modules']) {
meta['implicit-test-modules'] = [];
// before 5.6, Ember uses the AMD loader to decide if it's test-only parts
// are present, so we must ensure they're registered. After that it's
// enough to evaluate ember-testing, which @embroider/core is hard-coded
// to do in the backward-compatible tests bundle.
if (!satisfies(this.packageJSON.version, '>= 5.6.0-alpha.0', { includePrerelease: true })) {
if (!meta['implicit-test-modules']) {
meta['implicit-test-modules'] = [];
}
meta['implicit-test-modules'].push('./ember-testing/index.js');
}
meta['implicit-test-modules'].push('./ember-testing/index.js');
}
return meta;
}
Expand Down
1 change: 1 addition & 0 deletions packages/compat/src/compat-app-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,7 @@ export class CompatAppBuilder {
// packagers to understand. It's better to express it here as a direct
// module dependency.
let eagerModules: string[] = [
'ember-testing',
explicitRelative(dirname(myName), this.topAppJSAsset(appFiles, prepared).relativePath),
];

Expand Down

0 comments on commit e5cb780

Please sign in to comment.