esbuild-plugin-virtual
A virtual file system for esbuild modules.
Install
sh
npm i -D @chialab/esbuild-plugin-virtual
sh
yarn add -D @chialab/esbuild-plugin-virtual
sh
pnpm add -D @chialab/esbuild-plugin-virtual
Usage
Define a virtual module:
ts
import virtualPlugin from '@chialab/esbuild-plugin-virtual';
import esbuild from 'esbuild';
await esbuild.build({
entrypoints: ['index.js'],
plugins: [
virtualPlugin([
{
path: 'virtual-entry.js',
contents: 'export const nil = () => {};',
loader: 'js',
},
]),
],
});
ts
import { nil } from 'virtual-entry.js';
nil();