andrewbranch / gatsby-remark-vscode

Gatsby plugin to provide VS Code’s syntax highlighting to Markdown code fences
MIT License
296 stars 27 forks source link

Non-Gatsby Remark Plugin in MDSveX #160

Closed janosh closed 3 years ago

janosh commented 3 years ago

Thanks @codepunkt for #157! I just tried this out with MDSveX and got a pretty unhelpful Vite error message. My first guess is that it's an ESM-CJS compat issue. You mentioned you're also using the remark plugin in an ESM setting. Did you have to jump through any hoops to get it working?

Error: offset is longer than source length!
    at numberToPos (node_modules/@sveltejs/kit/node_modules/vite/dist/node/chunks/dep-bc228bbb.js:4221:15)
    at formatError (node_modules/@sveltejs/kit/node_modules/vite/dist/node/chunks/dep-bc228bbb.js:44580:24)
    at TransformContext.error (node_modules/@sveltejs/kit/node_modules/vite/dist/node/chunks/dep-bc228bbb.js:44560:19)
    at Object.transform (node_modules/@sveltejs/kit/node_modules/vite/dist/node/chunks/dep-bc228bbb.js:44768:25)
    at async transformRequest (node_modules/@sveltejs/kit/node_modules/vite/dist/node/chunks/dep-bc228bbb.js:59029:29)
    at async instantiateModule (node_modules/@sveltejs/kit/node_modules/vite/dist/node/chunks/dep-bc228bbb.js:68641:10)
codepunkt commented 3 years ago

Nope, I'm also using it with vite in @wilsonjs and it works like a charm.

https://github.com/wilsonjs/wilson/blob/main/packages/wilson/src/node/markdown.ts#L108

janosh commented 3 years ago

Thanks for the link to your code. Will try to debug mine over the weekend maybe. Closing this for now as there's nothing actionable atm.