Coder Social home page Coder Social logo

esbuild-plugin-velcro's Introduction

ESBuild Velcro Plugin

This esbuild plugin uses Velcro to build projects without having to npm install dependencies.

This Plugin wires up Velcro with esbuild so that bare module

Example

Given a project with the following file structure:

package.json:

{
  "dependencies": {
    "react": "~17.0.1",
    "react-dom": "~17.0.1"
  }
}

index.jsx:

import * as React from 'react';
import * as ReactDOMServer from 'react-dom/server';

const Hello = () => <h1>Hello world</h1>;

export function render() {
  return ReactDOMServer.renderToString(<Hello />);
}

Configure esbuild to build this project without ever having to npm install react or react-dom...

build.js:

import { build } from 'esbuild';
import { createPlugin } from 'esbuild-plugin-velcro';

(async () => {
  const result = await build({
    bundle: true,
    define: {
      'process.env.NODE_ENV': JSON.stringify('development'),
    },
    entryPoints: ['.'],
    plugins: [createPlugin({ target: 'node' })],
  });
})();

Usage

createPlugin(options)

Returns an instance of this plugin where options is an optional object having:

  • .extensions is an optional array of extensions to support resolving files without explicit extensions.
  • .packageMain is an optional array of supported 'main' fields. Options:
    • browser - Note that the browser field's extended resolution and overrides semantics are supported
    • module
    • jsnext:main
    • main
    • unpkg
  • .target is an optional value describing the target runtime environment for the build. Options:
    • node - When this is specified, Node's built-in modules will be treated as esbuild externals, and therefore not bundled.

License

MIT

esbuild-plugin-velcro's People

Contributors

ggoodman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

okikio

esbuild-plugin-velcro's Issues

[Bug] cachable-lookups requires builtin node modules that aren't present on esbuild in the browser

When I try to use esbuild-velcro, it just errors out with this,

[21:35:18] Error in plugin "gulp-esbuild"
Message:
    Build failed with 21 errors:
node_modules/.pnpm/[email protected]/node_modules/cacheable-lookup/source/index.js:10:12: error: Could not resolve "dns" (use "platform: 'node'" when building for node)
node_modules/.pnpm/[email protected]/node_modules/cacheable-lookup/source/index.js:12:19: error: Could not resolve "os" (use "platform: 'node'" when building for node)
node_modules/.pnpm/[email protected]/node_modules/decompress-response/index.js:3:21: error: Could not resolve "zlib" (use "platform: 'node'" when building for node)
node_modules/.pnpm/[email protected][email protected]/node_modules/esbuild-plugin-velcro/dist/index.esm.js:6:20: error: Could not resolve "fs" (use "platform: 'node'" when building for node)
node_modules/.pnpm/[email protected][email protected]/node_modules/esbuild-plugin-velcro/dist/index.esm.js:8:19: error: Could not resolve "module" (use "platform: 'node'" when building for node)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.