refactor(core-utils): Deprecate assert for external use - #28080
refactor(core-utils): Deprecate assert for external use#28080Joshua Smithrud (Josmithr) wants to merge 15 commits into
assert for external use#28080Conversation
|
Hi! Thank you for opening this PR. Want me to review it? Based on the diff (434 lines, 41 files), I've queued these reviewers:
How this works
|
Co-authored-by: Joshua Smithrud <54606601+Josmithr@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR deprecates the external assert export from @fluidframework/core-utils while preserving a non-deprecated assertion API for Fluid-internal consumers via a dedicated @fluidframework/core-utils/internal entry point. It also updates examples to stop relying on the deprecated external assert.
Changes:
- Split
@fluidframework/core-utilsinto shared (main.ts) plus external (index.ts) vs internal (internal.ts) entry points, exporting non-deprecatedassertonly from/internal. - Introduce
assertInternal()and route the deprecated externalassert()implementation through it. - Remove
@fluidframework/core-utilsusage from multiple examples (replace with explicit runtime checks / throws) and update lockfile accordingly.
Reviewed changes
Copilot reviewed 42 out of 43 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Removes @fluidframework/core-utils from several example importers after usage cleanup |
| packages/common/core-utils/src/timer.ts | Switches local usage to assertInternal to avoid deprecated symbol internally |
| packages/common/core-utils/src/math.ts | Switches local usage to assertInternal to avoid deprecated symbol internally |
| packages/common/core-utils/src/main.ts | New shared barrel for exports common to external + internal entry points (omits assert) |
| packages/common/core-utils/src/internal.ts | New internal entry point barrel that re-exports shared API + internal assert |
| packages/common/core-utils/src/index.ts | External entry point barrel now re-exports shared API + deprecated external assert |
| packages/common/core-utils/src/assert.ts | Adds assertInternal; deprecates external assert; routes assert through assertInternal |
| packages/common/core-utils/package.json | Updates ./internal export map to point at internal.{js,d.ts} outputs |
| packages/common/core-utils/DEV.md | Documents the new entry point structure and rationale |
| packages/common/core-utils/api-report/core-utils.legacy.beta.api.md | API report updates assert to include @deprecated |
| packages/common/core-utils/api-extractor/api-extractor-lint-bundle.json | Lint-bundle now uses lib/internal.d.ts as the entry point |
| examples/view-integration/external-views/src/container/diceRoller/diceRoller.ts | Replaces deprecated assert usage with explicit runtime validation + throw |
| examples/view-integration/external-views/package.json | Drops unused @fluidframework/core-utils dependency |
| examples/view-integration/container-views/src/container/diceRoller/diceRoller.ts | Replaces deprecated assert usage with explicit runtime validation + throw |
| examples/view-integration/container-views/package.json | Drops unused @fluidframework/core-utils dependency |
| examples/version-migration/live-schema-upgrade/src/modelVersion2/diceCounter.ts | Replaces deprecated assert checks with explicit throws |
| examples/version-migration/live-schema-upgrade/src/app.ts | Replaces deprecated assert checks with explicit throws |
| examples/version-migration/live-schema-upgrade/package.json | Drops unused @fluidframework/core-utils dependency |
| examples/utils/migration-tools/src/migrator/migrator.ts | Replaces deprecated assert checks with explicit throws |
| examples/utils/migration-tools/src/migrationTool/migrationTool.ts | Replaces deprecated assert checks with explicit throws |
| examples/utils/migration-tools/package.json | Drops unused @fluidframework/core-utils dependency |
| examples/utils/example-utils/src/migrator/sameContainerMigrator.ts | Replaces deprecated assert checks with explicit throws |
| examples/utils/example-utils/src/migrationTool/sameContainerMigrationTool.ts | Replaces deprecated assert checks with explicit throws |
| examples/utils/example-utils/package.json | Drops unused @fluidframework/core-utils dependency |
| examples/data-objects/webflow/src/html/formatters.ts | Replaces deprecated assert check with explicit throw |
| examples/data-objects/webflow/src/document/index.ts | Replaces deprecated assert check with explicit throw |
| examples/data-objects/webflow/package.json | Drops unused @fluidframework/core-utils dependency |
| examples/data-objects/table-document/src/interception/tableWithInterception.ts | Replaces deprecated assert checks with explicit throws |
| examples/data-objects/table-document/src/cellrange.ts | Replaces deprecated assert check with explicit throw |
| examples/data-objects/table-document/package.json | Drops unused @fluidframework/core-utils dependency |
| examples/data-objects/smde/src/smde.ts | Replaces deprecated assert check with explicit throw |
| examples/data-objects/smde/package.json | Drops unused @fluidframework/core-utils dependency |
| examples/data-objects/prosemirror/src/fluidCollabManager.ts | Replaces deprecated assert check with explicit throw |
| examples/data-objects/prosemirror/src/fluidBridge.ts | Replaces deprecated assert checks with explicit throws |
| examples/data-objects/prosemirror/package.json | Drops unused @fluidframework/core-utils dependency |
| examples/apps/task-selection/src/taskManagerDiceRoller.ts | Replaces deprecated assert checks with explicit throws |
| examples/apps/task-selection/src/oldestClientDiceRoller.ts | Replaces deprecated assert checks with explicit throws |
| examples/apps/task-selection/package.json | Drops unused @fluidframework/core-utils dependency |
| examples/apps/staging/src/container/groceryList/groceryList.ts | Replaces deprecated assert check with explicit throw |
| examples/apps/staging/package.json | Drops unused @fluidframework/core-utils dependency |
| examples/apps/presence-tracker/src/datastoreSupport.ts | Replaces deprecated assert checks with explicit throws (including a TypeError for type mismatch) |
| examples/apps/presence-tracker/package.json | Drops unused @fluidframework/core-utils dependency |
| .changeset/tricky-rules-fly.md | Adds a changeset documenting the deprecation (minor bump, deprecation section) |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
I think the reason I use api.ts in telemetry-utils was to preserve the history and be able to see the actual change. But, yeah, it means touching more places in package.json.
No need to change.
| // This package contains candidate shipping tools, not only example code, so it can use Fluid's internal assertion utility. | ||
| "@fluidframework/core-utils/internal", |
There was a problem hiding this comment.
Matt Rakow (@ChumpChief), sounds like an experiment and not an example.
|
🔗 Found some broken links! 💔 Run a link check locally to find them. See Checking for Broken Links for more information. linkcheck output |
Bundle size comparisonBase commit: Pending — |
The legacy
assertAPI is intended only for use within the Fluid Framework client codebase and is now deprecated for external consumers.Consumers should replace it with an assertion utility appropriate for their application.
Usage within the Fluid Framework client is still permitted.
Existing usages of
assertin example apps were replaced with Errors.