Skip to content

fix(tree-view-table-layout): support Directus 12#319

Open
seltzdesign wants to merge 1 commit into
directus-labs:mainfrom
seltzdesign:fix/directus-12-support
Open

fix(tree-view-table-layout): support Directus 12#319
seltzdesign wants to merge 1 commit into
directus-labs:mainfrom
seltzdesign:fix/directus-12-support

Conversation

@seltzdesign

Copy link
Copy Markdown

Problem

The Tree View Table layout does not work on Directus 12. The layout never appears in the Layout picker, and because the failure happens while the extension bundle is being evaluated, none of the layout registers — there is no partial degradation, the whole extension is dead on a v12 instance.

Root cause

Two independent things combine here:

  1. Host range excludes ^12. package.json declares directus:host as ^10.10.0 || ^11.0.0, so even once the code loads, Directus 12 considers the extension incompatible and filters it out of the picker.

  2. Two bare specifiers are not in the Directus 12 app import map. The built code imports:

    • useSync from @directus/composables
    • isSystemCollection from @directus/system-data

    Directus 12's app bundle does not expose either of those packages in the import map it hands to extensions. An unresolvable bare specifier throws at module-evaluation time, and since these imports sit at the top of files that are pulled into the layout's entry graph, the throw takes the entire extension bundle down with it. That is why bumping the host range alone is not enough — the layout still would not load.

Fix

  • Bump directus:host to ^10.10.0 || ^11.0.0 || ^12.0.0.
  • Import useSync from @directus/extensions-sdk instead of @directus/composables. The SDK re-exports useSync, and the SDK is present in the v12 import map, so the specifier resolves. Behaviour is identical.
  • Inline isSystemCollection in core-clones/utils/get-route.ts as the documented system-prefix check (collection.startsWith('directus_')) rather than importing @directus/system-data. This is the same logic that package ships, with no runtime dependency on a package the app does not provide to extensions.

Both source files carry a short comment explaining why the import was changed, so a future contributor does not innocently "clean up" the inline back into a bare import and re-break v12.

Verification

  • Built the package from source and loaded it as a local extension on a Directus 12 instance: the layout now appears in the Layout picker and registers cleanly (no console error during bundle evaluation).
  • Confirmed the layout still loads on Directus 11 (the SDK re-export and the inlined helper are both available there too), so this is additive, not a v12-only swap.
  • isSystemCollection behaviour spot-checked: directus_users etc. still route to their system pages, non-system collections fall through unchanged.

No behavioural change to the tree itself — this PR is purely about making the existing layout load on Directus 12 (and stay loading on 10/11).

The layout never appears in the picker on Directus 12. Two causes: package host range
excludes ^12, and the built code imports two bare specifiers absent from Directus 12's app
import map (useSync from @directus/composables, isSystemCollection from @directus/system-data).
An unresolvable specifier crashes the whole extension bundle at runtime, so no layout registers.

- bump host to include ^12.0.0
- import useSync from @directus/extensions-sdk (re-exports it)
- inline isSystemCollection as the documented directus_ prefix check
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