Comments (7)
@Janaka-Steph 's suggestion solved the issues of using react-srcipts v5.0.1
and react-app-rewired
to polyfill Node core modules' functions as well.
The most important bit is that I had to also add this rule { test: /.wasm$/, type: 'webassembly/async' }.
Also I had an issue with TerserPlugin in prod.
As long as I see webpack.js
under react-srcipts v5.0.1
, the resolution of wasm
file type is not defined.
Once I added the following part into config-override.js
, wasm.memory is undefined
error is solved.
module.exports = (config) => {
config.module.rules = config.module.rules.map((rule) => {
if (rule.oneOf instanceof Array) {
return {
...rule,
oneOf: [{ test: /\.wasm$/, type: 'webassembly/async' }, ...rule.oneOf],
};
}
return rule;
});
from tiny-secp256k1.
@taylorjdawson @classic-k Using Create-React-App v5 I struggled quite a lot to find the right config so I share here my craco.config.js
@junderw Since most people uses React with CRA it would help to document it or add an example app.
const webpack = require('webpack');
module.exports = {
webpack: {
configure: (webpackConfig, { env, paths }) => {
webpackConfig.module.rules = webpackConfig.module.rules.map((rule) => {
if (rule.oneOf instanceof Array) {
return {
...rule,
oneOf: [{ test: /\.wasm$/, type: 'webassembly/async' }, ...rule.oneOf],
};
}
return rule;
});
//
const fallback = webpackConfig.resolve.fallback || {};
Object.assign(fallback, {
fs: false,
buffer: require.resolve('buffer'),
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify'),
});
webpackConfig.resolve.fallback = fallback;
//
webpackConfig.plugins = (webpackConfig.plugins || []).concat([
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
]);
//
webpackConfig.experiments = {
asyncWebAssembly: true,
};
return webpackConfig;
},
},
plugins: [
{
plugin: {
overrideWebpackConfig: ({ webpackConfig }) => {
// Terser
webpackConfig.optimization.minimizer[0].options.minimizer.options.mangle = {
...webpackConfig.optimization.minimizer[0].options.minimizer.options.mangle,
reserved: ['Buffer'],
};
return webpackConfig;
},
},
},
],
};
The most important bit is that I had to also add this rule { test: /\.wasm$/, type: 'webassembly/async' }
.
Also I had an issue with TerserPlugin in prod.
from tiny-secp256k1.
Please see our example react app:
https://github.com/bitcoinjs/tiny-secp256k1/tree/v2.1.2/examples/react-app
from tiny-secp256k1.
@junderw As you can see I already have enabled:
experiments: {
asyncWebAssembly: true
},
And the rest of the settings are essentially the same unless you see that I am missing something in the config.
from tiny-secp256k1.
Please ask on the react issues.
This issue tracker is a place to track issues for tiny-secp256k1, and wasm.memory is a well defined part of the WASM spec, and we have it working in an example react app.
Anything beyond this is an issue with React and your configuration/environment. Which we are not equipped to assist you with.
from tiny-secp256k1.
@junderw As you can see I already have enabled:
experiments: { asyncWebAssembly: true },And the rest of the settings are essentially the same unless you see that I am missing something in the config.
Been on this for 2 days even topLevelAwait did not make wasm.memory defined. Kindly share if you have a workaround thank you
from tiny-secp256k1.
@junderw Since most people uses React with CRA it would help to document it or add an example app.
The react example in the repository currently is building fine.
If you'd like to add some extra tooling that you think is more widely used, pull requests are welcome.
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.