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

fix: generate unique component id #538

Merged
merged 1 commit into from
Mar 17, 2025

Conversation

underfin
Copy link
Member

@underfin underfin commented Mar 4, 2025

Description

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

The component id using hash for relative path, it could be conflict at module federation. The pr using the absolute path to avoid it.

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Sorry, something went wrong.

Copy link

pkg-pr-new bot commented Mar 4, 2025

Open in Stackblitz

npm i https://pkg.pr.new/@vitejs/plugin-vue@538
npm i https://pkg.pr.new/@vitejs/plugin-vue-jsx@538

commit: acd2814

@@ -49,7 +49,7 @@ export function createDescriptor(
descriptor.id = getHash(normalizedPath + source)
} else if (typeof componentIdGenerator === 'function') {
descriptor.id = componentIdGenerator(
normalizedPath,
normalizePath(path.relative(root, filename)),
Copy link
Member Author

Choose a reason for hiding this comment

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

Here perserve the relative path to avoid break change, if the user using it, it should be make sure the unique compoenent id.

The relate test is playground/vue-custom-id/__tests__/vue-custom-id.spec.ts. it using component id to generate attr <h1 data-v-components-foo="">Foo</h1>'.

Copy link

Choose a reason for hiding this comment

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

This change is breaking my tests, now...

The documentation clearly states that componentIdGenerator='filepath', which I presume is the default, "hash the file path (relative to the project root)" should use the relative path.

Yet the change clearly uses the relative path only in the componentIdGenerator='function' case.

The component ids generated on my machine are thus no longer matching the component ids generated in my CI.

@underfin underfin marked this pull request as draft March 4, 2025 08:21
@underfin underfin marked this pull request as ready for review March 10, 2025 03:15
@edison1105 edison1105 merged commit 2704e85 into vitejs:main Mar 17, 2025
8 checks passed
edison1105 added a commit that referenced this pull request Mar 17, 2025
This reverts commit 2704e85.
project-mirrors-bot-tu bot pushed a commit to project-mirrors/forgejo that referenced this pull request Mar 17, 2025
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#readme) ([source](https://github.com/vitejs/vite-plugin-vue/tree/HEAD/packages/plugin-vue)) | devDependencies | minor | [`5.1.5` -> `5.2.3`](https://renovatebot.com/diffs/npm/@vitejs%2fplugin-vue/5.1.5/5.2.3) |

---

### Release Notes

<details>
<summary>vitejs/vite-plugin-vue (@&#8203;vitejs/plugin-vue)</summary>

### [`v5.2.3`](https://github.com/vitejs/vite-plugin-vue/blob/HEAD/packages/plugin-vue/CHANGELOG.md#small523-2025-03-17-small)

-   Revert "fix: generate unique component id" ([#&#8203;548](vitejs/vite-plugin-vue#548)) ([4bc5517](vitejs/vite-plugin-vue@4bc5517)), closes [#&#8203;548](vitejs/vite-plugin-vue#548)

### [`v5.2.2`](https://github.com/vitejs/vite-plugin-vue/blob/HEAD/packages/plugin-vue/CHANGELOG.md#small522-2025-03-17-small)

-   feat: pass descriptor vapor flag to compileTemplte ([219e007](vitejs/vite-plugin-vue@219e007))
-   feat(css): tree shake scoped styles ([#&#8203;533](vitejs/vite-plugin-vue#533)) ([333094f](vitejs/vite-plugin-vue@333094f)), closes [#&#8203;533](vitejs/vite-plugin-vue#533)
-   fix: generate unique component id ([#&#8203;538](vitejs/vite-plugin-vue#538)) ([2704e85](vitejs/vite-plugin-vue@2704e85)), closes [#&#8203;538](vitejs/vite-plugin-vue#538)
-   fix: properly interpret boolean values in `define` ([#&#8203;545](vitejs/vite-plugin-vue#545)) ([46d3d65](vitejs/vite-plugin-vue@46d3d65)), closes [#&#8203;545](vitejs/vite-plugin-vue#545)
-   fix(deps): update all non-major dependencies ([#&#8203;482](vitejs/vite-plugin-vue#482)) ([cdbae68](vitejs/vite-plugin-vue@cdbae68)), closes [#&#8203;482](vitejs/vite-plugin-vue#482)
-   fix(deps): update all non-major dependencies ([#&#8203;488](vitejs/vite-plugin-vue#488)) ([5d39582](vitejs/vite-plugin-vue@5d39582)), closes [#&#8203;488](vitejs/vite-plugin-vue#488)
-   fix(index): move the if check earlier to avoid creating unnecessary ssr when entering return block ( ([2135c84](vitejs/vite-plugin-vue@2135c84)), closes [#&#8203;523](vitejs/vite-plugin-vue#523)
-   fix(plugin-vue): default value for compile time flags ([#&#8203;495](vitejs/vite-plugin-vue#495)) ([ae9d948](vitejs/vite-plugin-vue@ae9d948)), closes [#&#8203;495](vitejs/vite-plugin-vue#495)
-   fix(plugin-vue): ensure HMR updates styles when SFC is treated as a type dependency ([#&#8203;541](vitejs/vite-plugin-vue#541)) ([4abe3be](vitejs/vite-plugin-vue@4abe3be)), closes [#&#8203;541](vitejs/vite-plugin-vue#541)
-   fix(plugin-vue): resolve sourcemap conflicts in build watch mode with cached modules ([#&#8203;505](vitejs/vite-plugin-vue#505)) ([906cebb](vitejs/vite-plugin-vue@906cebb)), closes [#&#8203;505](vitejs/vite-plugin-vue#505)
-   fix(plugin-vue): support external import URLs for monorepos ([#&#8203;524](vitejs/vite-plugin-vue#524)) ([cdd4922](vitejs/vite-plugin-vue@cdd4922)), closes [#&#8203;524](vitejs/vite-plugin-vue#524)
-   fix(plugin-vue): support vapor template-only component ([#&#8203;529](vitejs/vite-plugin-vue#529)) ([95be153](vitejs/vite-plugin-vue@95be153)), closes [#&#8203;529](vitejs/vite-plugin-vue#529)
-   fix(plugin-vue): suppress warnings for non-recognized pseudo selectors form lightningcss ([#&#8203;521](vitejs/vite-plugin-vue#521)) ([15c0eb0](vitejs/vite-plugin-vue@15c0eb0)), closes [#&#8203;521](vitejs/vite-plugin-vue#521)
-   chore(deps): update dependency rollup to ^4.27.4 ([#&#8203;479](vitejs/vite-plugin-vue#479)) ([428320d](vitejs/vite-plugin-vue@428320d)), closes [#&#8203;479](vitejs/vite-plugin-vue#479)
-   chore(deps): update dependency rollup to ^4.28.1 ([#&#8203;484](vitejs/vite-plugin-vue#484)) ([388403f](vitejs/vite-plugin-vue@388403f)), closes [#&#8203;484](vitejs/vite-plugin-vue#484)
-   chore(deps): update dependency rollup to ^4.29.1 ([#&#8203;493](vitejs/vite-plugin-vue#493)) ([b092bc8](vitejs/vite-plugin-vue@b092bc8)), closes [#&#8203;493](vitejs/vite-plugin-vue#493)
-   chore(deps): update upstream ([#&#8203;503](vitejs/vite-plugin-vue#503)) ([8c12b9f](vitejs/vite-plugin-vue@8c12b9f)), closes [#&#8203;503](vitejs/vite-plugin-vue#503)
-   chore(deps): update upstream ([#&#8203;511](vitejs/vite-plugin-vue#511)) ([d057351](vitejs/vite-plugin-vue@d057351)), closes [#&#8203;511](vitejs/vite-plugin-vue#511)
-   chore(deps): update upstream ([#&#8203;526](vitejs/vite-plugin-vue#526)) ([59946d3](vitejs/vite-plugin-vue@59946d3)), closes [#&#8203;526](vitejs/vite-plugin-vue#526)
-   chore(plugin-vue): simplify `resolved` declaration ([7288a59](vitejs/vite-plugin-vue@7288a59))

### [`v5.2.1`](https://github.com/vitejs/vite-plugin-vue/blob/HEAD/packages/plugin-vue/CHANGELOG.md#small521-2024-11-26-small)

-   chore: add vite 6 peer dep ([#&#8203;481](vitejs/vite-plugin-vue#481)) ([4288652](vitejs/vite-plugin-vue@4288652)), closes [#&#8203;481](vitejs/vite-plugin-vue#481)
-   chore: fix lint ([378aea3](vitejs/vite-plugin-vue@378aea3))
-   chore(deps): update dependency rollup to ^4.27.2 ([#&#8203;476](vitejs/vite-plugin-vue#476)) ([b2df95e](vitejs/vite-plugin-vue@b2df95e)), closes [#&#8203;476](vitejs/vite-plugin-vue#476)

### [`v5.2.0`](https://github.com/vitejs/vite-plugin-vue/blob/HEAD/packages/plugin-vue/CHANGELOG.md#520-2024-11-13)

-   feat: add a feature option to support custom component id generator ([#&#8203;461](vitejs/vite-plugin-vue#461)) ([7a1fc4c](vitejs/vite-plugin-vue@7a1fc4c)), closes [#&#8203;461](vitejs/vite-plugin-vue#461)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "* 0-3 * * *" (UTC), Automerge - "* 0-3 * * *" (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [x] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xOTUuMSIsInVwZGF0ZWRJblZlciI6IjM5LjIwNS4xIiwidGFyZ2V0QnJhbmNoIjoiZm9yZ2VqbyIsImxhYmVscyI6WyJkZXBlbmRlbmN5LXVwZ3JhZGUiLCJ0ZXN0L25vdC1uZWVkZWQiXX0=-->

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7248
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
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.

None yet

4 participants