Commit a0944ea
committed
fix(graph): SCSS imports no longer resolve to sibling .tsx files
Closes #245.
When a `.scss` / `.sass` file does `@use 'Widget'` (extensionless) and
both `Widget.scss` and `Widget.tsx` exist as siblings, fallow now resolves
the import to `Widget.scss` per Sass's actual resolution algorithm. The
standard `oxc_resolver` extension list contains `.tsx` / `.ts` before
`.scss`, so without this guard a bare specifier from a stylesheet was
silently picking the JS/TS sibling, creating phantom circular
dependencies in standard CSS-modules / Angular `styleUrls` patterns:
Helper.scss -> Widget.tsx -> Helper.tsx -> Helper.scss
(Helper.scss meant to share Sass variables with Widget.scss but
mis-resolved to Widget.tsx instead.)
Implementation: in `resolve_specifier`, after the standard resolver
returns a hit, reject any path whose extension is a JS/TS-family
extension (.tsx, .ts, .mts, .cts, .js, .jsx, .mjs, .cjs) when the
importer is `.scss` / `.sass`, and re-route through the SCSS-aware
fallback chain (CSS-extension probe, `_filename` partial convention,
framework include paths, `node_modules` walk-up). When those also fail,
the import is reported as unresolved instead of falling through to
JS/TS extensions. SFC `<style>` block imports (`from_style = true`)
keep their existing behaviour because their importer extension is
`.vue` / `.svelte` rather than `.scss`.
Tests: new fixture `scss-bare-import-tsx-collision` exactly mirrors the
issue's reproduction (Widget.tsx + Widget.scss siblings, Helper.scss
with `@use 'Widget'`, Helper.tsx imports `./Helper.scss`). Integration
test asserts zero circular dependencies, zero unresolved imports, and
that Widget.scss is reachable. The OLD binary built via `git stash` of
the diff produces the exact 3-file phantom cycle the issue documents;
the FIXED binary produces zero. The other 9 SCSS integration tests
(partial convention, include paths, node_modules resolution, external
package SCSS subpaths, SFC `<style>` blocks, Vite preprocessor
additionalData) continue to pass.1 parent ae7207b commit a0944ea
10 files changed
Lines changed: 110 additions & 0 deletions
File tree
- crates
- core/tests/integration_test
- graph/src/resolve
- tests/fixtures/scss-bare-import-tsx-collision
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
246 | 265 | | |
247 | 266 | | |
248 | 267 | | |
| |||
388 | 407 | | |
389 | 408 | | |
390 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
391 | 428 | | |
392 | 429 | | |
393 | 430 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments