diff --git a/src/services/scssNavigation.ts b/src/services/scssNavigation.ts index 96d85479..38536a09 100644 --- a/src/services/scssNavigation.ts +++ b/src/services/scssNavigation.ts @@ -79,10 +79,11 @@ export class SCSSNavigation extends CSSNavigation { const subpath = bareTarget.substring(moduleName.length + 1); if (packageJson.exports) { if (!subpath) { - const dotExport = packageJson.exports['.']; + // exports may look like { "sass": "./_index.scss" } or { ".": { "sass": "./_index.scss" } } + const rootExport = packageJson.exports["."] || packageJson.exports; // look for the default/index export // @ts-expect-error If ['.'] is a string this just produces undefined - const entry = dotExport && (dotExport['sass'] || dotExport['style'] || dotExport['default']); + const entry = rootExport && (rootExport['sass'] || rootExport['style'] || rootExport['default']); // the 'default' entry can be whatever, typically .js – confirm it looks like `scss` if (entry && entry.endsWith('.scss')) { const entryPath = joinPath(modulePath, entry); diff --git a/src/test/scss/scssNavigation.test.ts b/src/test/scss/scssNavigation.test.ts index 2b307f43..f667e6d7 100644 --- a/src/test/scss/scssNavigation.test.ts +++ b/src/test/scss/scssNavigation.test.ts @@ -326,6 +326,9 @@ suite('SCSS - Navigation', () => { await assertLinks(ls, `@use "pkg:bar-pattern/theme/dark.scss"`, [{ range: newRange(5, 38), target: getTestResource('node_modules/bar-pattern/styles/theme/dark.scss')}], 'scss', testUri, workspaceFolder ); + await assertLinks(ls, `@use "pkg:conditional"`, + [{ range: newRange(5, 22), target: getTestResource('node_modules/conditional/_index.scss')}], 'scss', testUri, workspaceFolder + ); }); }); diff --git a/test/linksTestFixtures/node_modules/conditional/package.json b/test/linksTestFixtures/node_modules/conditional/package.json new file mode 100644 index 00000000..81f44eff --- /dev/null +++ b/test/linksTestFixtures/node_modules/conditional/package.json @@ -0,0 +1,6 @@ +{ + "exports": { + "sass": "./_index.scss", + "default": "./index.js" + } +}