Skip to content

kanamone/vite-plugin-dynamic-import-with-import-map

Repository files navigation

@kanamone/vite-plugin-dynamic-import-with-import-map

npm version test

Import some modules via importmap

Features

  1. ✅ Auto embed importmap in index.html
  2. ✅ Auto generate external modules bundle by esbuild
    1. ✅ Minify
    2. ✅ Inline sourcemap

Installation

npm install @kanamone/vite-plugin-dynamic-import-with-import-map

Usage

The following example makes split react bundle

// vite.config.ts

import { defineConfig } from 'vite'
import { dynamicImportWithImportMap } from '@kanamone/vite-plugin-dynamic-import-with-import-map'

export default defineConfig({
  plugins: [dynamicImportWithImportMap(['react'])],
})

Caveats

Module dependency resolution doesn't work. Because vite is not execute rollup build phase when serve mode.