Skip to content

fix: return client bundle collections in a stable order - #583

Open
lafllamme wants to merge 1 commit into
nuxt:mainfrom
lafllamme:fix/stable-client-collection-order
Open

lafllamme wants to merge 1 commit into
nuxt:mainfrom
lafllamme:fix/stable-client-collection-order

Conversation

@lafllamme

Copy link
Copy Markdown
Contributor

Resolves #582

Description

Collections in the client bundle can end up in a different order depending
on when they finish loading. This can change the bundle's chunk hash between
builds even when the icons haven't changed.

Sort collections by prefix before returning them. The comparison doesn't
depend on the build machine's locale.

This one is literally a one-line fix 😄

Tests

Added a regression test that resolves the same collections in different
input orders and checks that the result is identical. It fails before the
fix and passes after it.

  • All 135 unit tests pass.
  • Lint passes for the changed files.

@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/icon@583

commit: b2d657c

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

resolveBundleIcons now sorts returned collections by prefix in ascending lexicographical order. A new test checks that reversing the requested icon order produces the same collection order and data.

Estimated code review effort: 2 (Simple) | ~8 minutes

Severity of issue fixed: Medium

Merge Risk: Minimal · up to b2d65

This change makes client bundle collection order deterministic, so identical icons should produce stable chunk hashes. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: client bundle collections are now returned in a stable order. The raw summary confirms that resolveBundleIcons now sorts returned collections by prefix. The title is …
Description check Passed The description explains the nondeterministic collection order, the one-line sort-by-prefix fix, the locale-independent comparison, and the regression test. It relates directly to the changeset.
Linked Issues check Passed Issue #582 requires that collections returned by resolveBundleIcons have a stable order, sorted by prefix with a locale-independent comparison. At the reviewed head, src/core/bundle.ts returns `[.…
Out of Scope Changes check Passed The whole-PR diff against the merge base 28c9943 changes two files only. src/core/bundle.ts adds a one-line sort to the return value of resolveBundleIcons, which is the change requested by #582.…
Full details: Title check

Explanation

The title states the main change: client bundle collections are now returned in a stable order. The raw summary confirms that resolveBundleIcons now sorts returned collections by prefix. The title is concise and specific, and it matches the linked objectives.

Full details: Linked Issues check

Explanation

Issue #582 requires that collections returned by resolveBundleIcons have a stable order, sorted by prefix with a locale-independent comparison. At the reviewed head, src/core/bundle.ts returns [...collections.values()].sort((a, b) => a.prefix < b.prefix ? -1 : a.prefix > b.prefix ? 1 : 0). This uses code-point ordering, not localeCompare(), so it does not depend on the build machine's locale. Because src/context.ts and src/vite.ts both call this function, both the module client bundle and the standalone Vite plugin receive the stable order. The new test in test/bundle.test.ts resolves the same collections in two request orders and checks that the prefixes are ['alpha', 'zeta'] and that both results are equal. This covers the automated test requirement. The issue's exact test uses a different name and fixture, but it checks the same behaviour. No unmet coding requirement is found in the diff.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base 28c9943 changes two files only. src/core/bundle.ts adds a one-line sort to the return value of resolveBundleIcons, which is the change requested by #582. test/bundle.test.ts adds one regression test for the same function and ordering behaviour. Neither change falls outside the scope of #582. The icon-name sort from #446 is not changed, which matches the issue scope.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 68b2c7a3-d7c9-4685-a98c-a74f15189e8f
Commits

Reviewing files that changed from the base of the PR and between 28c9943 and b2d657c.

Files selected for processing: 2

  • src/core/bundle.ts
  • test/bundle.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client bundle lists collections in load-completion order, so identical builds get different chunk hashes

1 participant