0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

[ci] format

This commit is contained in:
Emanuele Stoppa 2024-06-13 13:05:54 +00:00 committed by astrobot-houston
parent 4385bf7a4d
commit a6df7e877f
7 changed files with 36 additions and 35 deletions

View file

@ -6,7 +6,7 @@ import ReactWrapper from '../src/components/ReactWrapper.astro';
const renderers = await loadRenderers([getContainerRenderer()]);
const container = await AstroContainer.create({
renderers
renderers,
});
test('ReactWrapper with react renderer', async () => {

View file

@ -2996,7 +2996,7 @@ export type SSRLoadedRendererValue = {
* page-level data structure.
*/
renderHydrationScript?: () => string;
}
};
export interface SSRLoadedRenderer extends Pick<AstroRenderer, 'name' | 'clientEntrypoint'> {
ssr: SSRLoadedRendererValue;

View file

@ -8,7 +8,8 @@ import type {
Props,
RouteData,
RouteType,
SSRLoadedRenderer, SSRLoadedRendererValue,
SSRLoadedRenderer,
SSRLoadedRendererValue,
SSRManifest,
SSRResult,
} from '../@types/astro.js';
@ -290,14 +291,16 @@ export class experimental_AstroContainer {
*/
public addServerRenderer(name: string, renderer: SSRLoadedRendererValue) {
if (!renderer.check || !renderer.renderToStaticMarkup) {
throw new Error("The renderer you passed isn't valid. A renderer is usually an object that exposes the `check` and `renderToStaticMarkup` functions.\n" +
"Usually, the renderer is exported by a /server.js entrypoint e.g. `import renderer from '@astrojs/react/server.js'`")
throw new Error(
"The renderer you passed isn't valid. A renderer is usually an object that exposes the `check` and `renderToStaticMarkup` functions.\n" +
"Usually, the renderer is exported by a /server.js entrypoint e.g. `import renderer from '@astrojs/react/server.js'`"
);
}
this.#pipeline.manifest.renderers.push({
name,
ssr: renderer
})
ssr: renderer,
});
}
// NOTE: we keep this private via TS instead via `#` so it's still available on the surface, so we can play with it.

View file

@ -1,5 +1,5 @@
import assert from 'node:assert/strict';
import { describe, it, before } from 'node:test';
import { before, describe, it } from 'node:test';
import { experimental_AstroContainer } from '../dist/container/index.js';
import {
Fragment,
@ -12,8 +12,8 @@ import {
renderSlot,
renderTemplate,
} from '../dist/runtime/server/index.js';
import {loadFixture} from "./test-utils.js";
import testAdapter from "./test-adapter.js";
import testAdapter from './test-adapter.js';
import { loadFixture } from './test-utils.js';
const BaseLayout = createComponent((result, _props, slots) => {
return render`<html>
@ -234,24 +234,23 @@ describe('Container', () => {
});
describe('Container with renderers', () => {
let fixture
let fixture;
let app;
before(async () => {
fixture = await loadFixture({
root: new URL('./fixtures/container-react/', import.meta.url),
output: "server",
adapter: testAdapter()
output: 'server',
adapter: testAdapter(),
});
await fixture.build();
app = await fixture.loadTestAdapterApp();
});
it("the endpoint should return the HTML of the React component", async () => {
const request = new Request("https://example.com/api");
const response = await app.render(request)
const html = await response.text()
it('the endpoint should return the HTML of the React component', async () => {
const request = new Request('https://example.com/api');
const response = await app.render(request);
const html = await response.text();
assert.match(html, /I am a react button/)
})
assert.match(html, /I am a react button/);
});
});

View file

@ -230,4 +230,3 @@ export default {
renderToStaticMarkup,
supportsAstroStaticSlot: true,
};

View file

@ -2,11 +2,11 @@ import react, { type Options as ViteReactPluginOptions } from '@vitejs/plugin-re
import type { AstroIntegration, ContainerRenderer } from 'astro';
import type * as vite from 'vite';
import {
type ReactVersionConfig,
type SupportedReactVersion,
getReactMajorVersion,
isUnsupportedVersion,
versionsConfig,
type ReactVersionConfig,
type SupportedReactVersion,
} from './version.js';
export type ReactIntegrationOptions = Pick<

View file

@ -3,5 +3,5 @@
"include": ["src"],
"compilerOptions": {
"outDir": "./dist"
},
}
}