You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to use this lib from npm in a React project, I get the error
Failed to compile.
./node_modules/drand-client/verifying.js 16:29
Module parse failed: Unexpected token (16:29)
File was processed with these loaders:
* ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| // TODO: switch to TinyGo when math/big works for smaller wasm file and non-global exports.
| const go = new Go();
> const url = `${import.meta.url.split('/').slice(0, -1).join('/')}/wasm/drand.wasm`;
| let result;
|
Starting with Webpack 5, import.meta.url is resolved to an absolute file URL at build time. Then
// TODO: switch to TinyGo when math/big works for smaller wasm file and non-global exports.constgo=newGo()consturl=`${import.meta.url.split('/').slice(0,-1).join('/')}/wasm/drand.wasm`letresult
becomes
// TODO: switch to TinyGo when math/big works for smaller wasm file and non-global exports.constgo=newGo()consturl=`${"file:///Users/me/projects/drand-client/verifying.js".split('/').slice(0,-1).join('/')}/wasm/drand.wasm`letresult
which is not very helpful. However, a small rewrite to
// TODO: switch to TinyGo when math/big works for smaller wasm file and non-global exports.constgo=newGo()consturl=newURL("./wasm/drand.wasm",import.meta.url)letresult
The client has now been migrated to typescript, so you shouldn't have a problem with create-react-app as there's no wasm binding! Let me know if you have any issues
When trying to use this lib from npm in a React project, I get the error
This is because import.meta.url is not supported in Webpack 4. Webpack 5 support probably will take some more time.
I have no great idea how to solve this, but let's see.
The text was updated successfully, but these errors were encountered: