Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-node-polyfills

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-node-polyfills - npm Package Compare versions

Comparing version 0.21.0 to 0.22.0

115

dist/index.js

@@ -1,25 +0,24 @@

import { createRequire as v } from "node:module";
import h from "@rollup/plugin-inject";
import y from "node-stdlib-browser";
import { handleCircularDependancyWarning as _ } from "node-stdlib-browser/helpers/rollup/plugin";
import B from "node-stdlib-browser/helpers/esbuild/plugin";
const g = (e, r) => u(e) === u(r), i = (e, r) => e ? e === !0 ? !0 : e === r : !1, x = (e) => e.startsWith("node:"), T = (e) => {
const r = e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
return new RegExp(`^${r}$`);
}, u = (e) => e.replace(/^node:/, ""), a = [
"import __buffer_polyfill from 'vite-plugin-node-polyfills/shims/buffer'",
"import __global_polyfill from 'vite-plugin-node-polyfills/shims/global'",
"import __process_polyfill from 'vite-plugin-node-polyfills/shims/process'",
"",
"globalThis.Buffer = globalThis.Buffer || __buffer_polyfill",
"globalThis.global = globalThis.global || __global_polyfill",
"globalThis.process = globalThis.process || __process_polyfill",
""
].join(`
`), w = (e = {}) => {
const r = v(import.meta.url), f = [
r.resolve("vite-plugin-node-polyfills/shims/buffer"),
r.resolve("vite-plugin-node-polyfills/shims/global"),
r.resolve("vite-plugin-node-polyfills/shims/process")
], l = {
import { createRequire as h } from "node:module";
import y from "@rollup/plugin-inject";
import _ from "node-stdlib-browser";
import { handleCircularDependancyWarning as B } from "node-stdlib-browser/helpers/rollup/plugin";
import x from "node-stdlib-browser/helpers/esbuild/plugin";
const c = (s, l) => b(s) === b(l), e = (s, l) => s ? s === !0 ? !0 : s === l : !1, T = (s) => s.startsWith("node:"), $ = (s) => {
const l = s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
return new RegExp(`^${l}$`);
}, b = (s) => s.replace(/^node:/, ""), u = {
buffer: [
"import __buffer_polyfill from 'vite-plugin-node-polyfills/shims/buffer'",
"globalThis.Buffer = globalThis.Buffer || __buffer_polyfill"
],
global: [
"import __global_polyfill from 'vite-plugin-node-polyfills/shims/global'",
"globalThis.global = globalThis.global || __global_polyfill"
],
process: [
"import __process_polyfill from 'vite-plugin-node-polyfills/shims/process'",
"globalThis.process = globalThis.process || __process_polyfill"
]
}, w = (s = {}) => {
const l = {
include: [],

@@ -29,3 +28,3 @@ exclude: [],

protocolImports: !0,
...e,
...s,
globals: {

@@ -35,26 +34,36 @@ Buffer: !0,

process: !0,
...e.globals
...s.globals
}
}, c = (o) => l.include.length > 0 ? !l.include.some((s) => g(o, s)) : l.exclude.some((s) => g(o, s)), d = (o) => {
if (i(l.globals.Buffer, "dev") && /^buffer$/.test(o))
}, d = (o) => l.include.length > 0 ? !l.include.some((r) => c(o, r)) : l.exclude.some((r) => c(o, r)), m = (o) => {
if (e(l.globals.Buffer, "dev") && /^buffer$/.test(o))
return "vite-plugin-node-polyfills/shims/buffer";
if (i(l.globals.global, "dev") && /^global$/.test(o))
if (e(l.globals.global, "dev") && /^global$/.test(o))
return "vite-plugin-node-polyfills/shims/global";
if (i(l.globals.process, "dev") && /^process$/.test(o))
if (e(l.globals.process, "dev") && /^process$/.test(o))
return "vite-plugin-node-polyfills/shims/process";
if (o in l.overrides)
return l.overrides[o];
}, b = Object.entries(y).reduce((o, [s, t]) => (!l.protocolImports && x(s) || c(s) || (o[s] = d(u(s)) || t), o), {});
}, g = Object.entries(_).reduce((o, [r, i]) => (!l.protocolImports && T(r) || d(r) || (o[r] = m(b(r)) || i), o), {}), p = h(import.meta.url), f = [
...e(l.globals.Buffer, "dev") ? [p.resolve("vite-plugin-node-polyfills/shims/buffer")] : [],
...e(l.globals.global, "dev") ? [p.resolve("vite-plugin-node-polyfills/shims/global")] : [],
...e(l.globals.process, "dev") ? [p.resolve("vite-plugin-node-polyfills/shims/process")] : []
], a = [
...e(l.globals.Buffer, "dev") ? u.buffer : [],
...e(l.globals.global, "dev") ? u.global : [],
...e(l.globals.process, "dev") ? u.process : [],
""
].join(`
`);
return {
name: "vite-plugin-node-polyfills",
config: (o, s) => {
const t = s.command === "serve";
config: (o, r) => {
const i = r.command === "serve";
return {
build: {
rollupOptions: {
onwarn: (n, p) => {
_(n, () => {
onwarn: (t, n) => {
B(t, () => {
if (o.build?.rollupOptions?.onwarn)
return o.build.rollupOptions.onwarn(n, p);
p(n);
return o.build.rollupOptions.onwarn(t, n);
n(t);
});

@@ -64,7 +73,7 @@ },

{
...h({
...y({
// https://github.com/niksy/node-stdlib-browser/blob/3e7cd7f3d115ac5c4593b550e7d8c4a82a0d4ac4/README.md#vite
...i(l.globals.Buffer, "build") ? { Buffer: "vite-plugin-node-polyfills/shims/buffer" } : {},
...i(l.globals.global, "build") ? { global: "vite-plugin-node-polyfills/shims/global" } : {},
...i(l.globals.process, "build") ? { process: "vite-plugin-node-polyfills/shims/process" } : {}
...e(l.globals.Buffer, "build") ? { Buffer: "vite-plugin-node-polyfills/shims/buffer" } : {},
...e(l.globals.global, "build") ? { global: "vite-plugin-node-polyfills/shims/global" } : {},
...e(l.globals.process, "build") ? { process: "vite-plugin-node-polyfills/shims/process" } : {}
})

@@ -77,3 +86,3 @@ }

// In dev, the global polyfills need to be injected as a banner in order for isolated scripts (such as Vue SFCs) to have access to them.
banner: t ? a : void 0
banner: i ? a : void 0
},

@@ -85,8 +94,8 @@ optimizeDeps: {

esbuildOptions: {
banner: t ? { js: a } : void 0,
banner: i ? { js: a } : void 0,
// https://github.com/niksy/node-stdlib-browser/blob/3e7cd7f3d115ac5c4593b550e7d8c4a82a0d4ac4/README.md?plain=1#L203-L209
define: {
...t && i(l.globals.Buffer, "dev") ? { Buffer: "Buffer" } : {},
...t && i(l.globals.global, "dev") ? { global: "global" } : {},
...t && i(l.globals.process, "dev") ? { process: "process" } : {}
...i && e(l.globals.Buffer, "dev") ? { Buffer: "Buffer" } : {},
...i && e(l.globals.global, "dev") ? { global: "global" } : {},
...i && e(l.globals.process, "dev") ? { process: "process" } : {}
},

@@ -97,3 +106,3 @@ inject: [

plugins: [
B(b),
x(g),
// Supress the 'injected path "..." cannot be marked as external' error in Vite 4 (emitted by esbuild).

@@ -103,9 +112,9 @@ // https://github.com/evanw/esbuild/blob/edede3c49ad6adddc6ea5b3c78c6ea7507e03020/internal/bundler/bundler.go#L1469

name: "vite-plugin-node-polyfills-shims-resolver",
setup(n) {
for (const p of f) {
const m = T(p);
n.onResolve({ filter: m }, () => ({
setup(t) {
for (const n of f) {
const v = $(n);
t.onResolve({ filter: v }, () => ({
// https://github.com/evanw/esbuild/blob/edede3c49ad6adddc6ea5b3c78c6ea7507e03020/internal/bundler/bundler.go#L1468
external: !1,
path: p
path: n
}));

@@ -121,3 +130,3 @@ }

alias: {
...b
...g
}

@@ -124,0 +133,0 @@ }

{
"name": "vite-plugin-node-polyfills",
"type": "module",
"version": "0.21.0",
"packageManager": "pnpm@8.4.0",
"version": "0.22.0",
"description": "A Vite plugin to polyfill Node's Core Modules for browser environments.",

@@ -89,3 +88,3 @@ "author": "David Myers <hello@davidmyers.dev>",

"vitest": "^1.2.2",
"vite-plugin-node-polyfills": "0.21.0"
"vite-plugin-node-polyfills": "0.22.0"
},

@@ -92,0 +91,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc