Skip to content

fix: bundle @astrojs/internal-helpers in prerender environment#16572

Merged
ematipico merged 2 commits into
withastro:mainfrom
DORI2001:fix/bundle-internal-helpers-in-prerender
May 15, 2026
Merged

fix: bundle @astrojs/internal-helpers in prerender environment#16572
ematipico merged 2 commits into
withastro:mainfrom
DORI2001:fix/bundle-internal-helpers-in-prerender

Conversation

@DORI2001
Copy link
Copy Markdown
Contributor

@DORI2001 DORI2001 commented May 2, 2026

Changes

Fixes the Vite build warning reported in #15957:

[WARN] Plugin vite:reporter: Unused imports from "@astrojs/internal-helpers/remote":
 – "matchHostname", "matchPathname", "matchPort", "matchProtocol"

plugin-internals.ts sets noExternal: ['astro'] for the prerender environment, which bundles astro but leaves @astrojs/internal-helpers as an external. Rollup then sees that those four helpers are imported by the bundled astro code but not consumed inside the bundle boundary, which triggers the unused-import warning.

Adding @astrojs/internal-helpers to noExternal alongside astro co-bundles it in the prerender environment, eliminating the warning. This is a first-party workspace package and the same pattern is already used elsewhere.

Testing

The warning is emitted by Vite/Rollup during the build phase and is not directly observable in the integration test suite without capturing stderr. Verified manually by running a project build with output: 'hybrid' before and after the change — the warning disappears with the fix applied.

Docs

No user-facing behavior change — no docs update needed.

Fixes #15957.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 2, 2026

🦋 Changeset detected

Latest commit: ff572f9

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label May 2, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 2, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing DORI2001:fix/bundle-internal-helpers-in-prerender (ff572f9) with main (17f1867)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (7711e47) during the generation of this report, so 17f1867 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@ematipico ematipico merged commit 4a5a077 into withastro:main May 15, 2026
27 checks passed
@astrobot-houston astrobot-houston mentioned this pull request May 15, 2026
dadezzz pushed a commit to dadezzz/university_notes that referenced this pull request May 22, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`6.3.3` → `6.3.5`](https://renovatebot.com/diffs/npm/astro/6.3.3/6.3.5) | ![age](https://developer.mend.io/api/mc/badges/age/npm/astro/6.3.5?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/astro/6.3.3/6.3.5?slim=true) |

---

### Release Notes

<details>
<summary>withastro/astro (astro)</summary>

### [`v6.3.5`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#635)

[Compare Source](https://github.com/withastro/astro/compare/astro@6.3.4...astro@6.3.5)

##### Patch Changes

- [#&#8203;16771](withastro/astro#16771) [`07c8805`](withastro/astro@07c8805) Thanks [@&#8203;ematipico](https://github.com/ematipico)! - Fixes `position` prop on `<Image>` and `<Picture>` components breaking Content Security Policy (CSP).

- [#&#8203;16593](withastro/astro#16593) [`50924ce`](withastro/astro@50924ce) Thanks [@&#8203;yanthomasdev](https://github.com/yanthomasdev)! - Improves error messages with more consistent and correct writing.

- [#&#8203;16757](withastro/astro#16757) [`5d661cd`](withastro/astro@5d661cd) Thanks [@&#8203;astrobot-houston](https://github.com/astrobot-houston)! - Fixes dev server serving stale content when SSR-only modules change (e.g. `.astro` files outside the project root in a monorepo, or dynamically imported components).

  Previously, the `astro:hmr-reload` plugin returned an empty array after detecting SSR-only module changes, which prevented Vite's `updateModules` from propagating the invalidation to the SSR module runner. The runner's evaluated module cache stayed stale, so subsequent requests continued returning old content.

  Now the plugin returns the SSR-only modules so Vite can process them through `updateModules`, which properly invalidates the module runner's cache and ensures fresh content on the next request.

### [`v6.3.4`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#634)

[Compare Source](https://github.com/withastro/astro/compare/astro@6.3.3...astro@6.3.4)

##### Patch Changes

- [#&#8203;16723](withastro/astro#16723) [`0f10bfe`](withastro/astro@0f10bfe) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Adds `fetchFile` option to `experimental.advancedRouting` to customize or disable the entrypoint file

  ```js
  export default defineConfig({
    experimental: {
      advancedRouting: {
        fetchFile: 'fetch.ts',
      },
    },
  });
  ```

- [#&#8203;16723](withastro/astro#16723) [`0f10bfe`](withastro/astro@0f10bfe) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes Hono `cache()` middleware to follow the standard wrapper pattern

- [#&#8203;16723](withastro/astro#16723) [`0f10bfe`](withastro/astro@0f10bfe) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Adds `App.Providers` interface for typing custom context providers on `Astro` and `ctx`

  ```ts
  declare namespace App {
    interface Providers {
      oauth: import('./lib/oauth').OAuthSession;
    }
  }
  ```

- [#&#8203;16723](withastro/astro#16723) [`0f10bfe`](withastro/astro@0f10bfe) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Adds `FetchState.response` property, set automatically after `pages()` or `middleware()` completes

  ```ts
  const response = await middleware(state, (s) => pages(s));
  console.log(state.response === response); // true
  ```

- [#&#8203;16723](withastro/astro#16723) [`0f10bfe`](withastro/astro@0f10bfe) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Adds `Fetchable` type export for typing the advanced routing entrypoint

  ```ts
  import type { Fetchable } from 'astro';

  export default {
    async fetch(request) {
      return new Response('ok');
    },
  } satisfies Fetchable;
  ```

- [#&#8203;16572](withastro/astro#16572) [`4a5a077`](withastro/astro@4a5a077) Thanks [@&#8203;DORI2001](https://github.com/DORI2001)! - Suppresses `[WARN] Vite warning: unused imports from "@&#8203;astrojs/internal-helpers/remote"` during prerender builds. The package is now bundled alongside `astro` in the prerender environment, matching how it is handled in the SSR environment.

- [#&#8203;16756](withastro/astro#16756) [`b6ee23d`](withastro/astro@b6ee23d) Thanks [@&#8203;astrobot-houston](https://github.com/astrobot-houston)! - Fixes styles from Markdoc/MDX custom components not being extracted to `<head>` in the dev server when using the Cloudflare adapter with `prerenderEnvironment: 'node'` and rendering content through a wrapper component.

- [#&#8203;16747](withastro/astro#16747) [`904d19a`](withastro/astro@904d19a) Thanks [@&#8203;astrobot-houston](https://github.com/astrobot-houston)! - Fixes Astro action requests failing in `astro dev` when using the Cloudflare adapter with `prerenderEnvironment: 'node'` alongside a prerendered catch-all route such as `[...page].astro`.

  Actions and other SSR POST endpoints now continue to work in dev instead of returning an HTTP 500 error.

- [#&#8203;16701](withastro/astro#16701) [`3495ce4`](withastro/astro@3495ce4) Thanks [@&#8203;demaisj](https://github.com/demaisj)! - Fix `Map` and `Set` instances saved in a content collection being broken when retrieving entries.

- [#&#8203;16614](withastro/astro#16614) [`fca1c32`](withastro/astro@fca1c32) Thanks [@&#8203;Eptagone](https://github.com/Eptagone)! - Fixes `entry.data` type inference when a live collection is configured without a schema.

- [#&#8203;16661](withastro/astro#16661) [`03b8f7f`](withastro/astro@03b8f7f) Thanks [@&#8203;ocavue](https://github.com/ocavue)! - Updates `typescript` to v6. No changes are needed from users.

- [#&#8203;16681](withastro/astro#16681) [`c22770a`](withastro/astro@c22770a) Thanks [@&#8203;dotnetCarpenter](https://github.com/dotnetCarpenter)! - Fixes an issue where SVG images with `width="0"` or `height="0"` incorrectly threw a `NoImageMetadata` error instead of being treated as valid dimensions.

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xODIuMSIsInVwZGF0ZWRJblZlciI6IjQzLjE4Mi4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WARN] Vite warning: unused imports from "@astrojs/internal-helpers/remote

2 participants