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
0
Versions
365
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.6.5-next.ed4291e.0 to 1.6.5

58

dist/index.js

@@ -20,4 +20,3 @@ 'use strict';

}) : x)(function(x) {
if (typeof require !== "undefined")
return require.apply(this, arguments);
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');

@@ -55,4 +54,3 @@ });

const cachedPromise = polyfillPathCache.get(normalizedImportPath);
if (cachedPromise)
return cachedPromise;
if (cachedPromise) return cachedPromise;
const promise = polyfillPath(normalizedImportPath);

@@ -71,4 +69,3 @@ polyfillPathCache.set(normalizedImportPath, promise);

const cachedPromise = polyfillContentCache.get(normalizedImportPath);
if (cachedPromise)
return cachedPromise;
if (cachedPromise) return cachedPromise;
const promise = polyfillContentAndTransform(normalizedImportPath);

@@ -118,8 +115,5 @@ polyfillContentCache.set(normalizedImportPath, promise);

} = options;
if (namespace.endsWith("commonjs"))
throw new Error(`namespace ${namespace} must not end with commonjs`);
if (namespace.endsWith("empty"))
throw new Error(`namespace ${namespace} must not end with empty`);
if (namespace.endsWith("error"))
throw new Error(`namespace ${namespace} must not end with error`);
if (namespace.endsWith("commonjs")) throw new Error(`namespace ${namespace} must not end with commonjs`);
if (namespace.endsWith("empty")) throw new Error(`namespace ${namespace} must not end with empty`);
if (namespace.endsWith("error")) throw new Error(`namespace ${namespace} must not end with error`);
const modules = Array.isArray(modulesOption) ? Object.fromEntries(modulesOption.map((mod) => [mod, true])) : modulesOption;

@@ -132,15 +126,12 @@ const commonjsNamespace = `${namespace}-commonjs`;

name,
setup: ({ onLoad, onResolve, onEnd, initialOptions }) => {
// eslint-disable-next-line @typescript-eslint/unbound-method
setup: /* @__PURE__ */ __name(({ onLoad, onResolve, onEnd, initialOptions }) => {
if (shouldDetectErrorModules && initialOptions.write !== false)
throw new Error(`The "write" build option must be set to false when using the "error" polyfill type`);
const root = initialOptions.absWorkingDir ?? process__default.default.cwd();
if (initialOptions.define && !initialOptions.define.global)
initialOptions.define.global = "globalThis";
else if (!initialOptions.define)
initialOptions.define = { global: "globalThis" };
if (initialOptions.define && !initialOptions.define.global) initialOptions.define.global = "globalThis";
else if (!initialOptions.define) initialOptions.define = { global: "globalThis" };
initialOptions.inject = initialOptions.inject ?? [];
if (globals.Buffer)
initialOptions.inject.push(path__default.default.resolve(__dirname, "../globals/Buffer.js"));
if (globals.process)
initialOptions.inject.push(path__default.default.resolve(__dirname, "../globals/process.js"));
if (globals.Buffer) initialOptions.inject.push(path__default.default.resolve(__dirname, "../globals/Buffer.js"));
if (globals.process) initialOptions.inject.push(path__default.default.resolve(__dirname, "../globals/process.js"));
onLoad({ filter: /.*/, namespace: emptyNamespace }, () => ({

@@ -184,19 +175,13 @@ loader: "js",

const browserFieldValue = packageJson?.browser;
if (typeof browserFieldValue === "string")
return;
if (typeof browserFieldValue === "string") return;
const browserFieldValueForModule = browserFieldValue?.[args.path];
if (browserFieldValueForModule === false)
return result.empty;
if (browserFieldValueForModule !== void 0)
return;
if (browserFieldValueForModule === false) return result.empty;
if (browserFieldValueForModule !== void 0) return;
}
const moduleName = normalizeNodeBuiltinPath(args.path);
const polyfillOption = modules[moduleName];
if (!polyfillOption)
return result[fallback];
if (polyfillOption === "error" || polyfillOption === "empty")
return result[polyfillOption];
if (!polyfillOption) return result[fallback];
if (polyfillOption === "error" || polyfillOption === "empty") return result[polyfillOption];
const polyfillPath2 = await getCachedPolyfillPath(moduleName).catch(() => null);
if (!polyfillPath2)
return result[fallback];
if (!polyfillPath2) return result[fallback];
const ignoreRequire = args.namespace === commonjsNamespace;

@@ -212,4 +197,3 @@ const isCommonjs = !ignoreRequire && args.kind === "require-call";

onEnd(async ({ outputFiles = [] }) => {
if (!shouldDetectErrorModules)
return;
if (!shouldDetectErrorModules) return;
const errors = [];

@@ -235,3 +219,3 @@ const { outfile, outExtension = {} } = initialOptions;

});
}
}, "setup")
};

@@ -244,3 +228,3 @@ }, "nodeModulesPolyfillPlugin");

exports.normalizeNodeBuiltinPath = normalizeNodeBuiltinPath;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map
{
"name": "esbuild-plugins-node-modules-polyfill",
"version": "1.6.5-next.ed4291e.0",
"version": "1.6.5",
"description": "Polyfills nodejs builtin modules and globals for the browser.",

@@ -39,21 +39,21 @@ "main": "dist/index.js",

"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/cli": "^19.4.0",
"@commitlint/config-conventional": "^19.2.2",
"@favware/cliff-jumper": "^3.0.3",
"@favware/cliff-jumper": "^4.0.3",
"@favware/npm-deprecate": "^1.0.7",
"@types/node": "^20.12.11",
"@types/node": "^20.15.0",
"cz-conventional-changelog": "^3.3.0",
"esbuild": "^0.21.1",
"esbuild": "^0.23.1",
"eslint": "^8.57.0",
"eslint-config-mahir": "^0.0.43",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"eslint-config-mahir": "^0.0.45",
"husky": "^9.1.4",
"lint-staged": "^15.2.9",
"pinst": "^3.0.0",
"prettier": "^3.2.5",
"tsup": "^8.0.2",
"typescript": "^5.4.5",
"vitest": "^1.6.0"
"prettier": "^3.3.3",
"tsup": "^8.2.4",
"typescript": "^5.5.4",
"vitest": "^2.0.5"
},
"peerDependencies": {
"esbuild": "^0.14.0 || ^0.15.0 || ^0.16.0 || ^0.17.0 || ^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0"
"esbuild": ">=0.14.0 <=0.23.0"
},

@@ -94,3 +94,3 @@ "files": [

},
"packageManager": "yarn@4.2.2"
"packageManager": "yarn@4.4.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