From e57a79adf99d78d6cef1755932308d39ffbc469b Mon Sep 17 00:00:00 2001 From: Moe Jangda Date: Fri, 13 Oct 2023 17:26:24 -0500 Subject: [PATCH] Revert "update how buffer is polyfilled to match approach taken by other packages in this repo" This reverts commit e886df7be7cc8ce0587ac6be1e51e06e4b36c3f6. --- package-lock.json | 1 - packages/dids/build/buffer-polyfill.cjs | 3 +++ packages/dids/build/esbuild-browser-config.cjs | 18 +----------------- packages/dids/package.json | 1 - 4 files changed, 4 insertions(+), 19 deletions(-) create mode 100644 packages/dids/build/buffer-polyfill.cjs diff --git a/package-lock.json b/package-lock.json index e6267fa5d..c5803604c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10795,7 +10795,6 @@ "eslint": "8.47.0", "karma": "6.4.1", "mocha": "10.2.0", - "node-stdlib-browser": "1.2.0", "rimraf": "4.4.0", "sinon": "15.0.2", "typescript": "5.1.6" diff --git a/packages/dids/build/buffer-polyfill.cjs b/packages/dids/build/buffer-polyfill.cjs new file mode 100644 index 000000000..8bd6256c2 --- /dev/null +++ b/packages/dids/build/buffer-polyfill.cjs @@ -0,0 +1,3 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +const { Buffer } = require('buffer'); +global.Buffer = Buffer; diff --git a/packages/dids/build/esbuild-browser-config.cjs b/packages/dids/build/esbuild-browser-config.cjs index bbd62fbcb..599cae57b 100644 --- a/packages/dids/build/esbuild-browser-config.cjs +++ b/packages/dids/build/esbuild-browser-config.cjs @@ -1,18 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const polyfillProviderPlugin = require('node-stdlib-browser/helpers/esbuild/plugin'); -const stdLibBrowser = require('node-stdlib-browser'); - -const requiredPolyfills = new Set(['buffer']); - -// populate object containing lib -> polyfill path -const polyfills = {}; -for (let lib in stdLibBrowser) { - if (requiredPolyfills.has(lib)) { - const polyfill = stdLibBrowser[lib]; - polyfills[lib] = polyfill; - } -} - /** @type {import('esbuild').BuildOptions} */ module.exports = { entryPoints : ['./src/index.ts'], @@ -22,8 +7,7 @@ module.exports = { minify : true, platform : 'browser', target : ['chrome101', 'firefox108', 'safari16'], - inject : [require.resolve('node-stdlib-browser/helpers/esbuild/shim')], - plugins : [polyfillProviderPlugin(polyfills)], + inject : ['./build/buffer-polyfill.cjs'], define : { 'global': 'globalThis', }, diff --git a/packages/dids/package.json b/packages/dids/package.json index 2fd318563..cac90d14c 100644 --- a/packages/dids/package.json +++ b/packages/dids/package.json @@ -102,7 +102,6 @@ "eslint": "8.47.0", "karma": "6.4.1", "mocha": "10.2.0", - "node-stdlib-browser": "1.2.0", "rimraf": "4.4.0", "sinon": "15.0.2", "typescript": "5.1.6"