mdx-js / mdx-analyzer

MDX extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-mdx
MIT License
351 stars 21 forks source link

VSCode Extension cannot find packages indicated in tsconfig.json #442

Closed Icexist closed 6 months ago

Icexist commented 6 months ago

Initial checklist

Affected packages and versions

v1.8.6

Link to runnable example

No response

Steps to reproduce

When using the MDX plugin in VSCode, set the tsconfig.json file to have any number of plugins and try to open an mdx file.

It works just fine with the 1.8.5 version (installed via "install other version" in vscode)

my tsconfig.json file:

{
  "include": ["**/*"],
  "compilerOptions": {
    // …
  },
  "mdx": {
    "plugins": [
      "remark-frontmatter",
      "remark-gfm",
      "remark-math",
      "rehype-katex"
    ]
  }
}

Expected behavior

MDX should work as expected.

Actual behavior

The MDX plugin crashes:

Error: Cannot find package 'remark-frontmatter' imported from /home/xxxx/project at new n (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:858:18648) at Sq (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:860:7076) at Xle (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:860:7581) at Eq (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:860:8808) at Gv (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:860:8998) at Lq (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:860:10157) at async Kv (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:860:9400) at async Promise.all (index 0) at async s (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:865:18826) at async sae (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:96:5817) { code: 'ERR_MODULE_NOT_FOUND' }

Node.js v18.18.2 [Error - 4:13:18 PM] Server process exited with code 1. [Error - 4:13:18 PM] The MDX server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

Runtime

No response

Package manager

No response

OS

Windows 10, running VSCode remote in a WSL2 instance. MDX plugin runs on the WSL instance.

Build and bundle tools

No response

remcohaszing commented 6 months ago

In version 1.8.0-1.8.5 there was a bug that caused the language server to ignore the plugins field. So it defaulted to ["remark-frontmatter", "remark-gfm"]. That’s why this worked for you kind of by accident.

You should specify "remark-math", because it adds support for parsing the math syntax, but not "rehype-katex", as this only transforms the AST.

Do you have all those plugins installed in /home/xxxx/project? In other words: Does /home/xxxx/project/node_modules/remark-frontmatter exist and can you import remark-frontmatter from /home/xxxx/project/some-script.mjs? with the following contents:

import 'remark-frontmatter'
github-actions[bot] commented 6 months ago

Hi! Thanks for taking the time to contribute! This has been marked by a maintainer as needing more info. It’s not clear yet whether this is an issue. Here are a couple tips:

Thanks, — bb

Icexist commented 6 months ago

Verify that those (and more) are in node_modules: image

I'm running Docusaurus, so i'm not fully clear on how to test the .mjs file, but these extensions work just fine in Docusaurus.

Still have the same problems after removing rehype-katex - the extension can't find the modules.

Here's a fresh repository that shows the issue for me: https://github.com/Icexist/mdx-ext-debug

There is a file docs\test.mdx that triggers the issue.

Icexist commented 6 months ago

As a note, that repo was created on MacOS and showed the issue in VSCode there, so this isn't limited to Windows.

remcohaszing commented 6 months ago

Thanks for the reproduction. I’m able to reproduce this on Linux too.

github-actions[bot] commented 6 months ago

Hi! This was marked as ready to be worked on! Note that while this is ready to be worked on, nothing is said about priority: it may take a while for this to be solved.

Is this something you can and want to work on?

Team: please use the area/* (to describe the scope of the change), platform/* (if this is related to a specific one), and semver/* and type/* labels to annotate this. If this is first-timers friendly, add good first issue and if this could use help, add help wanted.

github-actions[bot] commented 6 months ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

remcohaszing commented 6 months ago

This was fixed in version 1.8.7 :tada: