@shinnqy/cjs2esm
v1.2.1
Published
Convert cjs to esm. Support vite.js and standalone.
Downloads
3
Maintainers
Readme
Preview
Install
npm i cjs2esmodule
// or
yarn add cjs2esmodule
Usage
Using in vite.js
This will use babel
to transform AST
. If it's too slow, prefer to use script version to transform files.
import { defineConfig } from 'vite'
import { cjs2esmVitePlugin } from 'cjs2esmodule'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [cjs2esmVitePlugin()]
})
Using script to transform files.
Used glob
under the hood, so it will follow the pattern.
const { transformFiles } = require('cjs2esmodule')
transformFiles('./scripts/test.js')
// Support Array
transformFiles(['./utils/*.js', './components/*.js'])