esbuild-plugin-virtual
v0.1.0
Published
An esbuild plugin which loads virutal modules from memory.
Downloads
13
Readme
esbuild-plugin-virtual
💠 An esbuild plugin which loads virtual modules from memory.
Inspired from @rollup/plugin-virtual
.
Install
Using npm:
npm install esbuild-plugin-virtual --save-dev
Usage
// src/entry.ts
import batman from 'batman';
import { robin } from 'robin';
console.log(batman, robin);
Node
// build.js
import * as esbuild from 'esbuild';
import virtual from 'esbuild-plugin-virtual';
esbuild.build({
entryPoints: ['src/entry.ts'],
bundle: true,
plugins: [
virtual({
batman: `export default 'na na na na na';`,
robin: `export const robin = 'batmannnnn';`,
}),
],
})
$ node build.js
# (() => {
# // virtual:batman
# var batman_default = "na na na na na";
#
# // virtual:robin
# var robin = "batmannnnn";
#
# // entry.ts
# console.log(batman_default, robin);
# })();
Deno
import * as esbuild from "https://deno.land/x/[email protected]/mod.js";
import virtual from "https://cdn.skypack.dev/esbuild-plugin-virtual";
await esbuild.build({
entryPoints: ['entry.ts'],
bundle: true,
plugins: [
virtual({
batman: `export default 'na na na na na'`,
robin: `export const robin = 'batmannnnn'`,
}),
],
})
esbuild.stop()
$ deno run -A build.ts
# (() => {
# // virtual:batman
# var batman_default = "na na na na na";
#
# // virtual:robin
# var robin = "batmannnnn";
#
# // entry.ts
# console.log(batman_default, robin);
# })();