Skip to content

example: add cross-package SharedTree schema consumption example #26522

Open
WillieHabi wants to merge 7 commits intomicrosoft:mainfrom
WillieHabi:cross-package-schema
Open

example: add cross-package SharedTree schema consumption example #26522
WillieHabi wants to merge 7 commits intomicrosoft:mainfrom
WillieHabi:cross-package-schema

Conversation

@WillieHabi
Copy link
Contributor

@WillieHabi WillieHabi commented Feb 23, 2026

Description

Adds a minimal two-package example (schema-provider + schema-consumer) demonstrating how to consume SharedTree schemas across package boundaries using a /schema subpath export whose "types" field points directly to .ts source.

When objectAlpha() schemas are compiled with TypeScript 5.9+ and moduleResolution: "bundler", consumers importing through .d.ts see:

  TS2694: Namespace '"@fluidframework/tree"' has no exported member 'ObjectNodeSchema'.
  TS2322: Type 'typeof AppState' is not assignable to type 'ImplicitFieldSchema'.

The /schema subpath export lets consumers resolve .ts source directly, bypassing the broken .d.ts.

This example serves as proof of viability for SharedTree schema definitions being extracted into separate packages for cross-package consumption.

Reviewer Guidance

  • The example includes two verification scripts in the consumer package that demonstrate the issue:
    • npm run check:schema-import — type-checks importing from the /schema subpath (passes)
    • npm run check:direct-import — type-checks importing from the . export through .d.ts (fails, proving the issue is real)

Copilot AI review requested due to automatic review settings February 23, 2026 22:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new examples/utils/cross-package-schema two-package example intended to demonstrate consuming SharedTree objectAlpha() schemas across package boundaries by using TypeScript customConditions: ["source"] and a "source" export condition to bypass problematic .d.ts path normalization under TS 5.9 + moduleResolution: "bundler".

Changes:

  • Add a new schema-provider package exporting SharedTree schema classes with a "source" export condition and a TS 5.9 “bundler” build mode to reproduce the .d.ts issue.
  • Add a new schema-consumer package that imports the provider’s schemas and demonstrates success/failure with and without customConditions: ["source"].
  • Add documentation and lockfile updates to wire the new example packages into the repo.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds new workspace importers for the provider/consumer example packages and updates a dependency resolution entry.
examples/utils/cross-package-schema/README.md Documents the problem, the "source"-condition workaround, and verification steps.
examples/utils/cross-package-schema/schema-provider/package.json Defines the provider package exports (including "source"), build scripts, and dependencies.
examples/utils/cross-package-schema/schema-provider/tsconfig.json Provider baseline TS config for Node16 resolution output to lib.
examples/utils/cross-package-schema/schema-provider/tsconfig.bundler.json Provider TS 5.9+ bundler-resolution config to reproduce .d.ts normalization.
examples/utils/cross-package-schema/schema-provider/src/schema.ts Declares a small set of objectAlpha()-based schema classes to export.
examples/utils/cross-package-schema/schema-provider/src/index.ts Re-exports the provider schema classes as the public entrypoint.
examples/utils/cross-package-schema/schema-provider/eslint.config.mts Adds local ESLint flat-config wiring consistent with other examples.
examples/utils/cross-package-schema/schema-consumer/package.json Defines the consumer package scripts for the “with source condition” pass and “without source condition” failure demonstration.
examples/utils/cross-package-schema/schema-consumer/tsconfig.json Enables customConditions: ["source"] for the success-path typecheck.
examples/utils/cross-package-schema/schema-consumer/tsconfig.no-source.json Consumer TS config variant that omits customConditions to reproduce the failure.
examples/utils/cross-package-schema/schema-consumer/src/consume.ts Imports provider schemas and constructs a TreeViewConfiguration to validate compatibility.
examples/utils/cross-package-schema/schema-consumer/src/index.ts Re-exports the consumer example entrypoint/types.
examples/utils/cross-package-schema/schema-consumer/eslint.config.mts Adds local ESLint flat-config wiring consistent with other examples.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@github-actions
Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> [email protected] ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> [email protected] serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> [email protected] check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  257789 links
    1822 destination URLs
    2063 URLs ignored
       0 warnings
       0 errors


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