Skip to content

Copy Flutter dep assets/shaders/fonts into .clojuredart/deps stubs#379

Closed
dankinsoid wants to merge 1 commit into
Tensegritics:mainfrom
dankinsoid:fix/copy-flutter-dep-assets
Closed

Copy Flutter dep assets/shaders/fonts into .clojuredart/deps stubs#379
dankinsoid wants to merge 1 commit into
Tensegritics:mainfrom
dankinsoid:fix/copy-flutter-dep-assets

Conversation

@dankinsoid

Copy link
Copy Markdown

Problem

sync-pubspec! mirrors each Flutter dependency into .clojuredart/deps/<sha>/ as a bare pubspec.yaml stub. Flutter's asset bundler reads that stub's flutter: section and resolves the declared assets/shaders/fonts relative to it (asset.dart _parseAssets runs per-package). But the stub only ever contained the pubspec — never the files it references.

So a package that ships shaders or assets — e.g. a widget lib that does

FragmentProgram.fromAsset("packages/my_pkg/shaders/gradient.frag")

gets nothing bundled under packages/my_pkg/… and fails at runtime (missing shader/asset). There's no way to fix this from the consuming app's pubspec, because the shaders live at the dep's package root, not under lib/. Today the only workaround is a post-compile script that copies the files into every stub by hand.

Fix

When materializing a stub, also copy the files the dep declares under flutter: {assets, shaders, fonts} from its source checkout into the stub dir. Source dir is resolved from the already-available coordinate (:deps/root for git / :local/root, or a directory on :paths); jar-only deps are a no-op.

  • Trailing-slash asset entries (directory wildcards) are copied recursively.
  • Map-form asset entries ({path: …, flavors: …}) and fonts: [{fonts: [{asset: …}]}] are handled.
  • No-op when the source dir is unknown or the dep declares no flutter: bundle.

Runs inside the existing deps-to-add loop, so it only fires when a dep is (re)materialized.

Testing

Loaded cljd.build to confirm it compiles, and unit-tested copy-flutter-assets! against a fixture covering shaders, single assets, wildcard directories, fonts, map-form entries, missing-file skip, and nil src/flutter guards — all pass.

🤖 Generated with Claude Code

sync-pubspec! mirrors each Flutter dependency into
.clojuredart/deps/<sha>/ as a bare pubspec.yaml stub. Flutter's asset
bundler then reads that stub's `flutter:` section and resolves the
declared assets/shaders/fonts relative to it — but the stub only ever
contained the pubspec, never the files it references. As a result a
package that ships shaders or assets (e.g. FragmentProgram.fromAsset
"packages/<pkg>/shaders/x.frag") silently gets nothing bundled and
fails at runtime.

Copy the files declared under flutter: {assets, shaders, fonts} from the
dep's source checkout (:deps/root, :local/root, or a classpath dir) into
the stub when materializing it. Trailing-slash asset entries are copied
recursively; map-form asset entries ({path: ...}) and font asset lists
are handled. No-op for jar-only deps or deps that declare no bundle.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dankinsoid

Copy link
Copy Markdown
Author

Duplicate of #378 — consolidated there (that one keeps find-pubspec's search precise for multi-path deps and carries the fonts handling from here). Closing this one.

@dankinsoid dankinsoid closed this Jul 5, 2026
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.

1 participant