Skip to content

Language service does not support non-extension paths of JS files #1942

Open
@tzachbon

Description

@tzachbon

There is a general issue when trying to resolve js files in the language service.
You would expect it to be similar to the webpack plugin path resolution.

I would expect the language service to "jump to file" when I click on the default import of the JS mixin for example, but it is not the case when the .js extension is missing, or even if it is an index file and you write the only the dirname.

Examples time -

Let's say I have 2 files next to each other:

- my-mixin.js
- style.st.css

In the style.st.css:

@st-import myMixin from "./my-mixin.js"

When clicking on the myMixin import it jumps to my-mixin.js as expected like this:

module.exports = function |myMixin([...]) {
	return {
		...
	};
}

The problem starts when I remove the extension to:

@st-import myMixin from "./my-mixin"

And when I hover, I get this error in the output of VSCode:

[Error - 12:31:00 PM] Request textDocument/definition failed.
  Message: Request textDocument/definition failed with message: ENOENT: no such file or directory, open '/Users/project/src/my-mixin'
  Code: -32603 

Note: when using this code with the webpack plugin, everything works as expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected behavior or exceptionlanguage-serviceCompletions, highlights, definitions and more LSP capabilities

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions