Skip to content

feat: support Typescript 6#2614

Open
jackw wants to merge 7 commits intomainfrom
jackw/008-remove-tsconfig-baseurl
Open

feat: support Typescript 6#2614
jackw wants to merge 7 commits intomainfrom
jackw/008-remove-tsconfig-baseurl

Conversation

@jackw
Copy link
Copy Markdown
Collaborator

@jackw jackw commented May 5, 2026

Summary

Two changes that together get scaffolded plugins ready for TypeScript 6:

baseUrlpaths

  • Replaces "baseUrl": "../src" with "paths": { "*": ["../src/*"] } in the scaffold template, so newly-created plugins are clean on TS 6 (baseUrl is deprecated — TS error TS5101).
  • Adds migration 008-remove-tsconfig-baseurl so existing plugins can apply the same fix via npx @grafana/create-plugin@latest update.
  • Backwards compatible with TS 5 — paths without baseUrl is supported in TS 5.0+ with moduleResolution: bundler, which @grafana/tsconfig already requires.

ts-node compilerOptions overrides

  • Updates module/moduleResolution/target in the ts-node block from commonjs/node/es5 to nodenext/nodenext/es2022 in the scaffold template, so newly-created plugins build under the latest @grafana/tsconfig on Node 22+ / TS 5–6.
  • Adds migration 009-ts-node-nodenext to apply the same fix to existing plugins. Idempotent and only touches keys still at their known-old scaffolded values.

CI

  • Re-enables the test-updates job in ci.yml that was temporarily disabled due to the grafana/grafana NPM publishing issue. It scaffolds a plugin from create-plugin@5.27.1, runs update --force, then lint/typecheck/build/test/e2e — exercising both migrations end-to-end.

Both migrations use jsonc-parser to edit in-place, preserving the DO-NOT-EDIT comment header and any user customisations.

Fixes: #2613

Test plan

  • 11 unit tests across the two migrations (5 + 6) covering: happy path, idempotency, already-migrated guard, missing-file guard, comment-header preservation, and partial customisation
  • npm run test -w @grafana/create-plugin — 242 tests pass
  • npm run lint -w @grafana/create-plugin — clean
  • npm run typecheck -w @grafana/create-plugin — clean
  • CI test-updates job passes end-to-end after force-push

🤖 Generated with Claude Code

📦 Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install website@5.6.0-canary.2614.25425808460.0
npm install @grafana/create-plugin@7.4.0-canary.2614.25425808460.0
npm install @grafana/plugin-e2e@3.8.0-canary.2614.25425808460.0
# or 
yarn add website@5.6.0-canary.2614.25425808460.0
yarn add @grafana/create-plugin@7.4.0-canary.2614.25425808460.0
yarn add @grafana/plugin-e2e@3.8.0-canary.2614.25425808460.0

Copilot AI review requested due to automatic review settings May 5, 2026 15:22
@jackw jackw requested a review from a team as a code owner May 5, 2026 15:22
@jackw jackw requested review from ashharrison90 and joshhunt May 5, 2026 15:22
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

✨ This PR can be merged and will trigger a new minor release.
NOTE: When merging a PR with the release label please avoid merging another PR. For further information see here.

@jackw jackw self-assigned this May 5, 2026
@jackw jackw added minor Increment the minor version when merged release Create a release when this pr is merged labels May 5, 2026
@jackw jackw changed the title fix: replace deprecated tsconfig baseUrl with paths catch-all feat: support Typescript 6 May 5, 2026
Copy link
Copy Markdown
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

Updates the @grafana/create-plugin scaffold and update-migrations to avoid the TypeScript 6 deprecation warning for compilerOptions.baseUrl, while preserving equivalent module-resolution behavior via a paths catch-all.

Changes:

  • Update the common scaffold .config/tsconfig.json to replace deprecated baseUrl with compilerOptions.paths["*"] = ["../src/*"].
  • Add migration 008-remove-tsconfig-baseurl to apply the same change to existing plugins’ .config/tsconfig.json while preserving JSONC comments/formatting via jsonc-parser.
  • Add unit tests covering the migration’s expected behavior (happy path, idempotency, guards, and merging with existing paths entries).

Reviewed changes

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

File Description
packages/create-plugin/templates/common/.config/tsconfig.json Removes baseUrl from the scaffolded tsconfig and adds a paths catch-all to keep TS resolution working without the deprecated option.
packages/create-plugin/src/codemods/migrations/scripts/008-remove-tsconfig-baseurl.ts New migration script to remove baseUrl and inject paths["*"] using JSONC edit operations.
packages/create-plugin/src/codemods/migrations/scripts/008-remove-tsconfig-baseurl.test.ts Tests verifying migration correctness, idempotency, guards, and non-destructive merge with existing paths.
packages/create-plugin/src/codemods/migrations/migrations.ts Registers the new migration with version metadata and script path.

@MattIPv4
Copy link
Copy Markdown
Member

MattIPv4 commented May 5, 2026

👀 Would now not be the best time to look at encouraging using #/my-file subpath imports (https://nodejs.org/api/packages.html#subpath-imports) for new plugins, instead of perpetuating the pattern of bare imports that can collide with installed modules and that requires a bundler + additional TS config?

ashharrison90
ashharrison90 previously approved these changes May 5, 2026
Copy link
Copy Markdown
Contributor

@ashharrison90 ashharrison90 left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@github-project-automation github-project-automation Bot moved this from 📬 Triage to 🔬 In review in Grafana Catalog Team May 5, 2026
@jackw jackw force-pushed the jackw/008-remove-tsconfig-baseurl branch from 25cd42a to dd5c24a Compare May 6, 2026 07:33
jackw added 4 commits May 6, 2026 10:15
Updates module, moduleResolution, and target inside ts-node
compilerOptions in scaffolded plugins' .config/tsconfig.json so they
remain compatible with the latest @grafana/tsconfig (TypeScript 5/6).
Update module, moduleResolution, and target to nodenext/nodenext/es2022
so newly scaffolded plugins are compatible with the latest
@grafana/tsconfig (TypeScript 5/6).
The grafana/grafana NPM package publishing issue that caused this
job to fail has been resolved, so the job can run again. It exercises
the create-plugin update command end-to-end on a 5.27.1-scaffolded
plugin, validating every registered migration in sequence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Increment the minor version when merged release Create a release when this pr is merged

Projects

Status: 🔬 In review

Development

Successfully merging this pull request may close these issues.

Create Plugin: Support Typescript 6

4 participants