Skip to content

Comments

feat: add declaration source maps (.d.ts.map) for CSS Modules#74

Merged
privatenumber merged 4 commits intodevelopfrom
feat/declaration-source-maps
Feb 20, 2026
Merged

feat: add declaration source maps (.d.ts.map) for CSS Modules#74
privatenumber merged 4 commits intodevelopfrom
feat/declaration-source-maps

Conversation

@privatenumber
Copy link
Owner

Problem

When generateSourceTypes: true, the plugin generates .d.ts files next to CSS Modules. However, "Go to Definition" in editors lands on the generated .d.ts file rather than the CSS source. There's no way to navigate directly to the class selector definition in the CSS file.

Changes

  • Add @jridgewell/sourcemap-codec dependency for VLQ encoding
  • Create src/plugin/find-class-positions.ts — parses CSS with PostCSS to locate class selector positions (the . character)
  • Modify src/plugin/generate-types.ts — generate .d.ts.map source maps that map declare const declarations and export identifiers back to CSS class positions
  • Modify src/plugin/index.ts — wire up position finding and .d.ts.map file writing (with skip-if-unchanged optimization)
  • Update PostCSS and LightningCSS test suites with source map assertions and new dedicated .d.ts.map tests

@privatenumber privatenumber force-pushed the feat/declaration-source-maps branch from 9c21cce to 754c6fd Compare February 17, 2026 08:05
@privatenumber privatenumber force-pushed the feat/declaration-source-maps branch from 5f6d5f2 to 7a8356e Compare February 20, 2026 14:07
@privatenumber privatenumber marked this pull request as ready for review February 20, 2026 15:35
@privatenumber privatenumber force-pushed the feat/declaration-source-maps branch 6 times, most recently from 662e228 to 6ba5a95 Compare February 20, 2026 15:52
@privatenumber privatenumber force-pushed the feat/declaration-source-maps branch from 6ba5a95 to 30d7b94 Compare February 20, 2026 15:52
@privatenumber privatenumber merged commit 08d9c61 into develop Feb 20, 2026
1 check passed
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.

1 participant