Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove prerender option from injectRoute #11978

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changeset/two-beans-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@astrojs/web-vitals': major
'astro': major
---

Removes the `prerender` option from `injectRoute` in the Integrations API.

The `injectRoute` integration method no longer accepts `prerender: true`.

Instead, add the `prerender` export to your injected route like you would for other routes defined in the `src/pages` directory:

```astro
---
export const prerender = true
---
```
1 change: 0 additions & 1 deletion packages/astro/src/actions/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default function astroIntegrationActionsRouteHandler({
params.injectRoute({
pattern: '/_actions/[...path]',
entrypoint: 'astro/actions/runtime/route.js',
prerender: false,
});

params.addMiddleware({
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/actions/runtime/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { formContentTypes, hasContentType } from './utils.js';
import { getAction } from './virtual/get-action.js';
import { serializeActionResult } from './virtual/shared.js';

export const prerender = false;

export const POST: APIRoute = async (context) => {
const { request, url } = context;
let baseAction;
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/routing/manifest/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function createInjectedRoutes({ settings, cwd }: CreateRouteManifestParams): Rou
const routes: RouteData[] = [];

for (const injectedRoute of settings.injectedRoutes) {
const { pattern: name, entrypoint, prerender: prerenderInjected } = injectedRoute;
const { pattern: name, entrypoint } = injectedRoute;
const { resolved, component } = resolveInjectedRoute(entrypoint, config.root, cwd);

const segments = removeLeadingForwardSlash(name)
Expand Down Expand Up @@ -316,7 +316,7 @@ function createInjectedRoutes({ settings, cwd }: CreateRouteManifestParams): Rou
component,
generate,
pathname: pathname || void 0,
prerender: prerenderInjected ?? prerender,
prerender,
fallbackRoutes: [],
});
}
Expand Down
7 changes: 0 additions & 7 deletions packages/astro/src/integrations/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,6 @@ export async function runHookConfigSetup({
return { ...updatedConfig };
},
injectRoute: (injectRoute) => {
if (injectRoute.entrypoint == null && 'entryPoint' in injectRoute) {
logger.warn(
null,
`The injected route "${injectRoute.pattern}" by ${integration.name} specifies the entry point with the "entryPoint" property. This property is deprecated, please use "entrypoint" instead.`,
);
injectRoute.entrypoint = injectRoute.entryPoint as string;
}
updatedSettings.injectedRoutes.push(injectRoute);
},
addWatchFile: (path) => {
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/types/public/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ export type InjectedScriptStage = 'before-hydration' | 'head-inline' | 'page' |
export interface InjectedRoute {
pattern: string;
entrypoint: string;
prerender?: boolean;
}

export interface ResolvedInjectedRoute extends InjectedRoute {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,21 @@ export default defineConfig({
injectRoute({
pattern: `/injected-a`,
entrypoint: './src/to-inject.astro',
prerender: true,
});
injectRoute({
pattern: `/injected-b`,
entrypoint: './src/to-inject.astro',
prerender: true,
});
injectRoute({
pattern: `/dynamic-a/[id]`,
entrypoint: './src/[id].astro',
prerender: true,
});
injectRoute({
pattern: `/dynamic-b/[id]`,
entrypoint: './src/[id].astro',
prerender: true,
});
},
},
},
],
});
});
1 change: 0 additions & 1 deletion packages/integrations/web-vitals/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default function webVitals({ deprecated }: { deprecated?: boolean } = {})
injectRoute({
entrypoint: '@astrojs/web-vitals/endpoint',
pattern: WEB_VITALS_ENDPOINT_PATH + '/[...any]',
prerender: false,
});
// Client-side performance measurement script.
injectScript('page', `import '@astrojs/web-vitals/client-script';`);
Expand Down
Loading