Code Monkey home page Code Monkey logo

vite-plugin-ngmi-polyfill's Introduction

vite-plugin-ngmi-polyfill

Vite plugin for polyfilling Node.js built-in globals and modules ⚡️

npm/v npm/dt stars


Table of contents


Reason

Some modules such as events or process requires polyfilling since Vite does not handle it by default (here's a search for vite browser-external errors), whereas several packages, especially web3 related ones, use these packages in order to work.

This package wraps other polyfill packages and exports a Vite plugin so you can easily import inside your vite.config.{js,ts}.

Installing

# using npm
npm install vite vite-plugin-ngmi-polyfill

# using yarn
yarn add vite vite-plugin-ngmi-polyfill

# using pnpm
pnpm add vite vite-plugin-ngmi-polyfill

Usage

import { defineConfig } from "vite";
import { NgmiPolyfill } from "vite-plugin-ngmi-polyfill";

export default defineConfig({
  plugins: [NgmiPolyfill()],
});

Examples

Included packages

License

MIT License, Copyright (c) 2022 Griko Nibras

vite-plugin-ngmi-polyfill's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vite-plugin-ngmi-polyfill's Issues

update dependencies

SvelteKit now ships with vite 4.0.0 which breaks compatibility with this plugin ("vite": "^3").

@esbuild-plugins/node-globals-polyfill/_buffer.js" cannot be marked as external

i've tried install esbuild polyfill get exactly same error with vite-plugin-ngmi-polyfill


  VITE v4.0.4  ready in 597 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help
✘ [ERROR] The injected path "/Users/monsterstep/dev/chat-client/node_modules/@esbuild-plugins/node-globals-polyfill/_buffer.js" cannot be marked as external

✘ [ERROR] The injected path "/Users/monsterstep/dev/chat-client/node_modules/@esbuild-plugins/node-globals-polyfill/_virtual-process-polyfill_.js" cannot be marked as external

Build failed with 2 errors:
error: The injected path "/Users/monsterstep/dev/chat-client/node_modules/@esbuild-plugins/node-globals-polyfill/_buffer.js" cannot be marked as external
error: The injected path "/Users/monsterstep/dev/chat-client/node_modules/@esbuild-plugins/node-globals-polyfill/_virtual-process-polyfill_.js" cannot be marked as external
✘ [ERROR] Could not resolve "/Users/monsterstep/dev/chat-client/node_modules/@esbuild-plugins/node-globals-polyfill/_virtual-process-polyfill_.js"

1:14:11 PM [vite] error while updating dependencies:
Error: Build failed with 1 error:
error: Could not resolve "/Users/monsterstep/dev/chat-client/node_modules/@esbuild-plugins/node-globals-polyfill/_virtual-process-polyfill_.js"
    at failureErrorWithLog (/Users/monsterstep/dev/chat-client/node_modules/esbuild/lib/main.js:1596:15)
    at /Users/monsterstep/dev/chat-client/node_modules/esbuild/lib/main.js:1052:28
    at runOnEndCallbacks (/Users/monsterstep/dev/chat-client/node_modules/esbuild/lib/main.js:1468:61)
    at buildResponseToResult (/Users/monsterstep/dev/chat-client/node_modules/esbuild/lib/main.js:1050:7)
    at /Users/monsterstep/dev/chat-client/node_modules/esbuild/lib/main.js:1162:14
    at responseCallbacks.<computed> (/Users/monsterstep/dev/chat-client/node_modules/esbuild/lib/main.js:697:9)
    at handleIncomingPacket (/Users/monsterstep/dev/chat-client/node_modules/esbuild/lib/main.js:752:9)
    at Socket.readFromStdout (/Users/monsterstep/dev/chat-client/node_modules/esbuild/lib/main.js:673:7)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:315:12)

rollup-plugin-node-polyfills or rollup-plugin-polyfill-node?

Hello. I just saw your package, and have a question / suggestion.

From https://github.com/FredKSchott/rollup-plugin-polyfill-node

This repo is an updated, maintained fork of https://github.com/ionic-team/rollup-plugin-node-polyfills to support better Node.js polyfills in Snowpack and all other Rollup projects. See this thread for discussion on moving this plugin into the official Rollup org: rollup/plugins#51 (comment)

I really don't know about all these packages for polyfilling node.js, but I guess in your case you want to use rollup-plugin-polyfill-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.