-
Notifications
You must be signed in to change notification settings - Fork 142
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
Add bundler annotations to make o1js work in Angular #910
Comments
can you add more context about your build setup / UI framework? it seems parts of snarkyjs that are necessary are not bundled properly |
I am using it in an Angular v15 app which is built using Webpack v5.75.0 |
@ymekuria do you have an idea what could happen here? |
@mitschabaude Do you have any updates regarding this issue? Thanks! |
@directcuteo I haven't looked into it. It seems that Angular / webpack is trying to compile snarkyjs' web bundle and is doing something wrong. Since snarkyjs' bundle should work as is, without transpilation, maybe there's some option that you can give to webpack to ignore snarkyjs when bundling the code, i.e. leave it untouched? |
@mitschabaude can you share a simple HTML + Javascript example of how to use o1js? I can't really figure out what is going on but Angular has a big community so maybe it should be included in the integration tutorial. |
sure! plain html & js example:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>hello-snarkyjs</title>
<script type="importmap">
{ "imports": { "snarkyjs": "./index.js" } }
</script>
<script type="module">
import { Field } from "snarkyjs";
console.log(Field(-1));
</script>
</head>
<body>
<div>Check out the console (F12)</div>
</body>
</html> |
So the point is, it's better if your web framework doesn't try to transform the snarkyjs build output (bundling should be fine; it should know where to resolve it from the package.json "exports" field) |
Your example works, I appreciate! My opinion: |
@directcuteo wow, thanks for investigating! I'll look into this |
hm that's weird.. this is a transformed version of the code here, which has normal function code inside |
Maybe Angular does something clever with |
Yes it's created on the fly from function source code, with |
Do you know if this works with |
I want to include the capabilities of SnarkyJS in my web application. The only code I added that uses snarkyjs is the following one.
This resulted in the error below. The error is coming from a snarkyjs file.
Have I made a mistake?
The text was updated successfully, but these errors were encountered: