From ad36776795348a32941d2b4e833ed00da05a476f Mon Sep 17 00:00:00 2001 From: dtfiedler Date: Fri, 23 Feb 2024 17:03:37 -0700 Subject: [PATCH] fix(build): add setImmediate polyfill for web only --- bundle.mjs | 8 +------- examples/node/index.cjs | 2 +- examples/node/index.mjs | 2 +- package.json | 1 + src/web/index.ts | 2 ++ yarn.lock | 2 +- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/bundle.mjs b/bundle.mjs index a2d5f435..0f8859d6 100644 --- a/bundle.mjs +++ b/bundle.mjs @@ -10,13 +10,7 @@ const bundle = () => { target: ['esnext'], format: 'esm', globalName: 'ar.io', - plugins: [ - polyfillNode({ - polyfills: { - crypto: true, - }, - }), - ], + plugins: [polyfillNode()], tsconfig: './tsconfig.web.json', outfile: './bundles/web.bundle.min.js', }) diff --git a/examples/node/index.cjs b/examples/node/index.cjs index 64f46b4b..fe7df9d0 100644 --- a/examples/node/index.cjs +++ b/examples/node/index.cjs @@ -1,4 +1,4 @@ -const { ArIO } = require('../../lib/cjs'); +const { ArIO } = require('../../../lib/cjs/node/index.js'); (async () => { const arIO = new ArIO({}); diff --git a/examples/node/index.mjs b/examples/node/index.mjs index 33f902f9..848c459f 100644 --- a/examples/node/index.mjs +++ b/examples/node/index.mjs @@ -1,4 +1,4 @@ -import { ArIO } from '../../lib/esm/index.js'; +import { ArIO } from '../../lib/esm/node/index.js'; (async () => { const arIO = new ArIO({}); diff --git a/package.json b/package.json index 8f00a216..89a97177 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,7 @@ "prettier": "^3.0.2", "rimraf": "^5.0.1", "semantic-release": "^21.0.7", + "setimmediate": "^1.0.5", "sinon": "^15.2.0", "ts-jest": "^29.1.2", "ts-node": "^10.9.1", diff --git a/src/web/index.ts b/src/web/index.ts index a4c6270c..e4dd9456 100644 --- a/src/web/index.ts +++ b/src/web/index.ts @@ -14,6 +14,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +// polyfill for setImmediate +import 'setimmediate'; export * from '../types/index.js'; export * from '../common/index.js'; diff --git a/yarn.lock b/yarn.lock index 1d869f7e..9a18df76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7610,7 +7610,7 @@ set-function-name@^2.0.1: functions-have-names "^1.2.3" has-property-descriptors "^1.0.0" -setimmediate@^1.0.4: +setimmediate@^1.0.4, setimmediate@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==