vite-plugin-fast-external
Without lexical transform, support custom external code
English | 简体中文
-
Like Webpack externals, support browser, Node.js and Electron
-
With out ast analyze, load virtual files by resolveId-hooks -- Real efficient
-
Support customize the code snippets by return string from function -- Real flexible 🎉
Install
npm i vite-plugin-fast-external -D
Usage
import external from 'vite-plugin-fast-external';
export default defineConfig({
plugins: [
external({
vue: 'Vue',
'@scope/name': () => `const Lib = window.ScopeName.Member; export default Lib;`,
externalId: () => require('fs/promises').readFile('path', 'utf-8'),
electron: () => `const { ipcRenderer } = require('electron'); export { ipcRenderer }`,
})
]
})
API
external(entries)
entries
Record<string, string | ((id: string) => string | Promise<string>)>;