biscuit-auth / biscuit-wasm

WebAssembly wrapper for Biscuit authorization tokens
Apache License 2.0
24 stars 10 forks source link

Import tracing of performance.js file contents #46

Open louisjmorgan opened 8 months ago

louisjmorgan commented 8 months ago

I'm using this library with Next.js to perform biscuit checks within a website, but I'm having difficulties due to the contents of the snippets folder in the distributed module not being successfully traced by Next.js.

e.g. /@biscuit-auth/biscuit-wasm/module/snippets/biscuit-auth-1c48f52e9814dd36/inline0.js

In other words, when I build my website and run it, I receive errors because those files are missing. Next.js doesn't realise correctly notice that the files are necessary during its build process and excludes them from the bundle. I have a workaround where I copy them after bundling as part of the build script, but it's less than optimal to have to do this.

This folder seems to include three separate copies of the performance.js file from the source code. From my understanding, you are able to call performance.now() within the rust wasm code, and this file helps in some way with this. I guess the import tracer is missing this import because it's being done implicitly within wasm somehow.

I recognise that this issue could be a flaw in the Next.js tracing process, but I just wanted to understand why there are three copies of this file in the distributed package files, and why their contents can't be inlined into some other file.

I'm happy to have a go at creating a pr that addresses this issue, but I'd need to understand better how this file is being imported/used in the first place.