Skip to content

Commit

Permalink
fix: support declaring exports without path
Browse files Browse the repository at this point in the history
Fixes #184
  • Loading branch information
wkillerud committed Jul 28, 2024
1 parent 2d1335c commit 1f2d56b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ suite("SCSS - Navigation", () => {
[
{
namespace: "sass-true",
range: newRange(5, 14),
range: newRange(5, 20),
target: getTestResource("node_modules/sass-true/_index.scss"),
type: nodes.NodeType.Use,
},
Expand Down

0 comments on commit 1f2d56b

Please sign in to comment.