Skip to content

SCSS: resolve bare module imports on Windows (the sequel) - #459

Open
ProgramGamer (miss-programgamer) wants to merge 16 commits into
microsoft:mainfrom
miss-programgamer:fix/scss-import-node-modules
Open

ProgramGamer (miss-programgamer) wants to merge 16 commits into
microsoft:mainfrom
miss-programgamer:fix/scss-import-node-modules

Conversation

@miss-programgamer

Copy link
Copy Markdown

Duplicate of #440 because original user went awol.

@miss-programgamer

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@miss-programgamer

Copy link
Copy Markdown
Author

@aeschli

Copy link
Copy Markdown
Collaborator

Changes Summary

PR #459 adds bare SCSS module resolution on Windows, including root-level module imports, while preserving scheme-prefixed URLs.

What’s Done Well

  • Handles imports that reference only a module root.
  • Includes coverage for standard and custom URI schemes.
  • Compilation and linting pass.

Critical Issues

  1. Correctness — relative imports now lose precedence
    cssNavigation.ts:443 tries node_modules before checking whether the relative target exists. This breaks existing behavior when both a local directory and package have the same name.
    Confirmed failures:

    • CSS green/c.css resolves to node_modules/green/c.css
    • SCSS green/d.scss resolves to node_modules/green/d.scss
  2. Tests — new Windows test fails on macOS/Linux
    scssNavigation.test.ts:410 references a nonexistent c:/proj/node_modules/bootstrap fixture and constructs a platform-dependent expected URI. The test falls back to file:///c:/proj/bootstrap/scss/variables instead of resolving the package.

Improvements

  • The scheme tests beginning at scssNavigation.test.ts:374 do not prove the URLs avoided bare-import classification: module lookup can fail and still return the expected unchanged URL.

Validation

npm run compile
node --enable-source-maps --test lib/esm/test/scss/scssNavigation.test.js

Compilation and linting passed; tests reported 45 passed, 3 failed.

Verdict

Needs Revisions. Restore relative-file-first resolution, then make the Windows test use a real or mocked package fixture with platform-independent URI assertions.

@aeschli Martin Aeschlimann (aeschli) left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

See the review comments: #459 (comment)

const resolvedModuleRef = await this.resolveModuleReference(target, documentUri, documentContext);
const moduleRef = await this.mapReference(resolvedModuleRef, isRawLink);

if (moduleRef != null) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should be moduleRef !== undefined

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.

3 participants