Skip to content

feat: unwrap Provider namespace + improved automation script#22690

Merged
kitlangton merged 1 commit into
devfrom
kit/namespace-treeshake-provider
Apr 16, 2026
Merged

feat: unwrap Provider namespace + improved automation script#22690
kitlangton merged 1 commit into
devfrom
kit/namespace-treeshake-provider

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

  • Convert export namespace Provider { ... } (1709 lines) to flat named exports with export * as Provider barrel
  • Upgrade unwrap-namespace.ts script to be fully automatic (no manual steps needed)

Why

Provider was the single worst tree-shake offender. cli/error.ts imports { Provider } for 2 error type checks, which forced inclusion of 20+ @ai-sdk/* packages, @aws-sdk/credential-providers, google-auth-library, and more.

Third module in the namespace migration.

Script improvements

The script now handles everything automatically — no manual fixup needed:

  1. Self-references: Config.PermissionAction inside the same file → PermissionAction
  2. Import rewrites: searches src/, test/, AND script/ (not just src/)
  3. Sibling imports: files in the same directory that import the old name get fixed

Running the script is now truly one command:

bun script/unwrap-namespace.ts src/provider/provider.ts

Verification

  • Full typecheck clean (tsgo --noEmit)
  • 251/251 provider tests pass, 0 failures
  • 36 import rewrites + 1 sibling fix, all automatic

…king

Convert `export namespace Provider { ... }` (1709 lines, 20+ AI SDK imports)
to flat named exports with `export * as Provider` barrel.

This is the highest-value conversion — Provider was the worst tree-shake
offender, forcing cli/error.ts to pull in all AI SDK packages just for
error type checks.

Also upgrades the unwrap-namespace script to automatically handle:
- Self-references (NsName.Export → Export)
- Import path rewrites across src/, test/, script/
- Sibling imports within the same directory

36 import rewrites + 1 sibling fix, all automatic.
251 provider tests pass, full typecheck clean.
@kitlangton kitlangton force-pushed the kit/namespace-treeshake-provider branch from 6cc2de7 to 28bb979 Compare April 16, 2026 01:42
@kitlangton kitlangton enabled auto-merge (squash) April 16, 2026 01:44
@kitlangton kitlangton disabled auto-merge April 16, 2026 01:44
@kitlangton kitlangton merged commit 1d81335 into dev Apr 16, 2026
9 checks passed
@kitlangton kitlangton deleted the kit/namespace-treeshake-provider branch April 16, 2026 01:44
jerome-benoit pushed a commit to jerome-benoit/opencode that referenced this pull request Apr 16, 2026
xywsxp pushed a commit to xywsxp/opencode that referenced this pull request Apr 24, 2026
dgokeeffe pushed a commit to dgokeeffe/opencode-databricks that referenced this pull request May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant