fix(tree-view-table-layout): support Directus 12#319
Open
seltzdesign wants to merge 1 commit into
Open
Conversation
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
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.
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:
Host range excludes
^12.package.jsondeclaresdirectus:hostas^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.Two bare specifiers are not in the Directus 12 app import map. The built code imports:
useSyncfrom@directus/composablesisSystemCollectionfrom@directus/system-dataDirectus 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
directus:hostto^10.10.0 || ^11.0.0 || ^12.0.0.useSyncfrom@directus/extensions-sdkinstead of@directus/composables. The SDK re-exportsuseSync, and the SDK is present in the v12 import map, so the specifier resolves. Behaviour is identical.isSystemCollectionincore-clones/utils/get-route.tsas 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
isSystemCollectionbehaviour spot-checked:directus_usersetc. 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).