Skip to content

astro@7.3.0 astro:assets imports unpublished astro/_internal/logger #17898

Closed

Description

@iseraph-dev

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.

Activity

  1. added
    triage: in progress
    on Sep 3, 2026
  2. astro-factory commented on Sep 3, 2026

    @astro-factory
    Contributor

    Triage complete

    • Prepare the workspace: ready
    • Install dependencies: complete
    • Build the project: complete
    • Reproduce the issue: confirmed
    • Diagnose the cause: high confidence
    • Verify the diagnosis: bug
    • Attempt a fix: verified
    • Publish the result: set triage: fix pending

    • Reproduced: Yes — by packing the astro package (pnpm pack) and installing the tarball in an isolated project outside the workspace, then running astro build with output: 'server'.
    • Exploration: Yes — View branch
    • Unit Test: Yes — packages/astro/test/units/exports.test.ts (new test: emitted virtual module code should not import from "astro/_internal/*")
    • Priority: P5: urgent. This breaks astro build for every output: 'server' project using the published astro@7.3.0 package, with no workaround. Even an empty page fails because the adapter pulls astro:assets into the server bundle.

    The RUNTIME_LOGGER_SETUP constant in packages/astro/src/assets/vite-plugin-assets.ts (introduced by #17818) emits import { astroToRuntimeLogger } from "astro/_internal/logger" into the astro:assets virtual module. Since _internal/* entries are stripped from publishConfig.exports at publish time, Rolldown's resolver rejects the import when bundling the server entry. This doesn't surface in the monorepo because the workspace symlink bypasses exports enforcement.

    I found a potential fix for this issue. The fix inlines the trivial astroToRuntimeLogger wrapper directly in the emitted code instead of importing it, removing the _internal/logger dependency entirely. A regression test was also added to exports.test.ts to 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@7c97653

    If 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:assets virtual module emits an import of astro/_internal/logger, which is not included in publishConfig.exports. This causes astro build to fail with a rolldown:vite-resolve error for any project using the published astro package when output: 'server' is configured (or when getImage is imported from astro:assets).

    Environment

    • Astro: 7.3.0 (installed from pnpm pack tarball to simulate published conditions)
    • Vite: 8.2.2
    • Node: v22.23.1
    • OS: Linux (x64)

    Error Message

    [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
    

    Root Cause

    In packages/astro/src/assets/vite-plugin-assets.ts (line 141), RUNTIME_LOGGER_SETUP emits:

    import { astroToRuntimeLogger as _astroToRuntimeLogger } from "astro/_internal/logger";
    • astro/logger/console IS in publishConfig.exports ✅
    • astro/_internal/logger is NOT in publishConfig.exports ❌

    The _internal/* convention is documented in CONTRIBUTING.md as "never ships" — publishConfig.exports intentionally strips these entries. The emitted virtual module code runs in the user's project context, so Rolldown resolves it against the published package's exports field. Introduced by PR #17818 (commit c0b65811d).

    The existing exports.test.ts doesn'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/astro is a workspace symlink → packages/astro/. Vite/Rolldown follows the symlink and resolves files directly on disk, bypassing exports enforcement. So the bug only manifests with the published package.

    Fix Details

    packages/astro/src/assets/vite-plugin-assets.ts — Replaced the astro/_internal/logger import + astroToRuntimeLogger() call with an inline object literal. The function is trivial:

    // Before
    import { astroToRuntimeLogger as _astroToRuntimeLogger } from "astro/_internal/logger";
    const _runtimeLogger = _astroToRuntimeLogger(_astroLogger);
    
    // After
    const _runtimeLogger = {
        info: (msg) => _astroLogger.info(null, msg),
        warn: (msg) => _astroLogger.warn(null, msg),
        error: (msg) => _astroLogger.error(null, msg),
    };

    packages/astro/test/units/exports.test.ts — Added regression test that scans the built vite-plugin-assets.js for astro/_internal/* import specifiers.

    Verification

    • Server build (output: 'server' + @astrojs/node) succeeds ✅
    • Static build continues to work ✅
    • All 3487 unit tests pass, 0 failures
    • New regression test correctly catches the old bug (verified by temporarily reverting the dist)

    Changeset

    .changeset/beige-things-beg.md — astro patch

    This 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.

  3. self-assigned this
    on Sep 3, 2026
  4. added
    - P5: urgent
    pkg: astro
    triage: fix pending
    and removed
    triage: in progress
    on Sep 3, 2026
  5. dgilleland commented on Sep 4, 2026

    @dgilleland

    For pnpm users still encountering this issue, try running pnpm why astro. You might see a result like the following (which I ran into):

    pnpm why astro                   
    astro@7.3.0
    ├── @0.0.1 (dependencies)
    ├─┬ @astrojs/mdx@8.0.0
    │ └─┬ @astrojs/starlight@0.42.0
    │   └── @0.0.1 (dependencies)
    ├── @astrojs/starlight@0.42.0 [deduped]
    └─┬ astro-expressive-code@0.44.2
      └── @astrojs/starlight@0.42.0 [deduped]

    The solution is simple:

    pnpm add astro@7.3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

- P5: urgentpkg: astrotriage: fix pending

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions