Skip to content

fix: fix crash with postcss 8.5.16+ when resolving original token locations#321

Merged
mizdra merged 3 commits into
mizdra:mainfrom
chida09:fix/remove-origin-column-workaround
Jul 2, 2026
Merged

fix: fix crash with postcss 8.5.16+ when resolving original token locations#321
mizdra merged 3 commits into
mizdra:mainfrom
chida09:fix/remove-origin-column-workaround

Conversation

@chida09

@chida09 chida09 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

postcss 8.5.16 (postcss/postcss#2036) fixed Input#origin() to correctly accept 1-based columns and internally convert to 0-based before passing to source-map-js.

The - 1 workaround in getOriginalLocationOfClassSelector is no longer needed and causes double subtraction, resulting in column = -1 which crashes source-map-js:

TypeError: Column must be greater than or equal to 0, got -1

Fixes #320

postcss 8.5.16 (postcss/postcss#2036) fixed `Input#origin()` to
correctly accept 1-based columns. The `- 1` workaround in
`getOriginalLocationOfClassSelector` is no longer needed and causes
double subtraction, resulting in `column = -1` which crashes
`source-map-js`.

Fixes mizdra#320
@chida09 chida09 force-pushed the fix/remove-origin-column-workaround branch from c73b43a to 6e1f707 Compare July 2, 2026 02:06
@mizdra mizdra added the Type: Bug Bug or Bug fixes label Jul 2, 2026
mizdra and others added 2 commits July 2, 2026 21:36
…alue

postcss 8.5.16 (postcss/postcss#2036) changed `Input#origin()` to
return 1-based columns as well as accept them. The `+ 1` conversion
in `getOriginalLocationOfClassSelector` is no longer needed and
shifted original locations by one column.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mizdra

mizdra commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Thanks for sending the PR! The changes looked good, but I have added a few commits here.

  1. Updated to postcss@^8.5.16 (b982748)
    • This is because keeping postcss@^8.5.15 does not guarantee that the patched Input#origin() is used.
  2. Removed the + 1 conversion on the return value of Input#origin() (dfdfc9c)

The tests are passing, so I will go ahead and merge this.

@mizdra mizdra left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mizdra mizdra merged commit c62e5ec into mizdra:main Jul 2, 2026
6 checks passed
@mizdra mizdra changed the title fix: remove workaround for postcss Input#origin() 0-based column fix: fix crash with postcss 8.5.16+ when resolving original token locations Jul 2, 2026
@mizdra

mizdra commented Jul 2, 2026

Copy link
Copy Markdown
Owner

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

Labels

Type: Bug Bug or Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

origin() call crashes with postcss 8.5.16: Column must be greater than or equal to 0, got -1

2 participants