Skip to content

Commit

Permalink
update how buffer is polyfilled to match approach taken by other pack…
Browse files Browse the repository at this point in the history
…ages in this repo
  • Loading branch information
mistermoe committed Oct 13, 2023
1 parent 29ecd8c commit e886df7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions packages/dids/build/buffer-polyfill.cjs

This file was deleted.

18 changes: 17 additions & 1 deletion packages/dids/build/esbuild-browser-config.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/* 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'],
Expand All @@ -7,7 +22,8 @@ module.exports = {
minify : true,
platform : 'browser',
target : ['chrome101', 'firefox108', 'safari16'],
inject : ['./build/buffer-polyfill.cjs'],
inject : [require.resolve('node-stdlib-browser/helpers/esbuild/shim')],
plugins : [polyfillProviderPlugin(polyfills)],
define : {
'global': 'globalThis',
},
Expand Down
1 change: 1 addition & 0 deletions packages/dids/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"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"
Expand Down

0 comments on commit e886df7

Please sign in to comment.