Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure addon app trees are merged in the correct order #1145

Merged
merged 3 commits into from Feb 28, 2022

Conversation

eoneill
Copy link
Contributor

@eoneill eoneill commented Feb 26, 2022

This resolves a compatibility issue in which the order that addon.app-js trees are merged is not consistent with classic builds. The fix here is to sort the addons by the order-index (if present).

I have yet to be able to reproduce a test case of the issue, but can confirm this resolves the issue discovered in our app.

@ef4
Copy link
Contributor

ef4 commented Feb 27, 2022

Nice.

This fix might want to move to a slightly different place because there's already code that was attempting to do this correctly:

// recurse to find all active addons that don't cross an engine boundary.
// Inner engines themselves will be returned, but not those engines' children.
// The output set's insertion order is the proper ember-cli compatible
// ordering of the addons.
private findActiveAddons(pkg: Package, engine: EngineSummary): void {
for (let child of this.adapter.activeAddonChildren(pkg)) {
if (!child.isEngine()) {
this.findActiveAddons(child, engine);
}
engine.addons.add(child);
}
}

activeAddonChildren(pkg: Package = this.appPackage): AddonPackage[] {
let result = (pkg.dependencies.filter(this.isActiveAddon) as AddonPackage[]).filter(
// When looking for child addons, we want to ignore 'peerDependencies' of
// a given package, to align with how ember-cli resolves addons. So here
// we only include dependencies that definitely appear in one of the other
// sections.
addon => pkg.packageJSON.dependencies?.[addon.name] || pkg.packageJSON.devDependencies?.[addon.name]
);
if (pkg === this.appPackage) {
let extras = [this.synthVendor, this.synthStyles].filter(this.isActiveAddon) as AddonPackage[];
result = [...result, ...extras];
}
return result.sort(this.orderAddons);
}

@ef4 ef4 merged commit 6758791 into embroider-build:main Feb 28, 2022
@rwjblue rwjblue added the bug Something isn't working label Mar 1, 2022
@rwjblue rwjblue changed the title ensure addon app-js trees are merged in the correct order Ensure addon app trees are merged in the correct order Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants