-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught TypeError: soljson.cwrap is not a function #226
Comments
Hi, Then at first hit of var solc = require('solc') got the error
I'm running in a dev environment, using webpack-dev-server. Hope you got enough informations. |
node v6.11.2 |
Seems related to #31 but not sure if same reasons. |
So, is it fixed ? |
For the One Using Electron js . |
I have a solution, but it is a little complicated... My environment is Node.v13.11.0, Create-React-App(ejected), Chrome. I encountered both this problem and the problem in issue #456. When I directly use
Follow by the solution in ##456, I tried to use Web-Worker and Worker-Loader (React), to move the whole solc module into the worker thread. The following two cases show the difference between a main thread import & worker thread import. Case1: index.html
App.js
Output
Case 2: App.js (worker-loader installed).
solc.worker.js
Output
Compare two output messages, we can find that the module required by main thread was somehow incompleted. I guess it is caused by some restriction (such as file size limit in main thread) in WebASM. So, here is my solution: Step1. Use Web-Worker to load soljson. The soljson module was store in object
Step2. The webpack.config.js
src/index.js
The webpack generate file
Output
If you don't want to wast your time installing webpack, here is my
|
BUMP. This is preventing my inline browser ethereum toolset from working in chrome: soljson-v0.6.9+commit.3e3065ac.js:1 failed to compile wasm module: RangeError: WebAssembly.Compile is disallowed on the main thread, if the buffer size is larger than 4KB. Use WebAssembly.compile, or compile on a worker thread. It appears that soljson-v0.6.9 is incorrectly loading webassembly on the main thread instead of a worker thread. I'm not even sure what that means, but it's breaking things for me downstream now. |
If you are using react, you need to use web worker. You can use https://github.com/rexdavinci/browser-solidity-compiler to get this done. It comes with typescript support as well. |
Hello. friends.
I am trying to import solc js in react mobx project.
But when use code "var solc = require('solc')", i am getting "Type error soljson.cwrap is not function".
If anyone know the way to fix or has sample, Please teach me.
The text was updated successfully, but these errors were encountered: