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

Custom identifier doesn't allow hyphens inside a css class #1253

Closed
2 tasks done
EvgenNoskov opened this issue Dec 13, 2023 · 0 comments · Fixed by #1254
Closed
2 tasks done

Custom identifier doesn't allow hyphens inside a css class #1253

EvgenNoskov opened this issue Dec 13, 2023 · 0 comments · Fixed by #1254

Comments

@EvgenNoskov
Copy link
Contributor

Describe the bug

Custom identifier function throws an error, when trying to use css class with hyphens inside.

const withVanillaExtract = createVanillaExtractPlugin({
    identifiers: ({ hash }) => `prefix-${hash}` //will throw an Error
});

It seems the regex detects the false negative result.

// packages\css\src\identifier.ts
if (!identifier.match(/^[A-Z_][0-9A-Z_]+$/i)) {
  throw new Error(
    `Identifier function returned invalid indentifier: "${identifier}"`,
  );
}

Reproduction

https://github.com/EvgenNoskov/vanilla-css-issue

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
    Memory: 7.59 GB / 31.94 GB
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 120.0.6099.71
    Edge: Spartan (44.19041.3636.0), Chromium (120.0.2210.61)
    Internet Explorer: 11.0.19041.3636
  npmPackages:
    @vanilla-extract/css: ^1.14.0 => 1.14.0
    @vanilla-extract/next-plugin: ^2.3.2 => 2.3.2

Used Package Manager

npm

Logs

Error: Identifier function returned invalid indentifier: "prefix-1gezp2d0"
Import trace for requested module:
./src/components/MyComponent.css.ts
./src/components/MyComponent.tsx
./src/app/page.tsx

Validations

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

Successfully merging a pull request may close this issue.

1 participant