Skip to content

refactor(core, ts-plugin): replace secondaryMapping with CustomSourceMap#363

Open
mizdra wants to merge 1 commit intomainfrom
refactor-source-map
Open

refactor(core, ts-plugin): replace secondaryMapping with CustomSourceMap#363
mizdra wants to merge 1 commit intomainfrom
refactor-source-map

Conversation

@mizdra
Copy link
Copy Markdown
Owner

@mizdra mizdra commented Apr 18, 2026

Summary

Remove the secondaryMapping workaround for the Single-Quote Span Problem and replace it with a custom Mapper that strips outer quote characters when a direct range lookup fails.

Motivation

The real goal of this refactor is to make upcoming work easier — specifically, to let named-export mode handle token names that are not valid JavaScript identifiers (e.g. a-4). The old secondaryMapping approach produced two mapping objects per token and leaned on Volar.js's ordered-mapping fallback, which made per-token mapping logic fragile to change. By shrinking each token to a single mapping object and moving the quote-span handling into CustomSourceMap, the mapping data becomes simple enough that subsequent work on invalid-identifier tokens can focus on codegen without fighting the mapping layer.

Test plan

  • vp check passes (format, lint, type checks)
  • vp test passes (300 tests, 1 todo)

🤖 Generated with Claude Code

@mizdra mizdra added the Type: Refactoring A code change that neither fixes a bug nor adds a feature label Apr 18, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 18, 2026

🦋 Changeset detected

Latest commit: 506782f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@css-modules-kit/core Patch
@css-modules-kit/ts-plugin Patch
@css-modules-kit/codegen Patch
@css-modules-kit/eslint-plugin Patch
@css-modules-kit/stylelint-plugin Patch
css-modules-kit-vscode Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mizdra mizdra force-pushed the refactor-source-map branch 3 times, most recently from cbc324a to 6b3bc59 Compare April 19, 2026 10:04
Remove the secondaryMapping workaround for the Single-Quote Span Problem and
replace it with a custom Mapper that strips outer quote characters when a
direct range lookup fails. The primary mapping now covers only the inner
token name, while CustomSourceMap (registered via language.mapperFactory)
handles getDefinitionAtPosition spans that include the surrounding quotes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mizdra mizdra force-pushed the refactor-source-map branch from 6b3bc59 to 506782f Compare April 19, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Refactoring A code change that neither fixes a bug nor adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant