antfu / babel-plugin-esm-rewrite

Rewrites ESM syntax to function calls

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

babel-plugin-esm-rewrite

NPM version

Rewrites ESM syntax to function calls, so they can be evaluated without ESM context. Ported from Vite's ssrTransfrom but as a Babel plugin.

// input
import { ref } from 'vue'
function foo() {
  return ref(0)
}
// output
const __esm_import_0__ = await __esm_import__('vue')
function foo() {
  return __esm_import_0__.ref(0)
}

Sponsors

License

MIT License © 2022 Anthony Fu

About

Rewrites ESM syntax to function calls

License:MIT License


Languages

Language:TypeScript 100.0%