Skip to content

fix(compiler): support goscript deploy embed fs#136

Merged
paralin merged 1 commit into
masterfrom
feat/goscript-deploy-compiler-option
May 28, 2026
Merged

fix(compiler): support goscript deploy embed fs#136
paralin merged 1 commit into
masterfrom
feat/goscript-deploy-compiler-option

Conversation

@paralin

@paralin paralin commented May 28, 2026

Copy link
Copy Markdown
Member
  • 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

Copilot AI review requested due to automatic review settings May 28, 2026 20:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a markAsStructValue(new embed.FS(new Map(...))) literal, with helper refactors for pattern cleaning and file reads.
  • Rewrite the gs/embed runtime override to back FS with a file map and implement Open, Read, ReadDir, Stat, Close, and clone(), including supporting embedFile, embedFileInfo, embedDirEntry types and a ValidPath-based validatePath helper.
  • Replace a manual loop with slices.Contains in compiler/build-flags.go and 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>
@paralin paralin force-pushed the feat/goscript-deploy-compiler-option branch from e554bfe to 1425a80 Compare May 28, 2026 20:34
@paralin paralin merged commit 5d33238 into master May 28, 2026
7 checks passed
@paralin paralin deleted the feat/goscript-deploy-compiler-option branch May 28, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants