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

esbuild-plugins-node-modules-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
371
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-plugins-node-modules-polyfill - npm Package Compare versions

Comparing version 1.4.0-next.0dd078c.0 to 1.4.0-next.5b26071.0

6

CHANGELOG.md

@@ -5,2 +5,8 @@ # Changelog

# [1.3.2](https://github.com/imranbarbhuiya/esbuild-plugins-node-modules-polyfill/compare/v1.3.1...v1.3.2) - (2023-08-16)
## 🐛 Bug Fixes
- Support `esbuild` 0.19 (#145) ([d5d0412](https://github.com/imranbarbhuiya/esbuild-plugins-node-modules-polyfill/commit/d5d0412b5e52a6e88a13f13668fc9f0fb6f72f18))
# [1.3.1](https://github.com/imranbarbhuiya/esbuild-plugins-node-modules-polyfill/compare/v1.3.0...v1.3.1) - (2023-08-14)

@@ -7,0 +13,0 @@

1

dist/index.d.ts

@@ -10,2 +10,3 @@ import { Plugin } from 'esbuild';

interface NodePolyfillsOptions {
fallback?: 'empty' | 'none';
globals?: {

@@ -12,0 +13,0 @@ Buffer?: boolean;

23

dist/index.js

@@ -118,3 +118,3 @@ 'use strict';

var nodeModulesPolyfillPlugin = /* @__PURE__ */ __name((options = {}) => {
const { globals = {}, modules: modulesOption = module$1.builtinModules, namespace = NAME, name = NAME } = options;
const { globals = {}, modules: modulesOption = module$1.builtinModules, fallback, namespace = NAME, name = NAME } = options;
if (namespace.endsWith("commonjs")) {

@@ -155,20 +155,21 @@ throw new Error(`namespace ${namespace} must not end with commonjs`);

onLoad({ filter: /.*/, namespace: commonjsNamespace }, loader);
const filter = new RegExp(
`^(?:node:)?(?:${Object.keys(modules).filter((moduleName) => module$1.builtinModules.includes(moduleName)).map(escapeRegex).join("|")})$`
);
const bundledModules = fallback === "empty" ? module$1.builtinModules : Object.keys(modules).filter((moduleName) => module$1.builtinModules.includes(moduleName));
const filter = new RegExp(`^(?:node:)?(?:${bundledModules.map(escapeRegex).join("|")})$`);
const resolver = /* @__PURE__ */ __name(async (args) => {
const moduleName = normalizeNodeBuiltinPath(args.path);
const emptyResult = {
namespace: emptyNamespace,
path: args.path,
sideEffects: false
};
const fallbackResult = fallback === "empty" ? emptyResult : void 0;
if (!modules[moduleName]) {
return;
return fallbackResult;
}
if (modules[moduleName] === "empty") {
return {
namespace: emptyNamespace,
path: args.path,
sideEffects: false
};
return emptyResult;
}
const polyfill = await getCachedPolyfillPath(moduleName).catch(() => null);
if (!polyfill) {
return;
return fallbackResult;
}

@@ -175,0 +176,0 @@ const ignoreRequire = args.namespace === commonjsNamespace;

{
"name": "esbuild-plugins-node-modules-polyfill",
"version": "1.4.0-next.0dd078c.0",
"version": "1.4.0-next.5b26071.0",
"description": "Polyfills nodejs builtin modules and globals for the browser.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -23,2 +23,3 @@ <div align="center">

- Optionally injects globals
- Optionally provides empty fallbacks

@@ -69,2 +70,17 @@ ## Install

Optionally provide empty fallbacks for any unpolyfilled or unconfigured modules:
```ts
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
build({
plugins: [nodeModulesPolyfillPlugin({
fallback: 'empty',
modules: {
crypto: true,
}
})],
});
```
Optionally inject globals when detected:

@@ -71,0 +87,0 @@

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