You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(container): provide a virtual module to load renderers (#11144)
* feat(container): provide a virtual module to load renderers
* address feedback
* chore: restore some default to allow to have PHP prototype working
* Thread through renderers and manifest
* Pass manifest too
* update changeset
* add diff
* Apply suggestions from code review
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* fix diff
* rebase and update lock
---------
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
**BREAKING CHANGE to the experimental Container API only**
6
+
7
+
Changes the **type** of the `renderers` option of the `AstroContainer::create` function and adds a dedicated function `loadRenderers()` to load the rendering scripts from renderer integration packages (`@astrojs/react`, `@astrojs/preact`, `@astrojs/solid-js`, `@astrojs/svelte`, `@astrojs/vue`, `@astrojs/lit`, and `@astrojs/mdx`).
8
+
9
+
You no longer need to know the individual, direct file paths to the client and server rendering scripts for each renderer integration package. Now, there is a dedicated function to load the renderer from each package, which is available from `getContainerRenderer()`:
10
+
11
+
```diff
12
+
import { experimental_AstroContainer as AstroContainer } from 'astro/container';
13
+
import ReactWrapper from '../src/components/ReactWrapper.astro';
14
+
import { loadRenderers } from "astro:container";
15
+
import { getContainerRenderer } from "@astrojs/react";
16
+
17
+
test('ReactWrapper with react renderer', async () => {
const result = await container.renderToString(ReactWrapper);
30
+
31
+
expect(result).toContain('Counter');
32
+
expect(result).toContain('Count: <!-- -->5');
33
+
});
34
+
```
35
+
36
+
The new `loadRenderers()` helper function is available from `astro:container`, a virtual module that can be used when running the Astro container inside `vite`.
0 commit comments