Skip to content

Use app blocks as theme graph entry points#1211

Draft
graygilmore wants to merge 2 commits into
mainfrom
gg-tae-orphaned-snippets
Draft

Use app blocks as theme graph entry points#1211
graygilmore wants to merge 2 commits into
mainfrom
gg-tae-orphaned-snippets

Conversation

@graygilmore
Copy link
Copy Markdown
Contributor

@graygilmore graygilmore commented May 22, 2026

Summary

Fixes a false positive where OrphanedSnippet reported snippets in theme app extensions as unused even when they were rendered by app blocks.

Theme app extension blocks are rendered by Shopify directly, without an in-repo template or section parent. The theme graph only used templates and sections as entrypoints, so the graph never traversed app blocks and never recorded their {% render %} references.

What changed

  • passes the theme-check config context into theme graph construction from the Node runner and language server
  • treats blocks/*.liquid as graph entrypoints only in context: app
  • leaves normal theme blocks on the existing reachability path so genuinely unused theme block trees can still be reported
  • adds regression coverage for a TAE app block rendering a snippet
  • adds a patch changeset for the affected packages

Context

This became visible in shopify app dev after the CLI picked up theme-check-node 3.25.0. OrphanedSnippet existed before then, but the Node runner did not provide getReferences, so the check no-op'd in CLI mode. Once getReferences was wired through for other cross-file checks, the existing graph entrypoint gap started surfacing as orphaned snippet warnings.

Tests

pnpm --filter @shopify/theme-graph build
pnpm --filter @shopify/theme-check-node build
pnpm --filter @shopify/theme-language-server-common build
pnpm --filter @shopify/theme-graph type-check
pnpm --filter @shopify/theme-check-node type-check
pnpm --filter @shopify/theme-language-server-common type-check
pnpm vitest run packages/theme-graph/src/graph/build.spec.ts packages/theme-check-node/src/index.spec.ts --reporter=verbose

@graygilmore graygilmore force-pushed the gg-tae-orphaned-snippets branch 4 times, most recently from 0767699 to 65730e7 Compare May 22, 2026 23:48
Theme graph construction needs to know whether it is running against a
full theme or a theme app extension before it can vary entrypoint
semantics. Add an optional mode to the graph dependencies and pass the
resolved config context from the Node runner and language server.

Keep the graph defaulting to theme mode so existing callers preserve the
same behavior unless they pass app context explicitly. Add the missing
TypeScript path for theme-check-node so type-checks use the local graph
source while developing this cross-package boundary.
Theme app extension blocks are rendered by Shopify without an in-repo
template or section parent. Use app blocks as additional entry points in
app mode so snippets rendered from app blocks get recorded references.

Keep theme blocks on the existing schema-driven reachability path so
unused theme block trees can still be reported as dead code.
@graygilmore graygilmore force-pushed the gg-tae-orphaned-snippets branch from 65730e7 to 8e63afa Compare May 22, 2026 23:58
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