Transforming `import.meta` with jest and swc
I've spent a few hours trying to find how this is meant to work with jest and swc.
config:
Jest:
But no matter what I try, I still hit:
SyntaxError: Cannot use 'import.meta' outside a module
What am I doing wrong here?3 Replies
The same problem happens with:
Issue created: https://github.com/swc-project/swc/issues/7636
GitHub
Jest with swc,
Cannot use 'import.meta' outside a module
· Issue ...Describe the bug I've been adopting the usage of @swc for testing in our Jest test suite for a react application and encountered the issue where when attempting to transpile import.meta.env swc...
For anyone stumbling across this, the solution was to write a plugin to handle this explicitly.
I've published this: https://github.com/Codex-/swc-plugin-import-meta-env
GitHub
GitHub - Codex-/swc-plugin-import-meta-env
Contribute to Codex-/swc-plugin-import-meta-env development by creating an account on GitHub.