No matching export in "node-modules-polyfills:buffer" for import "default"
Hello!
I'm not sure if this is an issue with node-modules-polyfills or with the way that the library that I'm trying to use is built, but when I try to use https://github.com/wanseob/soltypes, and build my app, I get the following error:
✘ [ERROR] No matching export in "node-modules-polyfills:buffer" for import "default"
node_modules/soltypes/build/index.es.js:1:7:
1 │ import buffer from 'buffer';
╵ ~~~~~~
I've created a minimal repro here: https://github.com/keithbro-imx/buffer-polyfills-repro
For context, I ran in to this issue when using this library in a Remix app.
Would be great to get your thoughts on where the problem might be and how we might fix it.
Thanks in advance for your help!
The problem is in the polyfill library, unfortunately the library won’t accept PRs and I don’t want to maintain a fork, maybe I should try again searching for an alternative polyfill
You can also give a try to https://github.com/niksy/node-stdlib-browser
If you use yarn v2 or pnpm, you can patch this package using package manager's patch command.
An example for patch:
diff --git a/build/index.es.js b/build/index.es.js
index 8f8e4779c39e381c13ed51ab6d608f1648c70d62..fa37bd4ba1d15417adf31019c7236ee16022b20e 100644
--- a/build/index.es.js
+++ b/build/index.es.js
@@ -1,4 +1,4 @@
-import buffer from 'buffer';
+import { Buffer } from 'buffer';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
@@ -85,12 +85,6 @@ var bn = createCommonjsModule(function (module) {
BN.BN = BN;
BN.wordSize = 26;
- var Buffer;
- try {
- Buffer = buffer.Buffer;
- } catch (e) {
- }
-
BN.isBN = function isBN (num) {
if (num instanceof BN) {
return true;