Comments (8)
Im using this in the browser in a simple Create React App application.
The versions I'm using:
"tiny-secp256k1": "^2.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hook-form": "^7.27.1",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.0",
webpack: 5.69.1
webpack-cli: 4.9.2
webpack-dev-server 4.7.4
Im also using Craco to overrride the default React CRA webpack configs whith the following configuration in craco.config.js:
module.exports = {
webpack: {
configure: {
resolve: {
fallback: {
process: require.resolve("process/browser"),
zlib: require.resolve("browserify-zlib"),
stream: require.resolve("stream-browserify"),
util: require.resolve("util"),
buffer: require.resolve("buffer"),
asset: require.resolve("assert")
},
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
process: "process/browser",
}),
],
},
},
};
from tiny-secp256k1.
See this comment: bitcoinjs/bitcoinjs-lib#1777 (comment)
This is not an issue with bitcoinjs-lib or tiny-secp256k1.
This is an issue with your config or react / webpack itself. Since we have a working example using react and webpack, it's probably because you lack the asyncWebAssembly
option in your webpack config.
from tiny-secp256k1.
I would say this is an issue with tiny-secp256k1
because the lib is using NodeJS modules so it cannot work out-of-the box in the browser. And now that Webpack 5 has decided to remove NodeJS polyfills it becomes a pain to install it.
from tiny-secp256k1.
Where does tiny-secp256k1 use NodeJS modules? (That isn't inside a file that is specified for NodeJS environment only in the package.json exports)
from tiny-secp256k1.
I didn't dig where modules are used but here https://github.com/bitcoinjs/tiny-secp256k1/blob/master/examples/react-app/webpack.config.js#L41-L44 if you have to polyfill it means that they are used.
from tiny-secp256k1.
https://github.com/bitcoinjs/tiny-secp256k1/blob/master/examples/react-app/index.js
The example app uses Buffer. This is not the library.
from tiny-secp256k1.
I have removed NodeJS dependencies in the example app to prove that the main library (which I have not touched) does not use NodeJS.
See #82
from tiny-secp256k1.
Ok so the error in the issue description Uncaught TypeError: Cannot read properties of undefined (reading 'buffer')
is only due to lack of asyncWebAssembly
property. I misinterpreted the error message. I still have to eject the webpack config in create-react-app to add that property but it's not an issue with the lib. Thank you for you quick reply.
from tiny-secp256k1.
Related Issues (20)
- Buffer is not defined HOT 1
- There are 2 test vectors for pointCompress which are not correct HOT 2
- Secp256k1 signature issue with messages > curve_order HOT 2
- Is there a fallback build instead of wasm? HOT 4
- Does this implement deterministic k generation HOT 2
- remove dependancy from `window` object on browser
- no such file or directory node_modules/tiny-secp256k1/lib/secp256k1.wasm HOT 7
- Uncaught TypeError: Cannot read properties of undefined (reading 'buffer') HOT 2
- Discrepancy in signSchnorr output when using zero-filled Buffer versus no Buffer HOT 3
- Cant figure equivalents to `bcrypto.secp256k1` calls HOT 5
- Nestjs ERROR Error: ENOENT: no such file or directory, open '/var/task/node_modules/tiny-secp256k1/lib/secp256k1.wasm' HOT 2
- Two times speed regression between `2.2.2` and `2.2.3` HOT 3
- Docker Build Failure HOT 2
- import tiny-secp256k1 in browser causes TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute HOT 2
- Cannot run react-app example HOT 2
- After bumping ReactNative project from 1.1.6 to 2.0.0 builds for Android fail HOT 6
- Wrong path when bundling tiny-secp256k1 with Electron HOT 1
- tiny-secp compilation in swift and java HOT 2
- Bug when using browserify HOT 3
- Pure-js backport of `xOnlyPointFromPoint()`..? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tiny-secp256k1.