antfu/vite-plugin-md

Server not starting

Hoopex opened this issue · 6 comments

Describe the bug

I'm getting this issue last 2 days.

[ERR_REQUIRE_ESM]: require() of ES Module \node_modules\brilliant-errors\node_modules\callsites\index.js from \node_modules\brilliant-errors\dist\index.cjs not supported.

Reproduction

Vue

System Info

'envinfo' is not recognized as an internal or external command,
operable program or batch file.

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

This may be caused by brilliant-errors. See the related issue .

@Discreater Yeah I know, But this plugin not gonna work since that package has that issue
By the way, I fixed that temp by installing v0.60 in my project, Bu still not a good way.

Don't ask me why or how, but it works if you put in the package.json

"resolutions": {
  "brilliant-errors": "0.6.0"
}

the reason is in part due to the fact that brilliant-errors updated to the latest version of callsites (used for better error reporting). Unfortunately the latest version of callsites is ESM-only (aka, no CJS). My functional tests all passed for brilliant-errors on up the stack because I'm testing at the Typescript level but this happens in this unforunate time where CJS is going away and ESM hasn't fully taken over.

To address this I have updated brilliant-errors to only export in ESM and this is available in version 0.7.x. For Vite based projects -- which are ESM by default -- this should be a non-issue. Note, however, while this issue was fixed I am now noticing that the very old gray-matter library is causing similar issues. I had given that team a pull request about a year ago for this library as well as picomatch which at least got them to ESM but I think that team is very busy and focused on other things (I got a nice thumbs up and they were going to approve picomatch but just never got there).

Anyway, I've refactored gray-matter to Typescript and ESM now and updated all of it's quite antiquated deps. You can find this at @yankeeinlondon/gray-matter for now but I still hope I can talk the team into bringing it into the main branch of gray-matter.

By end of day today, I'll have the full stack that vite-plugin-md depends on fully on ESM (I hope anyway). Appologies for all the hiccups and I will need to expand my tests to not only test the Typescript but the transpiled output.

I believe everything after Release v0.22.0 should work fine now. Please re-open if that is not the case.

@yankeeinlondon Thank you for your work! It seems that v0.22.0 is not published to npm, is there any mistake?