Skip to content

SW03001: Generated identifier collision

Two different styles would receive the same generated name.

This error occurs when two different styles, refs, or animations would receive the same generated name. The usual cause is a custom naming function that returns the same name for different requests. A very short hashLength can also cause it.

Reported

stillwind.config.ts
import { defineConfig } from "stillwind/config";

export default defineConfig({
  projects: [
    {
      css: "./src/stillwind.css",
      files: ["src/**/*.tsx"],
      namingRevision: "1",
      naming: {
        utilityClass: () => "button",
      },
    },
  ],
});
style("p-4");
style("p-8");

SW03001: generated identifier collision: button

Fixed

stillwind.config.tsts
import { defineConfig } from "stillwind/config";

export default defineConfig({
  projects: [
    {
      css: "./src/stillwind.css",
      files: ["src/**/*.tsx"],
      namingRevision: "2",
      naming: {
        utilityClass: (_context, hash) => `button_${hash.toString("hex")}`,
      },
    },
  ],
});
style("p-4");
style("p-8");

How to fix

  • Include the hash passed as the callback’s second argument in the name, as in the example. This keeps the button prefix while distinguishing requests. Return null to use the default name for a request.
  • If you use the default names, raise hashLength.
  • Change namingRevision whenever you change a naming function.