unplugin / unplugin-vue-markdown

Compile Markdown to Vue component
MIT License
508 stars 27 forks source link

fix: shim require for ESM #19

Closed sapphi-red closed 1 year ago

sapphi-red commented 1 year ago

Sorry, #18 wasn't working because require doesn't work in ESM. This PR shim require for ESM.

antfu commented 1 year ago

Can we directly create the require function in place? I am not sure the shim is needed

sapphi-red commented 1 year ago

I forgot that tsup will shim import.meta.url. (I had to add esbuildOptions.supported though) I updated the PR.

sapphi-red commented 1 year ago

import-meta not supported error was happening because the target was ES2017. Because vite-plugin-vue-markdown depends on Vite 2+ that supports Node 12+, I changed the target to node12 instead of setting esbuildOptions.supported in the latest commit. node12 is ES2019 + some features according to https://node.green/ .