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

Sort addon css by package name #1866

Draft
wants to merge 3 commits into
base: stable
Choose a base branch
from

Conversation

raycohen
Copy link
Contributor

@raycohen raycohen commented Apr 4, 2024

Fixes #1862

While broccoli-concat doesn't guarantee order, the effective order of addon css in (most?) classic builds seems to be alphabetical by package name.

Also, the order of app.import'd styles was being reversed from what the classic build had, in addition to not coming before addon css.

Updates:

  • Targets stable
  • Added tests
  • Simpler logic change, only impacts implicit-styles

@raycohen raycohen marked this pull request as draft April 4, 2024 21:40
@raycohen raycohen changed the title Sort addon css by package name WIP Sort addon css by package name Apr 4, 2024
ef4
ef4 previously approved these changes Apr 5, 2024
Copy link
Contributor

@ef4 ef4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

We may want to retarget it against the stable branch so it's easier to release sooner. I think it will apply cleanly there.

@raycohen raycohen changed the base branch from main to stable April 5, 2024 18:32
@raycohen raycohen changed the base branch from stable to main April 5, 2024 18:38
@raycohen
Copy link
Contributor Author

raycohen commented Apr 5, 2024

stable and main differ slightly inside impliedAddonAssets

}
} else {
result.push(resolve.sync(mod, options));
}
}
if (styles.length) {
result = [...styles, ...result];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was unshifting the group of styles from each package to the overall list, which reverses the order and we no longer want. then in implicitScriptsAsset the entire list was getting (re-)reversed. We don't need that reverse either now.

@BlueCutOfficial
Copy link
Collaborator

BlueCutOfficial commented Apr 9, 2024

impliedAddonAssets code is reused to replace the assets generated by compat-app-builder.ts with virtual contents. If this PR is merged we probably want to double-check #1805 and #1811 and reintegrate the changes in the new virtual-content generators.

@mansona
Copy link
Member

mansona commented Apr 10, 2024

Just a quick note on how to make sure this continues to work for the upcoming major release: @ef4 is correct that you should target stable with a change like this so that it could be released sooner than the next major, but we can't ensure that this is going to keep working unless we make sure to add a test that verifies the output is in the correct order. If this gets merged to stable and we then forward-port the test to the main branch we can ensure that the sort ordering is still correct even though the implementation is completely different 👍

@raycohen
Copy link
Contributor Author

I will look into testing this. Right now we're getting by with patch-package (with a slightly different diff) but we'll want to get off that eventually

@mansona mansona dismissed ef4’s stale review April 29, 2024 14:29

Needs changes: target main and add a test

@raycohen raycohen force-pushed the sort-addon-css-alphabetically branch from e96ddd1 to fc820d1 Compare November 25, 2024 22:22
@raycohen raycohen changed the base branch from main to stable November 25, 2024 22:27
@raycohen raycohen marked this pull request as ready for review November 25, 2024 22:34
project.addDependency(addonA);
project.addDependency(addonB);
addonA.addDependency(addonC);
project.addDependency(addonD);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test without the logic change gave c->a->b->d ordering

@raycohen raycohen changed the title WIP Sort addon css by package name Sort addon css by package name Nov 26, 2024
@raycohen raycohen closed this Nov 26, 2024
@raycohen raycohen reopened this Nov 26, 2024
@raycohen raycohen marked this pull request as draft November 26, 2024 03:15

module.exports = function (defaults) {
let app = new EmberApp(defaults, {});
app.import('node_modules/third-party/third-party.css');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add more of these so we get coverage on the order between app.import calls as well

@void-mAlex
Copy link
Collaborator

isn't order of assets supposed to be dictated by addon order before/after options that the legacy pipeline controls with alphabetical being the starting point only?

@raycohen
Copy link
Contributor Author

raycohen commented Dec 9, 2024

I'm not sure what the CI failures are here...

@raycohen
Copy link
Contributor Author

raycohen commented Jan 6, 2025

@void-mAlex

isn't order of assets supposed to be dictated by addon order before/after options that the legacy pipeline controls with alphabetical being the starting point only?

In a classic build, I believe the answer is no. The vendor css concatenation doesn't consider any ordering info for inputFiles other than the merged addon-tree-output file system structure. From what I can tell broccoli-concat just takes things in the order the fs methods give it.

Still not sure why this PR is red but I would like to get it landed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to control order of addon implicit styles?
5 participants