@shinnqy/cjs2esm
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

Preview

avatar

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'])

Package Sidebar

Install

npm i @shinnqy/cjs2esm

Weekly Downloads

27

Version

1.2.1

License

MIT

Unpacked Size

59.1 kB

Total Files

32

Last publish

Collaborators

  • shinnqy