From 1b876efb023e54a559de5a28d77c67643e68fef1 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 29 Sep 2021 10:40:07 +0100 Subject: [PATCH 1/2] fix: access process from globalThis Fixes webpack error: ``` Module not found: Error: Can't resolve 'process/browser' in /path/... ``` --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 7fac33e..2b96c16 100644 --- a/src/index.js +++ b/src/index.js @@ -244,7 +244,7 @@ export class BlockstoreDatastoreAdapter extends BaseBlockstore { // process.nextTick runs on the microtask queue, setImmediate runs on the next // event loop iteration so is slower. Use process.nextTick if it is available. - const runner = process && process.nextTick ? process.nextTick : setImmediate + const runner = globalThis.process && globalThis.process.nextTick ? globalThis.process.nextTick : setImmediate runner(async () => { try { From d9aab6f1b9f6bbf51572a89c55710ff20a71f5b8 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 29 Sep 2021 10:47:58 +0100 Subject: [PATCH 2/2] chore: only use setimmediate if available --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 2b96c16..1e01908 100644 --- a/src/index.js +++ b/src/index.js @@ -244,7 +244,7 @@ export class BlockstoreDatastoreAdapter extends BaseBlockstore { // process.nextTick runs on the microtask queue, setImmediate runs on the next // event loop iteration so is slower. Use process.nextTick if it is available. - const runner = globalThis.process && globalThis.process.nextTick ? globalThis.process.nextTick : setImmediate + const runner = globalThis.process && globalThis.process.nextTick ? globalThis.process.nextTick : (globalThis.setImmediate || globalThis.setTimeout) runner(async () => { try {