Skip to content

Conversation

sapphi-red
Copy link
Contributor

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

@antfu
Copy link
Member

antfu commented May 4, 2023

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

@sapphi-red
Copy link
Contributor Author

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

@sapphi-red
Copy link
Contributor Author

sapphi-red commented May 5, 2023

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/ .

@antfu antfu merged commit 656a9d6 into unplugin:main May 16, 2023
@sapphi-red sapphi-red deleted the fix/require-shim branch May 17, 2023 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants