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

feat: add a feature option to support custom component id generator #461

Merged
merged 5 commits into from
Nov 13, 2024

Conversation

Jinjiang
Copy link
Contributor

@Jinjiang Jinjiang commented Oct 21, 2024

Description

To help developers customize the way it generates component id for particular cases.

Additional context

Added this option into features field:

/**
 * Customize the component ID generation strategy.
 * - `'filepath'`: hash the file path (relative to the project root)
 * - `'filepath-source'`: hash the file path and the source code
 * - `function`: custom function that takes the file path, source code,
 *   whether in production mode, and the default hash function as arguments
 * - **default:** `'filepath'` in development, `'filepath-source'` in production
 */
componentIdGenerator?:
  | 'filepath'
  | 'filepath-source'
  | ((
      filepath: string,
      source: string,
      isProduction: boolean | undefined,
      getHash: (text: string) => string,
    ) => string)

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

  • 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.

Copy link

pkg-pr-new bot commented Oct 21, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/@vitejs/plugin-vue@461
pnpm add https://pkg.pr.new/@vitejs/plugin-vue-jsx@461

commit: 0c4af22

@Jinjiang Jinjiang changed the title Add a feature option to support custom component id generator feat: add a feature option to support custom component id generator Oct 21, 2024
@yyx990803 yyx990803 merged commit 7a1fc4c into vitejs:main Nov 13, 2024
7 of 8 checks passed
@Jinjiang Jinjiang deleted the custom-comp-id branch November 13, 2024 07:29
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.

2 participants