fix(compiler): support goscript deploy embed fs#136
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Enables real embed.FS support end-to-end so the GoScript compiler/runtime can lower //go:embed declarations targeting embed.FS (including directory and glob patterns) and serve the embedded files through the standard io/fs APIs at runtime. Also tidies a build-flag helper.
Changes:
- Add compiler lowering for
embed.FS(directory walks, globs,all:prefix) emitting amarkAsStructValue(new embed.FS(new Map(...)))literal, with helper refactors for pattern cleaning and file reads. - Rewrite the
gs/embedruntime override to backFSwith a file map and implementOpen,Read,ReadDir,Stat,Close, andclone(), including supportingembedFile,embedFileInfo,embedDirEntrytypes and aValidPath-basedvalidatePathhelper. - Replace a manual loop with
slices.Containsincompiler/build-flags.goand add Go+Vitest tests for the new behaviors.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| compiler/build-flags.go | Minor refactor to use slices.Contains when checking for an existing build tag. |
| compiler/lowering.go | Adds embed.FS lowering plus directory/glob expansion and refactors go:embed pattern/read helpers. |
| compiler/skeleton_test.go | New TestCompilePackagesEmbedsFS exercising direct, directory, and glob go:embed patterns into embed.FS. |
| gs/embed/index.ts | Implements a functional embed.FS runtime with Open/Read/ReadDir/Stat/Close and clone() plus supporting internal classes/helpers. |
| gs/embed/index.test.ts | Vitest coverage for cloning, io/fs.ReadFile/ReadDir/Stat, and direct Open/Read/ReadDir iteration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Christian Stewart <christian@aperture.us>
e554bfe to
1425a80
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
preserve GoScript CLI/package build flags through compiler package graph loading
add embed.FS compiler/runtime support needed by Bldr deploy bundles
keep generated deploy assets addressable for the Spacewave GoScript compiler mode
go test ./compiler ./cmd/goscript -run "TestCompilePackagesUsesEmbedOverride|TestCompilePackagesEmbedsFS|TestCompileCommand.*BuildFlags|TestPackageGraphHonorsBuildFlags"
bun test gs/embed/index.test.ts
git diff --check