fix(Link): export onNuxtReady from the Vue stubs - #546
Merged
Conversation
`pnpm repl:build` has been failing on `main` since #541, taking the Pages deploy with it — three commits, while `ci` stayed green the whole time. rolldown reports it as: [MISSING_EXPORT] "onNuxtReady" is not exported by "../../dist/runtime/vue/stubs/none.js" `Link.vue` imports `onNuxtReady` from `#imports` unconditionally and calls it only behind `prefetchApi`, which is `undefined` without `NuxtLink` — so no Vue build ever runs it. An import that is never called still has to resolve, and rolldown fails the whole bundle rather than warning. The stub runs the callback at the next idle moment and does nothing on the server. Nuxt's own waits for hydration and then for idle; a plain Vue app has no hydration to wait for, so only the idle half is left, and that is the half callers want. Why `ci` could not see it: `#imports` is a Nuxt alias, so `typecheck`, `test` and `build` all resolve it against Nuxt's generated types, where the name is present. The stubs are consulted only by a bundle built *without* Nuxt, which here is `pnpm repl:build` — a step in `deploy.yml` and in no other workflow. `test/utils/vue-stub-imports.spec.ts` closes that gap at the level where it is cheap: it reads every `import { … } from '#imports'` under `src/runtime` as text and asserts all three stub entry points cover the names. Mutation-checked — removing this export, dropping `export * from './base'`, and renaming one inherited export each turn it red, and the first names `Link.vue` as the caller. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JS8ypVfQSFzYVZzkTHhURb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pnpm repl:buildhas been failing onmainsince #541, taking the Pages deploy down with it — three commits (89f81a79,dbd5e7dd,6ae5680d), whilecistayed green the whole time.Link.vueimportsonNuxtReadyfrom#importsunconditionally and calls it only behindprefetchApi, which isundefinedwithoutNuxtLink— so no Vue build ever runs it. An import that is never called still has to resolve, and rolldown fails the whole bundle rather than warning.The fix
onNuxtReadyinsrc/runtime/vue/stubs/base.ts: runs the callback at the next idle moment, does nothing on the server. Nuxt's own waits for hydration and then for idle; a plain Vue app has no hydration to wait for, so only the idle half is left — and that is the half callers want, since this is how work is kept out of the mount path.Why
cicould not see it#importsis a Nuxt alias.typecheck,testandbuildall resolve it against Nuxt's generated types, where every name is present. The stubs are consulted only by a bundle built without Nuxt, which in this repository ispnpm repl:build— a step indeploy.ymland in no other workflow. So a missing export leavescigreen, merges, and takes the deploy down onmain.test/utils/vue-stub-imports.spec.tscloses that gap where it is cheap: it reads everyimport { … } from '#imports'undersrc/runtimeas text and asserts all three stub entry points (none,vue-router,inertia) cover the names. Read as text on purpose — importing#importsfrom a test resolves it through Nuxt, which is the resolution this check exists to bypass.Mutation-checked:
onNuxtReadyfrombase.ts(the regression itself)src/runtime/components/Link.vueas the callerexport * from './base'innone.tsnoneonlyuseAppConfig)One of those mutations was invalid on the first attempt and worth recording: commenting the re-export out with
//left the test green, because the helper'sexport \* from '\./base'regex matches inside a comment too. Deleting the line is the mutation that actually removes the behaviour.Verified against the real criterion, not just the guard:
pnpm repl:buildfails onmainand succeeds here.Local gate green:
lint·typecheck·build(3.87 MB) ·test(345 files, 7855 passed, 6 skipped) ·test:module·repl:build.Not fixed here
cistill builds nothing against the stubs, so a repl breakage of a different shape would still reachmainthe same way. Addingrepl:buildtoci.ymlis the general fix and a separate call — this PR covers the specific failure class cheaply.🤖 Generated with Claude Code
https://claude.ai/code/session_01JS8ypVfQSFzYVZzkTHhURb
Generated by Claude Code