Comments (14)
I updated Yoroi to Webpack 5 a few months ago and didn't have any issues at the time. Maybe this PR is useful to you: Emurgo/yoroi-frontend#1929
from cardano-serialization-lib.
Any solution to "Cannot find module 'util'" ? I've tried to add a polyfill and nothing.
from cardano-serialization-lib.
- You may need a polyfill for text-decoder. This is a common issue with WASM on older platforms
- Haven't heard of this before. Probably it's caused by a different issue
- Historically WASM modules have to be imported asynchronously. Webpack 5 added support for synchronous loading of WASM if you set an experimental flag for it though. Typescript also has better support for WASM than Babel I think.
from cardano-serialization-lib.
Having a similar issue with Webpack 5. Is there an example of how to make this work? A similar issue can be found here for another package:
Any help appreciated.
from cardano-serialization-lib.
Took a look at this, I think the difference here is your use babel-node when calling different npm run functions and we just use webpack. The result is that babel-loader does not polyfill node_modules because it is ignored in most configs.
Here is our package.json file:
"scripts": {
"build-main": "cross-env NODE_ENV=production webpack --config webpack.main.prod.config.js",
"build-renderer": "cross-env NODE_ENV=production webpack --config webpack.renderer.prod.config.js",
"build": "npm run build-main && npm run build-renderer",
"start-renderer-dev": "webpack serve --config webpack.renderer.dev.config.js",
"start-main-dev": "webpack --config webpack.main.config.js && electron ./dist/main.js",
"start-dev": "cross-env START_HOT=1 ELECTRON_IS_DEV=1 npm run start-renderer-dev",
"start-prod": "cross-env START_HOT=1 ELECTRON_IS_DEV=0 npm run start",
...
Here is our dev config for webpack:
{
test: /\.js$/,
exclude: /node_modules\/(?!(bech32|ripple-lib))/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ["@babel/plugin-syntax-dynamic-import"]
}
}
},
I think this is the issue. Also, Polkadot folks seem to use wasm with no issue at least that I can see.
https://www.npmjs.com/package/@polkadot/wasm-crypto
I took a look at this and would be curious to see what the difference is in packaging is.
from cardano-serialization-lib.
Every WASM project has at least two different builds:
- NodeJS build
- Browser build
If you're trying to connect from Webpack, you need to use the browser build, but it sounds like you may be trying to use the nodejs build. Can you make sure you're using https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-browser when building for a web environment?
from cardano-serialization-lib.
hi hi. Actually we use webpack to package an electron app. The module actually sits in the main node.js process not the render process. Webpack just happens to package the whole thing up.
from cardano-serialization-lib.
The new 7.1.0 release includes a fix for Webpack 5 builds that may help you if you're still having issues
from cardano-serialization-lib.
Not sure if anyone here is using Nextjs, but I'm having the same issue where it can't find the util
module. When I comment out the line, or add a polyfill, I get a new error
Error: ENOENT: no such file or directory, open '/Users/blakebrown/Documents/Code/wagmi/.next/server/cardano_serialization_lib_bg.wasm
Has anyone been able to successfully load this library in Next?
from cardano-serialization-lib.
Hi,
I've been hit with this same error (as in issue 1 in the first post) while trying to bundle my app:
I'm using "@emurgo/cardano-serialization-lib-nodejs": "^11.2.1"
. Is there any way to resolve this, and actually use the imported modules from the package?
I am trying to initiate a transaction from a connected wallet in the cardano browser extension
Please help.
from cardano-serialization-lib.
@amnambiar the error is telling you what to do. You have to specify the resolve.fallback
fields inside your webpack config. If you're using a build system that is hiding the webpack config from you, you may have to "eject" to modify it
Also note you're using the nodejs bindings. If you're using a browser extension, you may be interested in the browser bindings instead (separate NPM package)
from cardano-serialization-lib.
@SebastienGllmt
A bit of a context - I'm working on a react web application, and trying to interact with cardano wallets from JS. I've created the app using create-react-app; and the app bundles using npm.
Do I still need to use browser bindings?
from cardano-serialization-lib.
@amnambiar yeah, most likely you want the browser bindings if you're not depending on any nodejs scripts for your build process. This library is more low-level, so if you want a more high-level library for interacting with Cardano I suggest using Lucid
from cardano-serialization-lib.
Thanks @SebastienGllmt ,
Replaced @emurgo/cardano-serialization-lib-nodejs with @emurgo/cardano-serialization-lib-asmjs and this was resolved!
from cardano-serialization-lib.
Related Issues (20)
- Conway [12.0.0-alpha.4] - New certificates .kind() return in correct value. HOT 3
- Trying to find a Rust Crate/Functionality Demonstration of COSESign1 and COSEKey HOT 2
- `BigNumFinalization.unregister is not a function` when running CSL built with `WASM_BINDGEN_WEAKREF` HOT 1
- Help please? Private Keys in code?
- Help please? Private Keys in code? HOT 1
- DatumSource struct makes the script input to be reference input
- Unable to deregistration stake raw transaction HOT 2
- Finding a Go library that can perform basic data signature validation. HOT 2
- Distribute as a single NPM package HOT 1
- Make JSON encoding total & standardize it HOT 11
- RewardAddress method naming: why payment_cred() and not stake_cred()? HOT 1
- `RewardAddress`, `BaseAddress`, `EnterpriseAddress`, `PointerAddress` have no getter for network id HOT 3
- OutputDatum is not used in TransactionOutput HOT 1
- TransactionMetadatum.as_* methods: wrong type annotation HOT 1
- Fee calculation mismatch with conway certificates HOT 4
- `add_change_if_needed` multiple change outputs on many assets causes Error from node `OutputTooSmallUTxO` HOT 3
- plutus script witness deserialization issue HOT 8
- Add inputs with assets. HOT 1
- Witness Set Serialization differs between v11.5 and v12a18 HOT 3
- when a transaction has 2 inputs the fees are miscalculated, and uses 1 ADA as fee 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 cardano-serialization-lib.