Repository navigation
Closed
Labels
- P5: urgentFix build-breaking bugs affecting most users, should be released ASAP (priority)pkg: astroRelated to the core `astro` package (scope)triage: fix pendingReporter needs to verify the triage bot fix works
Description
Astro Info
Astro v7.3.0
Vite v8.2.2
Node v24.20.0
System Linux (x64)
Package Manager pnpm
Output static
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
astro@7.3.0 astro:assets emits this into the built graph (vite-plugin-assets.ts, from #17818):
import { createConsoleLogger as _createConsoleLogger } from "astro/logger/console";
import { astroToRuntimeLogger as _astroToRuntimeLogger } from "astro/_internal/logger";astro/logger/console is on publishConfig.exports. ./_internal/logger is only on the source map, which publishConfig.exports strips (CONTRIBUTING.md, #16473). exports.test.ts compares the two maps after dropping _internal/*, so it does not catch a virtual module importing one.
[rolldown:vite-resolve] plugin `rolldown:vite-resolve` threw an error
Caused by:
"./_internal/logger" is not exported under the conditions ["module", "node", "production", "astro", "import"]
from package .../node_modules/astro
node --input-type=module -e "import('astro/_internal/logger')"
# ERR_PACKAGE_PATH_NOT_EXPORTED: Package subpath './_internal/logger' is not defined by "exports"
Trigger: import { getImage } from 'astro:assets' (this repro), or output: 'server' — the adapter pulls astro:assets into the server bundle even on an empty page.
What's the expected result?
astro build succeeds. Emitted astro:assets code only imports specifiers that exist in publishConfig.exports.
Link to Minimal Reproducible Example
https://github.com/iseraph-dev/repro-astro-730-internal-logger
pnpm install
pnpm astro build
Participation
- I am willing to submit a pull request for this issue.
Reacted by xidedix and 伍轻鸣
Metadata
Metadata
Assignees
Labels
- P5: urgentFix build-breaking bugs affecting most users, should be released ASAP (priority)pkg: astroRelated to the core `astro` package (scope)triage: fix pendingReporter needs to verify the triage bot fix works
Activity
astro-factory commentedon Sep 3, 2026
Triage complete
triage: fix pendingastropackage (pnpm pack) and installing the tarball in an isolated project outside the workspace, then runningastro buildwithoutput: 'server'.packages/astro/test/units/exports.test.ts(new test:emitted virtual module code should not import from "astro/_internal/*")astro buildfor everyoutput: 'server'project using the publishedastro@7.3.0package, with no workaround. Even an empty page fails because the adapter pullsastro:assetsinto the server bundle.The
RUNTIME_LOGGER_SETUPconstant inpackages/astro/src/assets/vite-plugin-assets.ts(introduced by #17818) emitsimport { astroToRuntimeLogger } from "astro/_internal/logger"into theastro:assetsvirtual module. Since_internal/*entries are stripped frompublishConfig.exportsat publish time, Rolldown's resolver rejects the import when bundling the server entry. This doesn't surface in the monorepo because the workspace symlink bypassesexportsenforcement.I found a potential fix for this issue. The fix inlines the trivial
astroToRuntimeLoggerwrapper directly in the emitted code instead of importing it, removing the_internal/loggerdependency entirely. A regression test was also added toexports.test.tsto catch future_internal/*references in emitted virtual module code.Try this fix
You can test this fix right now without waiting for a release:
# astro npm i https://pkg.pr.new/astro@7c97653If this fixes your issue, please leave a comment letting us know (for example
"confirmed, this fixes it"). A pull request will then be opened to get it merged.
Full Triage Report
Summary
The
astro:assetsvirtual module emits an import ofastro/_internal/logger, which is not included inpublishConfig.exports. This causesastro buildto fail with arolldown:vite-resolveerror for any project using the publishedastropackage whenoutput: 'server'is configured (or whengetImageis imported fromastro:assets).Environment
pnpm packtarball to simulate published conditions)Error Message
Root Cause
In
packages/astro/src/assets/vite-plugin-assets.ts(line 141),RUNTIME_LOGGER_SETUPemits:astro/logger/consoleIS inpublishConfig.exports✅astro/_internal/loggeris NOT inpublishConfig.exports❌The
_internal/*convention is documented inCONTRIBUTING.mdas "never ships" —publishConfig.exportsintentionally strips these entries. The emitted virtual module code runs in the user's project context, so Rolldown resolves it against the published package'sexportsfield. Introduced by PR #17818 (commitc0b65811d).The existing
exports.test.tsdoesn't catch this because it only checks structural agreement between the two export maps after stripping_internal/*keys — it doesn't detect emitted virtual module code that references_internal/*specifiers.Why it doesn't fail in the monorepo
node_modules/astrois a workspace symlink →packages/astro/. Vite/Rolldown follows the symlink and resolves files directly on disk, bypassingexportsenforcement. So the bug only manifests with the published package.Fix Details
packages/astro/src/assets/vite-plugin-assets.ts— Replaced theastro/_internal/loggerimport +astroToRuntimeLogger()call with an inline object literal. The function is trivial:packages/astro/test/units/exports.test.ts— Added regression test that scans the builtvite-plugin-assets.jsforastro/_internal/*import specifiers.Verification
output: 'server'+@astrojs/node) succeeds ✅Changeset
.changeset/beige-things-beg.md—astropatchThis report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
dgilleland commentedon Sep 4, 2026
For
pnpmusers still encountering this issue, try runningpnpm why astro. You might see a result like the following (which I ran into):The solution is simple: