/unplugin-require-transform

💡 transform `require` into `import` for ESM

Primary LanguageTypeScriptMIT LicenseMIT

unplugin-require-transform

transform require into import for ESM runtime compatibility

Why?

When old project migrate from webpack to vite, you may just want to run it instead of modifying every require syntax to new import syntax.

Install

npm i unplugin-require-transform --save-dev

Usage

Vite
import { defineConfig } from 'vite'
import unPluginRequireTransform from 'unplugin-require-transform/vite'

export default defineConfig({
  plugins: [
    vue(),
    unPluginRequireTransform.vite(),
    // ...etc
  ],
})


TODO

  • vue require transform
  • dedupe import
  • test for webpack and add demos