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
GopherJS relies on vfsgen to embed some files. vfsgen predates Go's embed package, so I wanted to see if it's no longer needed. I tried it out on the embed-natives branch.
It turned out to work well to replace vfsgen with embed for the compiler/natives package; see commit 6078b6b and its commit message for some minor details.
For the compiler/gopherjspkg, I haven't found a way to do it that I'm happy with. It's running into embed's restriction files cannot be embedded from the parent directory, so embedding files in js and nosync directories at the top level can only be done from that directory (which is where the gopherjs command currently sits) or from js and nosync directories themselves (which is where those packages sit). It's possible to make extra copies, or to try to do the embedding in the gopherjs command and provide it to the compiler package as an input (this makes the API of compiler package harder to use). Neither of those options seem better than the current use of vfsgen.
It would be nice to remove reliance on vfsgen completely, but since there doesn't seem to be a clean path to do it, it seems fine to leave gopherjspkg alone for now and at least tackle natives.
Any thoughts? I can open a PR to merge the current version of the embed-natives branch into master.
The text was updated successfully, but these errors were encountered:
This would be great to do, even for compiler/natives only. Having to regenerate the VFS every time is kind of tedious and natives are changed a lot more frequently than the other two packages.
For js and nosync packages, I feel like there must be some kind of solution that doesn't require vfsgen, but I haven't put much though into it. Ideally, it would be addressed by Go Modules where the user's project specifies the dependency on the gopherjs module in go.mod, thus making them both available. But that becomes fragile when the user code doesn't import them directly, using syscall/js API instead.
On a somewhat related note, we could do the same for prelude: move unminified JS code into .js files, embed them, and use something like esbuild or minify to minify it at runtime.
GopherJS relies on vfsgen to embed some files. vfsgen predates Go's embed package, so I wanted to see if it's no longer needed. I tried it out on the
embed-natives
branch.It turned out to work well to replace vfsgen with embed for the
compiler/natives
package; see commit 6078b6b and its commit message for some minor details.For the compiler/gopherjspkg, I haven't found a way to do it that I'm happy with. It's running into embed's restriction files cannot be embedded from the parent directory, so embedding files in
js
andnosync
directories at the top level can only be done from that directory (which is where thegopherjs
command currently sits) or fromjs
andnosync
directories themselves (which is where those packages sit). It's possible to make extra copies, or to try to do the embedding in thegopherjs
command and provide it to thecompiler
package as an input (this makes the API ofcompiler
package harder to use). Neither of those options seem better than the current use ofvfsgen
.It would be nice to remove reliance on vfsgen completely, but since there doesn't seem to be a clean path to do it, it seems fine to leave
gopherjspkg
alone for now and at least tacklenatives
.Any thoughts? I can open a PR to merge the current version of the
embed-natives
branch intomaster
.The text was updated successfully, but these errors were encountered: