-
Notifications
You must be signed in to change notification settings - Fork 190
SCSS: resolve bare module imports on Windows (#245579) #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
SCSS: resolve bare module imports on Windows (#245579) #440
Conversation
@microsoft-github-policy-service agree |
.travis.yml
Outdated
@@ -0,0 +1,30 @@ | |||
# Continuous Integration for vscode-css-languageservice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove that file
const doc = TextDocument.create('file:///c:/proj/app.scss', 'scss', 1, | ||
"@import 'bootstrap/scss/variables';"); | ||
const links = await ls.findDocumentLinks2(doc, ls.parseStylesheet(doc), {}, mockFS); | ||
const target = links[0].target!.replace(/\\/g, '/'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target is a URI, it should not contain \
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. If you can add some more test cases that would be great
src/services/cssNavigation.ts
Outdated
// Treat bare module names (“bootstrap/...”) like sass-loader does | ||
const isBareImport = !target.startsWith('.') // not ./ or ../ | ||
&& !target.startsWith('/') // not workspace-absolute | ||
&& target.indexOf(':') === -1; // not a scheme (file://) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a use a regex to make that check [
startsWithSchemeRegex = /^\w[\w\d+.-]:/
…solute Adds `schemeImportLinks.test.ts` with four mocha cases covering `http://`, `https://`, `file://`, and `vscode-resource://` URLs
@@ -422,7 +422,22 @@ export class CSSNavigation { | |||
return this.mapReference(await this.resolveModuleReference(target, documentUri, documentContext), isRawLink); | |||
} | |||
|
|||
const ref = await this.mapReference(documentContext.resolveReference(target, documentUri), isRawLink); | |||
// Treat bare module names (“bootstrap/...”) like sass-loader does | |||
const startsWithSchemeRegex = /^\w[\w\d+.-]:/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node module resolving should only happen when this.resolveModuleReferences
is true.
(only set for LESS and SCSS).
So this needs to go behind the if (this.resolveModuleReferences) {
.
I looks like we already call resolveModuleReference
there, so this code is not necessary?
@@ -0,0 +1,46 @@ | |||
import * as assert from 'assert'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move these into scssNavigation.test.ts, where we have all other tests for node module resolving.
Please use the already existing test framework and style (mocha with suite
and test
@@ -0,0 +1,18 @@ | |||
import { assert } from 'chai'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move these into scssNavigation.test.ts, where we have all other tests for node module resolving.
Please use the already existing test framework and style (mocha with suite
and test
Fix issue #432