Skip to content

fix(devtools): rework timeline function wrapping to run after key injection - #1028

Open
cernymatej wants to merge 3 commits into
nuxt:mainfrom
cernymatej:fix/timeline-function-wrapping
Open

fix(devtools): rework timeline function wrapping to run after key injection#1028
cernymatej wants to merge 3 commits into
nuxt:mainfrom
cernymatej:fix/timeline-function-wrapping

Conversation

@cernymatej

@cernymatej cernymatej commented Jul 20, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

fix #941

📚 Description

this aims to fix the issues with wrapping functions with __nuxtTimelineWrap after the changes in Nuxt that made function key injection stricter (and more accurate): nuxt/nuxt#33446

the main issue was that we wrapped functions before the key injection plugin transformed the code... as a result, the plugin only saw local variable declarations instead of imports and bailed out without injecting function keys

another issue, reported in nuxt/nuxt#34934, was that it attempted to wrap new compiler macros, even though they're not meant to be called that way

this implementation fixes both of these issues and improves on the original implementation by supporting explicitly imported functions too, where the old one only wrapped auto-imported functions

@cernymatej
cernymatej force-pushed the fix/timeline-function-wrapping branch from 095b589 to d10cb86 Compare July 20, 2026 19:43
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b6a7c981-bd61-4602-aa01-a7d254f0671a

📥 Commits

Reviewing files that changed from the base of the PR and between 689910f and 55c1e6b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/devtools/package.json
  • pnpm-workspace.yaml
  • tests/e2e/playwright.config.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The timeline integration now wraps eligible imports in a post-build unplugin transform after key injection. A new utility handles static import bindings, helper injection, and source maps. Vitest and Playwright coverage validate wrapping, filtering, keyed composables, and generated markers. The timeline playground adds a keyed page and enables timeline support. Package and workspace configuration adds dependencies and test scripts.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 55c1e

This PR changes timeline function wrapping to preserve key injection and avoid wrapping unsupported compiler macros; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes reworking DevTools timeline wrapping to run after function key injection.
Description check ✅ Passed The description explains the timeline wrapping bug, its causes, and the fixes implemented by this pull request.
Linked Issues check ✅ Passed The changes move wrapping after key injection and add coverage for keyed composables, directly addressing issue #941.
Out of Scope Changes check ✅ Passed The dependency, test, playground, and configuration changes support implementation or validation of the timeline wrapping fix.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/devtools/vitest.config.ts (1)

1-7: 🧹 Nitpick | 🔵 Trivial

Wire the new test suite into CI before merge.

Per the PR summary, tests were added but aren't yet configured in CI. This config also runs the 60s-timeout e2e suite (timeline.e2e.test.ts, which boots a real dev server) together with fast unit tests under the same vitest run invocation — consider splitting them (e.g. separate include globs/projects or a dedicated test:e2e script) once CI is wired up, so unit-test feedback isn't gated on booting a Nuxt dev server.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/devtools/vitest.config.ts` around lines 1 - 7, Wire the new Vitest
suite into the repository’s CI workflow so it runs before merges. In the test
configuration around defineConfig, separate the fast unit tests from
timeline.e2e.test.ts into distinct globs, projects, or scripts, and ensure CI
invokes the unit suite independently so it is not gated by the real dev-server
e2e test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/devtools/src/integrations/timeline.ts`:
- Around line 87-104: Update the resolveId handling in the bySource processing
block to invoke ctx.resolveId(from) inside a promise-safe boundary so
synchronous throws become rejected resolutions handled as undefined. Ensure
resolvedFrom caches that safely handled promise and Promise.all cannot reject
from a resolver throw, preserving normal mapping behavior for successful
resolutions.

---

Nitpick comments:
In `@packages/devtools/vitest.config.ts`:
- Around line 1-7: Wire the new Vitest suite into the repository’s CI workflow
so it runs before merges. In the test configuration around defineConfig,
separate the fast unit tests from timeline.e2e.test.ts into distinct globs,
projects, or scripts, and ensure CI invokes the unit suite independently so it
is not gated by the real dev-server e2e test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 04b140c7-e9b9-4e43-a2cc-3271b7c282b2

📥 Commits

Reviewing files that changed from the base of the PR and between 0c94730 and d10cb86.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • packages/devtools/package.json
  • packages/devtools/src/integrations/timeline-wrap.ts
  • packages/devtools/src/integrations/timeline.ts
  • packages/devtools/test/fixtures/timeline/app.vue
  • packages/devtools/test/fixtures/timeline/nuxt.config.ts
  • packages/devtools/test/timeline-wrap.test.ts
  • packages/devtools/test/timeline.e2e.test.ts
  • packages/devtools/vitest.config.ts
  • playgrounds/tab-timeline/components/GlobalNav.vue
  • playgrounds/tab-timeline/pages/keyed.vue
  • pnpm-workspace.yaml

Comment thread packages/devtools/src/integrations/timeline.ts
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.

fix: Devtools timeline breaks function key injection

1 participant