Socket
Socket
Sign inDemoInstall

esbuild-plugin-virtual

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    esbuild-plugin-virtual

An esbuild plugin which loads virutal modules from memory.


Version published
Maintainers
1
Install size
4.99 kB
Created

Readme

Source

npm size

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/esbuild@v0.12.5/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);
# })();

License

MIT

Keywords

FAQs

Last updated on 04 Aug 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc