Skip to content

Commit 39185cf

Browse files
committed
fix: support for conditional exports in sass's pkg
1 parent 833f428 commit 39185cf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/services/scssNavigation.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ export class SCSSNavigation extends CSSNavigation {
7979
const subpath = bareTarget.substring(moduleName.length + 1);
8080
if (packageJson.exports) {
8181
if (!subpath) {
82-
const dotExport = packageJson.exports['.'];
82+
// exports may look like { "sass": "./_index.scss" } or { ".": { "sass": "./_index.scss" } }
83+
const rootExport = packageJson.exports["."] || packageJson.exports;
8384
// look for the default/index export
8485
// @ts-expect-error If ['.'] is a string this just produces undefined
85-
const entry = dotExport && (dotExport['sass'] || dotExport['style'] || dotExport['default']);
86+
const entry = rootExport && (rootExport['sass'] || rootExport['style'] || rootExport['default']);
8687
// the 'default' entry can be whatever, typically .js – confirm it looks like `scss`
8788
if (entry && entry.endsWith('.scss')) {
8889
const entryPath = joinPath(modulePath, entry);

0 commit comments

Comments
 (0)