before_code
stringlengths
14
465k
reviewer_comment
stringlengths
16
64.5k
after_code
stringlengths
9
467k
diff_context
stringlengths
0
97k
file_path
stringlengths
5
226
comment_line
int32
0
26
language
stringclasses
37 values
quality_score
float32
0.07
1
comment_type
stringclasses
9 values
comment_length
int32
16
64.5k
before_lines
int32
1
17.2k
after_lines
int32
1
12.1k
is_negative
bool
2 classes
pr_title
stringlengths
1
308
pr_number
int32
1
299k
repo_name
stringclasses
533 values
repo_stars
int64
321
419k
repo_language
stringclasses
27 values
reviewer_username
stringlengths
0
39
author_username
stringlengths
2
39
throw new Error( `${bold( packageName, )} doesn't appear to be an integration or an adapter. Find our official integrations at ${cyan( 'https://astro.build/integrations', )}`, ); } if (integration === 'tailwind') { integrationName = 'tailwind'; dependencies =...
Quick comparison of the two states here: | Current CLI | This PR | |--------|--------| | <img width="179" height="23" alt="Checkmark icon Resolving packages..." src="https://github.com/user-attachments/assets/fb79bc61-06f7-46ea-9d1e-d5d8cbe21426" /> | <img width="253" height="29" alt="diamond icon with no text" sr...
} } return Promise.all( Object.entries(ranges).map(([name, range]) => resolveRangeToInstallSpecifier(name, range)), ); } /** * Resolves package with a given range to a STABLE version * peerDependencies might specify a compatible prerelease, * but `astro add` should only ever install stable releases */ async...
@@ -813,11 +808,11 @@ async function validateIntegrations( }; }), ); - spinner.success(); + spinner.stop();
packages/astro/src/cli/add/index.ts
26
TypeScript
0.857
suggestion
708
51
51
false
perf: switch to clack for CLI prompts
14,589
withastro/astro
47,179
TypeScript
delucis
43081j
'https://astro.build/integrations', )}`, ); } if (integration === 'tailwind') { integrationName = 'tailwind'; dependencies = [ ['@tailwindcss/vite', '^4.0.0'], ['tailwindcss', '^4.0.0'], ]; } return { id: integration, packageName, dependencies...
Linking https://github.com/bombshell-dev/clack/pull/405 here as a reminder to revisit if that change to the spinner API goes ahead.
); } /** * Resolves package with a given range to a STABLE version * peerDependencies might specify a compatible prerelease, * but `astro add` should only ever install stable releases */ async function resolveRangeToInstallSpecifier(name: string, range: string): Promise<string> { const versions = await fetchPack...
@@ -813,11 +808,11 @@ async function validateIntegrations( }; }), ); - spinner.success(); + spinner.stop(); return integrationEntries; } catch (e) { if (e instanceof Error) { - spinner.error(e.message); + spinner.stop(e.message, 2);
packages/astro/src/cli/add/index.ts
26
TypeScript
0.429
suggestion
131
51
51
false
perf: switch to clack for CLI prompts
14,589
withastro/astro
47,179
TypeScript
delucis
43081j
} const coloredOutput = `${bold(installCommand.command)} ${installCommand.args.join(' ')} ${cyan(packageNames.join(' '))}`; logger.info( 'SKIP_FORMAT', `\n ${magenta('Astro will run the following command:')}\n ${dim( 'If you skip this step, you can always run it yourself later', )}`, ); clack.box(colore...
Documenting the visual changes here: | Current CLI | This PR | |---|---| | <img width="667" height="142" alt="image" src="https://github.com/user-attachments/assets/a4fcf262-7309-4b4a-8bf9-6dc503844429" /> | <img width="588" height="161" alt="image" src="https://github.com/user-attachments/assets/e85374fe-08c0-468...
packageNames = packageNames.map((name) => `npm:${name}`); } const coloredOutput = `${bold(installCommand.command)} ${installCommand.args.join(' ')} ${cyan(packageNames.join(' '))}`; logger.info( 'SKIP_FORMAT', `\n ${magenta('Astro will run the following command:')}\n ${dim( 'If you skip this step, you can...
@@ -75,34 +73,30 @@ async function installPackage( packageNames = packageNames.map((name) => `npm:${name}`); } const coloredOutput = `${bold(installCommand.command)} ${installCommand.args.join(' ')} ${cyan(packageNames.join(' '))}`; - const message = `\n${boxen(coloredOutput, { - margin: 0.5, - padding: 0.5, -...
packages/astro/src/cli/install-package.ts
26
TypeScript
0.857
suggestion
1,181
51
51
false
perf: switch to clack for CLI prompts
14,589
withastro/astro
47,179
TypeScript
delucis
43081j
const keywords = Array.isArray(pkgJson['keywords']) ? pkgJson['keywords'] : []; if (keywords.includes('astro-integration')) { integrationType = 'integration'; } else if (keywords.includes('astro-adapter')) { integrationType = 'adapter'; } else { throw new Error( `${bold( pack...
`spinner.error` makes the build fail currently
'SKIP_FORMAT', `\n ${magenta('Astro will run the following command:')}\n ${dim( 'If you skip this step, you can always run it yourself later', )}`, ); clack.box(coloredOutput, undefined, { rounded: true, withGuide: false, width: 'auto', }); if (await askToContinue({ flags, logger })) { const spi...
@@ -780,10 +774,10 @@ async function tryToInstallIntegrations({ env: { NODE_ENV: undefined }, }, }); - spinner.success(); + spinner.stop('Dependencies installed.'); return UpdateResult.updated; } catch (err: any) { - spinner.error(); + spinner.error('Error installing dependencies.');
packages/astro/src/cli/add/index.ts
26
TypeScript
0.357
bug
46
51
51
false
perf: switch to clack for CLI prompts
14,589
withastro/astro
47,179
TypeScript
florian-lefebvre
43081j
import { confirm } from '@clack/prompts'; import type { Prompt } from '../definitions.js'; interface Options { force: boolean; } export function createClackPrompt({ force }: Options): Prompt { return { async confirm({ message, defaultValue }) { if (force) { return true; } return await confirm({ m...
@43081j why does it return `Promise<boolean | symbol>`?
import { confirm } from '@clack/prompts'; import type { Prompt } from '../definitions.js'; export class ClackPrompt implements Prompt { readonly #force: boolean; constructor({ force }: { force: boolean }) { this.#force = force; } async confirm({ message, defaultValue, }: { message: string; defaultValu...
@@ -0,0 +1,20 @@ +import { confirm } from '@clack/prompts'; +import type { Prompt } from '../definitions.js'; + +interface Options { + force: boolean; +} + +export function createClackPrompt({ force }: Options): Prompt { + return { + async confirm({ message, defaultValue }) { + if (force) { + return true; + } +...
packages/astro/src/cli/info/infra/clack-prompt.ts
14
TypeScript
0.357
question
55
21
30
false
perf: switch to clack for CLI prompts
14,589
withastro/astro
47,179
TypeScript
florian-lefebvre
43081j
/** Markdown file compiled to HTML, excluding layout HTML */ compiledContent(): Promise<string>; /** List of headings (h1 -> h6) with associated metadata */ getHeadings(): MarkdownHeading[]; default: AstroComponentFactory; } export interface MDXInstance<T extends Record<string, any>> extends Omit<MarkdownInstanc...
The components aren't defined anywhere. Should we update the example?
/** Markdown file compiled to HTML, excluding layout HTML */ compiledContent(): Promise<string>; /** List of headings (h1 -> h6) with associated metadata */ getHeadings(): MarkdownHeading[]; default: AstroComponentFactory; } export interface MDXInstance<T extends Record<string, any>> extends Omit<MarkdownInstanc...
@@ -33,6 +33,33 @@ export interface MDXInstance<T extends Record<string, any>> components: Record<string, AstroComponentFactory> | undefined; } +/** + * Props accepted by the MDX `Content` component when using `await render()`. + * Allows passing custom components to override default MDX element rendering. + * + *...
packages/astro/src/types/public/content.ts
26
TypeScript
0.286
question
69
51
51
false
feat(mdx): add TypeScript types for Content components prop
14,591
withastro/astro
47,179
TypeScript
ematipico
matthewp
/** Browser URL for files under `/src/pages` (e.g. `/en/guides/markdown-content`) */ url: string | undefined; /** Component to render content in `.astro` files. Usage: `<Content />` */ Content: AstroComponentFactory; /** raw Markdown file content, excluding layout HTML and YAML frontmatter */ rawContent(): string...
```suggestion * import { getEntry, render } from 'astro:content'; * import MyCustomH1 from '../components/CustomHeading.astro'; * import MyImage from '../images/MyImage.jpg'; ``` Probably something like this? (We don't state a file name, so relative path is just approximate)
/** Browser URL for files under `/src/pages` (e.g. `/en/guides/markdown-content`) */ url: string | undefined; /** Component to render content in `.astro` files. Usage: `<Content />` */ Content: AstroComponentFactory; /** raw Markdown file content, excluding layout HTML and YAML frontmatter */ rawContent(): string...
@@ -33,6 +33,33 @@ export interface MDXInstance<T extends Record<string, any>> components: Record<string, AstroComponentFactory> | undefined; } +/** + * Props accepted by the MDX `Content` component when using `await render()`. + * Allows passing custom components to override default MDX element rendering. + * + *...
packages/astro/src/types/public/content.ts
26
TypeScript
0.786
suggestion
283
51
51
false
feat(mdx): add TypeScript types for Content components prop
14,591
withastro/astro
47,179
TypeScript
sarah11918
matthewp
getHeadings(): MarkdownHeading[]; default: AstroComponentFactory; } export interface MDXInstance<T extends Record<string, any>> extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent'> { components: Record<string, AstroComponentFactory> | undefined; } /** * Props accepted by the MDX `Content` componen...
Calling @ArmandPhilippot -- I don't think we document Markdown or MDX types, really. So, nothing to update, but is this something we should have?
getHeadings(): MarkdownHeading[]; default: AstroComponentFactory; } export interface MDXInstance<T extends Record<string, any>> extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent'> { components: Record<string, AstroComponentFactory> | undefined; } /** * Props accepted by the MDX `Content` componen...
@@ -33,6 +33,33 @@ export interface MDXInstance<T extends Record<string, any>> components: Record<string, AstroComponentFactory> | undefined; } +/** + * Props accepted by the MDX `Content` component when using `await render()`. + * Allows passing custom components to override default MDX element rendering. + * + *...
packages/astro/src/types/public/content.ts
26
TypeScript
0.571
question
145
51
51
false
feat(mdx): add TypeScript types for Content components prop
14,591
withastro/astro
47,179
TypeScript
sarah11918
matthewp
import { renderers } from 'virtual:astro:renderers'; import { routes } from 'virtual:astro:routes'; import { manifest as serializedManifest } from 'virtual:astro:serialized-manifest'; import { App } from './app.js'; import type { BaseApp } from './base.js'; import { DevApp } from './dev/app.js'; import { createConsoleL...
[Ditto](https://github.com/withastro/astro/blob/1fcab2434fa73d41cf308f4de62cecd1c3d296c7/packages/astro/src/core/app/base.ts#L118)
import { renderers } from 'virtual:astro:renderers'; import { routes } from 'virtual:astro:routes'; import { manifest as serializedManifest } from 'virtual:astro:serialized-manifest'; import { App } from './app.js'; import type { BaseApp } from './base.js'; import { DevApp } from './dev/app.js'; import { createConsoleL...
@@ -5,16 +5,27 @@ import { App } from './app.js'; import type { BaseApp } from './base.js'; import { DevApp } from './dev/app.js'; import { createConsoleLogger } from './logging.js'; +import type { SSRManifest } from './types.js'; const actions = async () => { return await import('virtual:astro:actions/entrypoi...
packages/astro/src/core/app/entrypoint.ts
17
TypeScript
0.357
suggestion
131
33
25
false
refactor: support middleware in entrypoint
14,616
withastro/astro
47,179
TypeScript
ematipico
ematipico
import { renderers } from 'virtual:astro:renderers'; import { routes } from 'virtual:astro:routes'; import { manifest as serializedManifest } from 'virtual:astro:serialized-manifest'; import { App } from './app.js'; import type { BaseApp } from './base.js'; import { DevApp } from './dev/app.js'; import { createConsoleL...
knitpick ```suggestion const manifest: SSRManifest = Object.assign(serializedManifest, { renderers, actions: () => import('virtual:astro:actions/entrypoint'), middleware: () => import('virtual:astro:middleware'), routes, }); ```
import { renderers } from 'virtual:astro:renderers'; import { routes } from 'virtual:astro:routes'; import { manifest as serializedManifest } from 'virtual:astro:serialized-manifest'; import { App } from './app.js'; import type { BaseApp } from './base.js'; import { DevApp } from './dev/app.js'; import { createConsoleL...
@@ -5,16 +5,27 @@ import { App } from './app.js'; import type { BaseApp } from './base.js'; import { DevApp } from './dev/app.js'; import { createConsoleLogger } from './logging.js'; +import type { SSRManifest } from './types.js'; const actions = async () => { return await import('virtual:astro:actions/entrypoi...
packages/astro/src/core/app/entrypoint.ts
23
TypeScript
0.786
suggestion
232
33
25
false
refactor: support middleware in entrypoint
14,616
withastro/astro
47,179
TypeScript
florian-lefebvre
ematipico
import { MiddlewareCantBeLoaded } from '../errors/errors-data.js'; import { AstroError } from '../errors/index.js'; import type { ModuleLoader } from '../module-loader/index.js'; import { MIDDLEWARE_MODULE_ID } from './vite-plugin.js'; /** * It accepts a module loader and the astro settings, and it attempts to load t...
I think this should still import `MIDDLEWARE_MODULE_ID` to let Vite handle the module resolution. I'd be happy to be proved wrong tho
import { MiddlewareCantBeLoaded } from '../errors/errors-data.js'; import { AstroError } from '../errors/index.js'; import type { ModuleLoader } from '../module-loader/index.js'; import { MIDDLEWARE_RESOLVED_MODULE_ID } from './vite-plugin.js'; /** * It accepts a module loader and the astro settings, and it attempts ...
@@ -10,7 +10,7 @@ import { MIDDLEWARE_MODULE_ID } from './vite-plugin.js'; */ export async function loadMiddleware(moduleLoader: ModuleLoader) { try { - return await moduleLoader.import(MIDDLEWARE_MODULE_ID); + return await moduleLoader.import(MIDDLEWARE_RESOLVED_MODULE_ID);
packages/astro/src/core/middleware/loadMiddleware.ts
13
TypeScript
0.714
bug
133
19
19
false
refactor: support middleware in entrypoint
14,616
withastro/astro
47,179
TypeScript
florian-lefebvre
ematipico
import { fileExtension, joinPaths, prependForwardSlash } from '../../../core/path.js'; import type { AssetsPrefix } from '../../../types/public/index.js'; import { getAssetsPrefix } from '../../utils/getAssetsPrefix.js'; import type { UrlResolver } from '../definitions.js'; export function createDevUrlResolver({ base...
```suggestion export function createDevUrlResolver({ base, searchParams, }: { base: string; searchParams: URLSearchParams | undefined; }): UrlResolver { let resolved = false; return { resolve(hash) { resolved ||= true; let url = prependForwardSlash(joinPaths(base, hash)); // Append searchParams if ava...
import { fileExtension, joinPaths, prependForwardSlash } from '../../../core/path.js'; import type { AssetsPrefix } from '../../../types/public/index.js'; import { getAssetsPrefix } from '../../utils/getAssetsPrefix.js'; import { createPlaceholderURL, stringifyPlaceholderURL } from '../../utils/url.js'; import type { U...
@@ -3,12 +3,28 @@ import type { AssetsPrefix } from '../../../types/public/index.js'; import { getAssetsPrefix } from '../../utils/getAssetsPrefix.js'; import type { UrlResolver } from '../definitions.js'; -export function createDevUrlResolver({ base }: { base: string }): UrlResolver { +export function createDevUrl...
packages/astro/src/assets/fonts/implementations/url-resolver.ts
25
TypeScript
0.929
suggestion
522
50
50
false
Add support for skew protect for images and fonts
14,627
withastro/astro
47,179
TypeScript
florian-lefebvre
matthewp
assetQueryParams, }: { base: string; assetsPrefix: AssetsPrefix; assetQueryParams?: URLSearchParams; }): UrlResolver { const resources = new Set<string>(); return { resolve(hash) { const prefix = assetsPrefix ? getAssetsPrefix(fileExtension(hash), assetsPrefix) : undefined; let url: string; if (prefix)...
```suggestion export function createBuildUrlResolver({ base, assetsPrefix, searchParams, }: { base: string; assetsPrefix: AssetsPrefix; searchParams: URLSearchParams | undefined; }): UrlResolver { const resources = new Set<string>(); return { resolve(hash) { const prefix = assetsPrefix ? getAssetsPrefix(fi...
}: { base: string; assetsPrefix: AssetsPrefix; searchParams: URLSearchParams; }): UrlResolver { const resources = new Set<string>(); return { resolve(hash) { const prefix = assetsPrefix ? getAssetsPrefix(fileExtension(hash), assetsPrefix) : undefined; let urlPath: string; if (prefix) { resources.add...
@@ -19,20 +35,34 @@ export function createDevUrlResolver({ base }: { base: string }): UrlResolver { export function createBuildUrlResolver({ base, assetsPrefix, + assetQueryParams, }: { base: string; assetsPrefix: AssetsPrefix; + assetQueryParams?: URLSearchParams; }): UrlResolver { const resources = new S...
packages/astro/src/assets/fonts/implementations/url-resolver.ts
26
TypeScript
0.929
suggestion
801
35
32
false
Add support for skew protect for images and fonts
14,627
withastro/astro
47,179
TypeScript
florian-lefebvre
matthewp
if ( isLocalService(service) && globalThis.astroAsset.addStaticImage && !(isRemoteImage(validatedOptions.src) && imageURL === validatedOptions.src) ) { const propsToHash = service.propertiesToHash ?? DEFAULT_HASH_PROPS; imageURL = globalThis.astroAsset.addStaticImage( validatedOptions, propsToHash, ...
It it has a search param already, shouldn't we append?
if ( isLocalService(service) && globalThis.astroAsset.addStaticImage && !(isRemoteImage(validatedOptions.src) && imageURL === validatedOptions.src) ) { const propsToHash = service.propertiesToHash ?? DEFAULT_HASH_PROPS; imageURL = globalThis.astroAsset.addStaticImage( validatedOptions, propsToHash, ...
@@ -206,6 +207,22 @@ export async function getImage( attributes: srcSet.attributes, }; }); + } else if (imageConfig.assetQueryParams) { + // For SSR-rendered images without addStaticImage, append assetQueryParams manually + const assetQueryString = imageConfig.assetQueryParams.toString(); + if (assetQuer...
packages/astro/src/assets/internal.ts
26
TypeScript
0.286
question
54
51
51
false
Add support for skew protect for images and fonts
14,627
withastro/astro
47,179
TypeScript
florian-lefebvre
matthewp
finalFilePath = transformForHash.finalPath; } else { finalFilePath = prependForwardSlash( joinPaths( isESMImportedImage(options.src) ? '' : settings.config.build.assets, prependForwardSlash(propsToFilename(finalOriginalPath, options, hash)), ), ); if (!transformsForPath) { globalThi...
Wouldn't it be safer to work with a `URL` type instead?
if (transformsForPath && transformForHash) { finalFilePath = transformForHash.finalPath; } else { finalFilePath = prependForwardSlash( joinPaths( isESMImportedImage(options.src) ? '' : settings.config.build.assets, prependForwardSlash(propsToFilename(finalOriginalPath, options, hash)), ), ...
@@ -85,11 +85,23 @@ const addStaticImageFactory = ( // The paths here are used for URLs, so we need to make sure they have the proper format for an URL // (leading slash, prefixed with the base / assets prefix, encoded, etc) + let url: string;
packages/astro/src/assets/vite-plugin-assets.ts
26
TypeScript
0.571
question
56
51
51
false
Add support for skew protect for images and fonts
14,627
withastro/astro
47,179
TypeScript
ematipico
matthewp
return import.meta.resolve(builtinDrivers.fsLite, import.meta.url); } if (driver in builtinDrivers) { return import.meta.resolve(builtinDrivers[driver as BuiltinDriverName], import.meta.url); } } catch { return null; } return driver; } export function vitePluginSessionDriver({ settings }: { settings:...
Should we use `this.resolve()` instead?
import { type BuiltinDriverName, builtinDrivers } from 'unstorage'; import type { Plugin as VitePlugin } from 'vite'; import type { AstroSettings } from '../../types/astro.js'; export const VIRTUAL_SESSION_DRIVER_ID = 'virtual:astro:session-driver'; const RESOLVED_VIRTUAL_SESSION_DRIVER_ID = '\0' + VIRTUAL_SESSION_DRI...
@@ -0,0 +1,52 @@ +import { type BuiltinDriverName, builtinDrivers } from 'unstorage'; +import type { Plugin as VitePlugin } from 'vite'; +import type { AstroSettings } from '../../types/astro.js'; + +export const VIRTUAL_SESSION_DRIVER_ID = 'virtual:astro:session-driver'; +export const RESOLVED_VIRTUAL_SESSION_DRIVER_I...
packages/astro/src/core/session/vite-plugin.ts
26
TypeScript
0.286
question
39
40
37
false
refactor(sessions): import driver via vite plugin
14,632
withastro/astro
47,179
TypeScript
florian-lefebvre
ematipico
import type { AstroSettings } from '../../types/astro.js'; export const VIRTUAL_SESSION_DRIVER_ID = 'virtual:astro:session-driver'; export const RESOLVED_VIRTUAL_SESSION_DRIVER_ID = '\0' + VIRTUAL_SESSION_DRIVER_ID; function resolveSessionDriver(driver: string | undefined): string | null { if (!driver) { return nu...
Maybe? We do this in a couple of places ```suggestion name: VIRTUAL_SESSION_DRIVER_ID, ```
import type { AstroSettings } from '../../types/astro.js'; export const VIRTUAL_SESSION_DRIVER_ID = 'virtual:astro:session-driver'; const RESOLVED_VIRTUAL_SESSION_DRIVER_ID = '\0' + VIRTUAL_SESSION_DRIVER_ID; export function vitePluginSessionDriver({ settings }: { settings: AstroSettings }): VitePlugin { return { ...
@@ -0,0 +1,52 @@ +import { type BuiltinDriverName, builtinDrivers } from 'unstorage'; +import type { Plugin as VitePlugin } from 'vite'; +import type { AstroSettings } from '../../types/astro.js'; + +export const VIRTUAL_SESSION_DRIVER_ID = 'virtual:astro:session-driver'; +export const RESOLVED_VIRTUAL_SESSION_DRIVER_I...
packages/astro/src/core/session/vite-plugin.ts
26
TypeScript
0.571
suggestion
92
51
35
false
refactor(sessions): import driver via vite plugin
14,632
withastro/astro
47,179
TypeScript
florian-lefebvre
ematipico
if (this.manifest.checkOrigin) { // this middleware must be placed at the beginning because it needs to block incoming requests internalMiddlewares.unshift(createOriginCheckMiddleware()); } this.resolvedMiddleware = sequence(...internalMiddlewares); return this.resolvedMiddleware; } else { this...
This types are repeated a few times, could it be possible to extract the type and reuse it? Eg. ```ts import type { Driver } from 'unstorage' export type SessionDriver = (config: any) => Driver // elsewhere sessionDriver?: () => Promise<{ default: SessionDriver | null }>; resolvedSessionDriver: | SessionDriver | ...
internalMiddlewares.unshift(createOriginCheckMiddleware()); } this.resolvedMiddleware = sequence(...internalMiddlewares); return this.resolvedMiddleware; } else { this.resolvedMiddleware = NOOP_MIDDLEWARE_FN; return this.resolvedMiddleware; } } setActions(actions: SSRActions) { this.resolved...
@@ -140,6 +145,24 @@ export abstract class Pipeline { return NOOP_ACTIONS_MOD; } + async getSessionDriver(): Promise<((config: any) => import('unstorage').Driver) | null> {
packages/astro/src/core/base-pipeline.ts
26
TypeScript
1
refactor
414
51
51
false
refactor(sessions): import driver via vite plugin
14,632
withastro/astro
47,179
TypeScript
florian-lefebvre
ematipico
import { renderers } from 'virtual:astro:renderers'; import { routes } from 'virtual:astro:routes'; import { manifest as serializedManifest } from 'virtual:astro:serialized-manifest'; import type { RouteInfo } from '../core/app/types.js'; import { Logger } from '../core/logger/core.js'; import { nodeLogDestination } fr...
```suggestion sessionDriver: () => import('virtual:astro:session-driver'), ```
import { renderers } from 'virtual:astro:renderers'; import { routes } from 'virtual:astro:routes'; import { manifest as serializedManifest } from 'virtual:astro:serialized-manifest'; import type { RouteInfo } from '../core/app/types.js'; import { Logger } from '../core/logger/core.js'; import { nodeLogDestination } fr...
@@ -22,7 +22,10 @@ export default async function createExports( const routesList: RoutesList = { routes: routes.map((r: RouteInfo) => r.routeData) }; // Merge renderers into the serialized manifest - const manifest = Object.assign(serializedManifest, { renderers }); + const manifest = Object.assign(serializedMani...
packages/astro/src/vite-plugin-app/createExports.ts
26
TypeScript
0.571
suggestion
80
41
41
false
refactor(sessions): import driver via vite plugin
14,632
withastro/astro
47,179
TypeScript
florian-lefebvre
ematipico
import { stringify as rawStringify, unflatten as rawUnflatten } from 'devalue'; import { type BuiltinDriverOptions, createStorage, type Driver, type Storage } from 'unstorage'; import type { ResolvedSessionConfig, RuntimeMode, SessionConfig, SessionDriverName, } from '../types/public/config.js'; import type { Astr...
Is the type not `SessionConfig<TDriver>['options']` like below?
import { stringify as rawStringify, unflatten as rawUnflatten } from 'devalue'; import { type BuiltinDriverOptions, createStorage, type Driver, type Storage } from 'unstorage'; import type { ResolvedSessionConfig, RuntimeMode, SessionConfig, SessionDriverName, } from '../types/public/config.js'; import type { Astr...
@@ -23,6 +16,8 @@ export const PERSIST_SYMBOL = Symbol(); const DEFAULT_COOKIE_NAME = 'astro-session'; const VALID_COOKIE_REGEX = /^[\w-]+$/; +export type SessionDriver = (config: any) => import('unstorage').Driver;
packages/astro/src/core/session.ts
19
TypeScript
0.5
question
63
44
44
false
refactor(sessions): import driver via vite plugin
14,632
withastro/astro
47,179
TypeScript
matthewp
ematipico
sessionConfig?: ResolvedSessionConfig<any>; cacheDir: URL; srcDir: URL; outDir: URL; rootDir: URL; publicDir: URL; buildClientDir: URL; buildServerDir: URL; csp: SSRManifestCSP | undefined; devToolbar: { // This should always be false in prod/SSR enabled: boolean; /** * Latest version of Astro, will ...
I don't think this type is useful, it's only used in one place
sessionConfig?: ResolvedSessionConfig<any>; cacheDir: URL; srcDir: URL; outDir: URL; rootDir: URL; publicDir: URL; buildClientDir: URL; buildServerDir: URL; csp: SSRManifestCSP | undefined; devToolbar: { // This should always be false in prod/SSR enabled: boolean; /** * Latest version of Astro, will ...
@@ -111,6 +113,8 @@ export type SSRManifest = { }; }; +export type SSRSessionDriver = SessionDriver | null;
packages/astro/src/core/app/types.ts
26
TypeScript
0.429
suggestion
62
51
51
false
refactor(sessions): import driver via vite plugin
14,632
withastro/astro
47,179
TypeScript
florian-lefebvre
ematipico
if (this.manifest.checkOrigin) { // this middleware must be placed at the beginning because it needs to block incoming requests internalMiddlewares.unshift(createOriginCheckMiddleware()); } this.resolvedMiddleware = sequence(...internalMiddlewares); return this.resolvedMiddleware; } else { this...
```suggestion async getSessionDriver(): Promise<SessionDriver | null> { ```
// this middleware must be placed at the beginning because it needs to block incoming requests internalMiddlewares.unshift(createOriginCheckMiddleware()); } this.resolvedMiddleware = sequence(...internalMiddlewares); return this.resolvedMiddleware; } else { this.resolvedMiddleware = NOOP_MIDDLEWAR...
@@ -140,6 +144,24 @@ export abstract class Pipeline { return NOOP_ACTIONS_MOD; } + async getSessionDriver(): Promise<SSRSessionDriver> {
packages/astro/src/core/base-pipeline.ts
26
TypeScript
0.714
suggestion
76
51
51
false
refactor(sessions): import driver via vite plugin
14,632
withastro/astro
47,179
TypeScript
florian-lefebvre
ematipico
enforce: 'after-user-plugins', vitePlugin: vitePlugin, }; }, 'build:post': async () => { if (!ssr) { return; } if (!internals.ssrEntryChunk) { throw new Error(`Did not generate an entry chunk for SSR`); } // Mutate the filename internals.ssrEntryChunk.fileName = op...
Please let's use the const to reduce errors. We can import it from `manifest/serialized.js`
} return { enforce: 'after-user-plugins', vitePlugin: vitePlugin, }; }, 'build:post': async () => { if (!ssr) { return; } if (!internals.ssrEntryChunk) { throw new Error(`Did not generate an entry chunk for SSR`); } // Mutate the filename internals.ssrEntr...
@@ -169,7 +170,7 @@ function generateSSRCode(adapter: AstroAdapter) { const imports = [ `import { renderers } from '${ASTRO_RENDERERS_MODULE_ID}';`, `import * as serverEntrypointModule from '${ADAPTER_VIRTUAL_MODULE_ID}';`, - `import { manifest as defaultManifest } from '${SSR_MANIFEST_VIRTUAL_MODULE_ID}';`, +...
packages/astro/src/core/build/plugins/plugin-ssr.ts
26
TypeScript
0.571
suggestion
91
51
51
false
Get demo app deploying to Cloudflare
14,634
withastro/astro
47,179
TypeScript
ematipico
matthewp
throw new Error(`Did not generate an entry chunk for SSR`); } // Mutate the filename internals.ssrEntryChunk.fileName = options.settings.config.build.serverEntry; }, }, }; } function generateSSRCode(adapter: AstroAdapter) { const edgeMiddleware = adapter?.adapterFeatures?.edgeMiddleware ?? fals...
Why are these removed? I may know why, and if so, we should remove `middleware` too.
} if (!internals.ssrEntryChunk) { throw new Error(`Did not generate an entry chunk for SSR`); } // Mutate the filename internals.ssrEntryChunk.fileName = options.settings.config.build.serverEntry; }, }, }; } function generateSSRCode(adapter: AstroAdapter) { const edgeMiddleware = adapt...
@@ -178,13 +179,11 @@ function generateSSRCode(adapter: AstroAdapter) { `const _manifest = Object.assign(defaultManifest, {`, ` pageMap,`, ` serverIslandMap,`, - ` renderers,`, - ` actions: () => import("${ENTRYPOINT_VIRTUAL_MODULE_ID}"),`,
packages/astro/src/core/build/plugins/plugin-ssr.ts
26
TypeScript
0.429
question
85
51
51
false
Get demo app deploying to Cloudflare
14,634
withastro/astro
47,179
TypeScript
ematipico
matthewp
}: { settings: AstroSettings; command: 'dev' | 'build'; }): Plugin { return { name: SERIALIZED_MANIFEST_ID, enforce: 'pre', resolveId(id) { if (id === SERIALIZED_MANIFEST_ID) { return SERIALIZED_MANIFEST_RESOLVED_ID; } }, async load(id) { if (id === SERIALIZED_MANIFEST_RESOLVED_ID) { let...
Can we add a comment that explains this part? Especially the first `if` branch, where we have `"'@@ASTRO_MANIFEST_REPLACE@@'"`. We want to explain why, and add a link to where it's used. Also, to reduce the chances of error, we have already ```js const manifestReplace = '@@ASTRO_MANIFEST_REPLACE@@'; ``` in...
command, }: { settings: AstroSettings; command: 'dev' | 'build'; }): Plugin { return { name: SERIALIZED_MANIFEST_ID, enforce: 'pre', resolveId(id) { if (id === SERIALIZED_MANIFEST_ID) { return SERIALIZED_MANIFEST_RESOLVED_ID; } }, async load(id) { if (id === SERIALIZED_MANIFEST_RESOLVED_ID)...
@@ -35,10 +38,16 @@ export async function serializedManifestPlugin({ async load(id) { if (id === SERIALIZED_MANIFEST_RESOLVED_ID) { - const serialized = await createSerializedManifest(settings); + let manifestData: string; + if (command === 'build') { + manifestData = "'@@ASTRO_MANIFEST_REPLACE@@'...
packages/astro/src/manifest/serialized.ts
26
TypeScript
1
question
400
51
51
false
Get demo app deploying to Cloudflare
14,634
withastro/astro
47,179
TypeScript
ematipico
matthewp
import { baseMiddleware } from './base.js'; import { createController } from './controller.js'; import { recordServerError } from './error.js'; import { setRouteError } from './server-state.js'; import { trailingSlashMiddleware } from './trailing-slash.js'; interface AstroPluginOptions { settings: AstroSettings; log...
Can we do this for clarity? I was confused for a sec because `createApp` has another meaning somewhere else ```suggestion const { default: createAstroServerApp } = await viteServer.environments.ssr.runner.import(ASTRO_DEV_APP_ID); ```
import { baseMiddleware } from './base.js'; import { createController } from './controller.js'; import { recordServerError } from './error.js'; import { setRouteError } from './server-state.js'; import { trailingSlashMiddleware } from './trailing-slash.js'; interface AstroPluginOptions { settings: AstroSettings; log...
@@ -52,10 +54,10 @@ export default function createVitePluginAstroServer({ } const loader = createViteLoader(viteServer); - const createExports = await loader.import('astro:app'); + const createApp = await viteServer.environments.ssr.runner.import(ASTRO_DEV_APP_ID);
packages/astro/src/vite-plugin-astro-server/plugin.ts
26
TypeScript
0.857
question
237
51
51
false
refactor(core): clean up of apps
14,637
withastro/astro
47,179
TypeScript
florian-lefebvre
ematipico
// In this block of code we group routes based on their locale // A map like: locale => RouteData[] const routesByLocale = new Map<string, RouteData[]>(); // This type is here only as a helper. We copy the routes and make them unique, so we don't "process" the same route twice. // The assumption is that a ro...
I believe we need stricter, more refined checks. The new code assumes the `locale` is always at the start of the route, which isn't always the case. What do you think about this alternative: ```js const hasLocaleInRoute = route.route.split('/').some(routePath => routePath === locale); if (!hasLocaleInRoute && ...
// In this block of code we group routes based on their locale // A map like: locale => RouteData[] const routesByLocale = new Map<string, RouteData[]>(); // This type is here only as a helper. We copy the routes and make them unique, so we don't "process" the same route twice. // The assumption is that a ro...
@@ -581,7 +581,7 @@ export async function createRoutesList( }); for (const locale of filteredLocales) { for (const route of setRoutes) { - if (!route.route.includes(`/${locale}`)) { + if (!route.route.startsWith(`/${locale}/`) && route.route !== `/${locale}`) {
packages/astro/src/core/routing/manifest/create.ts
26
TypeScript
0.786
suggestion
359
51
51
false
fix(i18n): generate fallbacks for pages with filenames containing locale keys
14,690
withastro/astro
47,179
TypeScript
ematipico
fredriknorlin
import { renderers } from 'virtual:astro:renderers'; import { routes } from 'virtual:astro:routes'; import { manifest as serializedManifest } from 'virtual:astro:serialized-manifest'; import { App } from './app.js'; import type { BaseApp } from './base.js'; import { DevApp } from './dev/app.js'; import { createConsoleL...
May need to add a todo comment so we don't forget
import { renderers } from 'virtual:astro:renderers'; import { routes } from 'virtual:astro:routes'; import { manifest as serializedManifest } from 'virtual:astro:serialized-manifest'; import { App } from './app.js'; import type { BaseApp } from './base.js'; import { DevApp } from './dev/app.js'; import { createConsoleL...
@@ -11,7 +11,7 @@ const manifest: SSRManifest = Object.assign(serializedManifest, { renderers, actions: () => import('virtual:astro:actions/entrypoint'), middleware: () => import('virtual:astro:middleware'), - sessionDriver: () => import('virtual:astro:session-driver'), + sessionDriver: () => null,
packages/astro/src/core/app/entrypoint.ts
15
TypeScript
0.071
suggestion
49
26
27
false
refactor: fonts
14,694
withastro/astro
47,179
TypeScript
florian-lefebvre
ematipico
export function vitePluginSessionDriver({ settings }: { settings: AstroSettings }): VitePlugin { return { name: VIRTUAL_SESSION_DRIVER_ID, enforce: 'pre', async resolveId(id) { if (id === VIRTUAL_SESSION_DRIVER_ID) { return RESOLVED_VIRTUAL_SESSION_DRIVER_ID; } }, async load(id) { if (id === R...
Should this be an AstroError eventually? If so, we should add a todo comment
const VIRTUAL_SESSION_DRIVER_ID = 'virtual:astro:session-driver'; const RESOLVED_VIRTUAL_SESSION_DRIVER_ID = '\0' + VIRTUAL_SESSION_DRIVER_ID; export function vitePluginSessionDriver({ settings }: { settings: AstroSettings }): VitePlugin { return { name: VIRTUAL_SESSION_DRIVER_ID, enforce: 'pre', async resolve...
@@ -12,25 +13,33 @@ export function vitePluginSessionDriver({ settings }: { settings: AstroSettings async resolveId(id) { if (id === VIRTUAL_SESSION_DRIVER_ID) { + return RESOLVED_VIRTUAL_SESSION_DRIVER_ID; + } + }, + + async load(id) { + if (id === RESOLVED_VIRTUAL_SESSION_DRIVER_ID) { if (setti...
packages/astro/src/core/session/vite-plugin.ts
26
TypeScript
0.429
suggestion
76
38
50
false
feat: full sessions support w/ environment api
14,696
withastro/astro
47,179
TypeScript
florian-lefebvre
matthewp
import { fileURLToPath } from 'node:url'; import { type BuiltinDriverName, builtinDrivers } from 'unstorage'; import type { Plugin as VitePlugin } from 'vite'; import type { AstroSettings } from '../../types/astro.js'; const VIRTUAL_SESSION_DRIVER_ID = 'virtual:astro:session-driver'; const RESOLVED_VIRTUAL_SESSION_DRI...
Could we just do `export * from ${JSON.stringify(resolved.id)};`?
if (id === RESOLVED_VIRTUAL_SESSION_DRIVER_ID) { if (settings.config.session) { let sessionDriver: string; if (settings.config.session.driver === 'fs') { sessionDriver = builtinDrivers.fsLite; } else if ( settings.config.session.driver && settings.config.session.driver in builtin...
@@ -12,25 +13,33 @@ export function vitePluginSessionDriver({ settings }: { settings: AstroSettings async resolveId(id) { if (id === VIRTUAL_SESSION_DRIVER_ID) { + return RESOLVED_VIRTUAL_SESSION_DRIVER_ID; + } + }, + + async load(id) { + if (id === RESOLVED_VIRTUAL_SESSION_DRIVER_ID) { if (setti...
packages/astro/src/core/session/vite-plugin.ts
26
TypeScript
0.429
question
65
46
35
false
feat: full sessions support w/ environment api
14,696
withastro/astro
47,179
TypeScript
florian-lefebvre
matthewp
type ActionAPIContext, type ErrorInferenceObject, formContentTypes, hasContentType, isActionAPIContext, type MaybePromise, } from './utils.js'; export * from './shared.js'; export type ActionAccept = 'form' | 'json'; export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.ZodType ? (input: z...
Using ts `infer` keyword was not enough here so I had to do a little trickery
type ActionAPIContext, type ErrorInferenceObject, formContentTypes, hasContentType, isActionAPIContext, type MaybePromise, } from './utils.js'; export * from './shared.js'; export type ActionAccept = 'form' | 'json'; export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.ZodType ? (input: z...
@@ -38,6 +38,35 @@ export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.ZodTyp export type ActionReturnType<T extends ActionHandler<any, any>> = Awaited<ReturnType<T>>; +const inferSymbol = Symbol('#infer'); + +/** + * Infer the input zod schema of an action. + * + * @see https://docs.astro.bu...
packages/astro/src/actions/runtime/server.ts
26
TypeScript
0.357
suggestion
77
51
51
false
feat: Add `ActionInputSchema` utility type
14,698
withastro/astro
47,179
TypeScript
florian-lefebvre
mauriciabad
serializeActionResult, } from './shared.js'; import type { Locals } from './utils.js'; import { ACTION_API_CONTEXT_SYMBOL, type ActionAPIContext, type ErrorInferenceObject, formContentTypes, hasContentType, isActionAPIContext, type MaybePromise, } from './utils.js'; export * from './shared.js'; export type Ac...
@sarah11918 this will probably need checking as well
serializeActionResult, } from './shared.js'; import type { Locals } from './utils.js'; import { ACTION_API_CONTEXT_SYMBOL, type ActionAPIContext, type ErrorInferenceObject, formContentTypes, hasContentType, isActionAPIContext, type MaybePromise, } from './utils.js'; export * from './shared.js'; export type Ac...
@@ -38,6 +38,35 @@ export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.ZodTyp export type ActionReturnType<T extends ActionHandler<any, any>> = Awaited<ReturnType<T>>; +const inferSymbol = Symbol('#infer'); + +/**
packages/astro/src/actions/runtime/server.ts
26
TypeScript
0.214
suggestion
52
51
51
false
feat: Add `ActionInputSchema` utility type
14,698
withastro/astro
47,179
TypeScript
florian-lefebvre
mauriciabad
type ActionAPIContext, type ErrorInferenceObject, formContentTypes, hasContentType, isActionAPIContext, type MaybePromise, } from './utils.js'; export * from './shared.js'; export type ActionAccept = 'form' | 'json'; export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.ZodType ? (input: z...
I'm not sure we need an example here tbh. We don't do for this kind of things I think?
type ActionAPIContext, type ErrorInferenceObject, formContentTypes, hasContentType, isActionAPIContext, type MaybePromise, } from './utils.js'; export * from './shared.js'; export type ActionAccept = 'form' | 'json'; export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.ZodType ? (input: z...
@@ -38,6 +38,35 @@ export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.ZodTyp export type ActionReturnType<T extends ActionHandler<any, any>> = Awaited<ReturnType<T>>; +const inferSymbol = Symbol('#infer'); + +/** + * Infer the input zod schema of an action. + * + * @see https://docs.astro.bu...
packages/astro/src/actions/runtime/server.ts
26
TypeScript
0.214
question
86
51
51
false
feat: Add `ActionInputSchema` utility type
14,698
withastro/astro
47,179
TypeScript
florian-lefebvre
mauriciabad
} from './shared.js'; import type { Locals } from './utils.js'; import { ACTION_API_CONTEXT_SYMBOL, type ActionAPIContext, type ErrorInferenceObject, formContentTypes, hasContentType, isActionAPIContext, type MaybePromise, } from './utils.js'; export * from './shared.js'; export type ActionAccept = 'form' | 'j...
```suggestion * Infers the type of an action's input based on its Zod schema ```
} from './shared.js'; import type { Locals } from './utils.js'; import { ACTION_API_CONTEXT_SYMBOL, type ActionAPIContext, type ErrorInferenceObject, formContentTypes, hasContentType, isActionAPIContext, type MaybePromise, } from './utils.js'; export * from './shared.js'; export type ActionAccept = 'form' | 'j...
@@ -38,6 +38,19 @@ export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.ZodTyp export type ActionReturnType<T extends ActionHandler<any, any>> = Awaited<ReturnType<T>>; +const inferSymbol = Symbol('#infer'); + +/** + * Infer the input zod schema of an action.
packages/astro/src/actions/runtime/server.ts
26
TypeScript
0.714
suggestion
81
51
51
false
feat: Add `ActionInputSchema` utility type
14,698
withastro/astro
47,179
TypeScript
florian-lefebvre
mauriciabad
import { version as ReactVersion } from 'react-dom'; export type SupportedReactVersion = keyof typeof versionsConfig; export type ReactVersionConfig = (typeof versionsConfig)[SupportedReactVersion]; export function getReactMajorVersion(): number { const matches = /\d+\./.exec(ReactVersion); if (!matches) { return...
Flipped the logic on this so it works better as a type predicate
import { version as ReactVersion } from 'react-dom'; type SupportedReactVersion = keyof typeof versionsConfig; export type ReactVersionConfig = (typeof versionsConfig)[SupportedReactVersion]; export function getReactMajorVersion(): number { const matches = /\d+\./.exec(ReactVersion); if (!matches) { return NaN; ...
@@ -11,8 +11,10 @@ export function getReactMajorVersion(): number { return Number(matches[0]); } -export function isUnsupportedVersion(majorVersion: number) { - return majorVersion < 17 || majorVersion > 19 || Number.isNaN(majorVersion); +export function isSupportedReactVersion( + majorVersion: number, +): majorVe...
packages/integrations/react/src/version.ts
17
TypeScript
0.429
suggestion
64
34
34
false
feat: return `clientEntrypoint` from `getContainerRenderer`
14,715
withastro/astro
47,179
TypeScript
ascorbic
ascorbic
import type { DiagnosticMessage } from '@astrojs/compiler/types'; import type { CompletionItem, Diagnostic, LanguageServicePlugin, LanguageServicePluginInstance, } from '@volar/language-server'; import { CompletionItemKind, InsertTextFormat, Position, Range, TextEdit, } from '@volar/language-server'; import ty...
I can't add a suggestion for it, but you also need to remove codeLensProvider from the capabilities of this plugin!
import type { DiagnosticMessage } from '@astrojs/compiler/types'; import type { CompletionItem, Diagnostic, LanguageServicePlugin, LanguageServicePluginInstance, } from '@volar/language-server'; import { CompletionItemKind, InsertTextFormat, Position, Range, TextEdit, } from '@volar/language-server'; import ty...
@@ -14,14 +12,11 @@ import { Range, TextEdit, } from '@volar/language-server'; -import fg from 'fast-glob'; -import type { Provide } from 'volar-service-typescript'; import type { TextDocument } from 'vscode-html-languageservice'; import { URI } from 'vscode-uri'; import { AstroVirtualCode } from '../core/index...
packages/language-tools/language-server/src/plugins/astro.ts
22
TypeScript
0.429
suggestion
115
47
47
false
feat(language-server)!: remove support for Astro.glob()
14,720
withastro/astro
47,179
TypeScript
Princesseuh
florian-lefebvre
astro.resolveUrl( `/form-one?${new URLSearchParams({ enctype: 'application/x-www-form-urlencoded' })}`, ), ); // Submit the form await page.click('#submit'); expect( loads.length, 'There should be only 1 page load. No additional loads for the form submission', ).toEqual(1); expect( pos...
I think it's always a method that you have to call: https://playwright.dev/docs/api/class-request#request-is-navigation-request
astro.resolveUrl( `/form-one?${new URLSearchParams({ enctype: 'application/x-www-form-urlencoded' })}`, ), ); // Submit the form await page.click('#submit'); expect( loads.length, 'There should be only 1 page load. No additional loads for the form submission', ).toEqual(1); expect( pos...
@@ -1264,7 +1268,9 @@ test.describe('View Transitions', () => { }) => { await page.goto(astro.resolveUrl('/form-six')); page.on('request', (request) => { - expect(request.url()).toContain('/bar'); + if (request.isNavigationRequest) {
packages/astro/e2e/view-transitions.test.js
26
JavaScript
0.357
suggestion
127
51
51
false
chore: upgrade @playwright/test
14,749
withastro/astro
47,179
TypeScript
HiDeoo
florian-lefebvre
} }); // Submit the form await page.click('#submit'); }); test('form without method that includes an input with name method should not override default method', async ({ page, astro, }) => { await page.goto(astro.resolveUrl('/form-seven')); page.on('request', (request) => { if (request.isNavigat...
Nit: I wonder if having a small function in this test file, e.g. `isViteHmrRequest()` or something like that could help improve code readability here the two times we do this check, to remember why this is being done and may be relevant context for future persons reading this code or adding new tests?
} }); // Submit the form await page.click('#submit'); }); test('form without method that includes an input with name method should not override default method', async ({ page, astro, }) => { await page.goto(astro.resolveUrl('/form-seven')); page.on('request', (request) => { if (request.isNavigat...
@@ -1286,8 +1294,10 @@ test.describe('View Transitions', () => { let navigated; await page.goto(astro.resolveUrl('/form-with-hash#test')); page.on('request', (request) => { - expect(request.method()).toBe('POST'); - navigated = true; + if (request.resourceType() !== 'websocket') {
packages/astro/e2e/view-transitions.test.js
26
JavaScript
0.643
question
302
51
51
false
chore: upgrade @playwright/test
14,749
withastro/astro
47,179
TypeScript
HiDeoo
florian-lefebvre
if (hasSpecialQueries(id)) return; const parsedId = parseAstroRequest(id); // ignore astro file sub-requests, e.g. Foo.astro?astro&type=script&index=0&lang.ts if (!parsedId.filename.endsWith('.astro') || parsedId.query.astro) { // Special edge case handling for Vite 6 beta, the style dependencies need ...
@ematipico asked on Discord why we shouldn’t return a function that throws an error here, which is a good question and was the first thing I tried. I’m not 100% sure why, but when doing something like `export default () => { throw new Error('...') }`, this error was _always_ thrown on the client. I guess Astro tries...
if (hasSpecialQueries(id)) return; const parsedId = parseAstroRequest(id); // ignore astro file sub-requests, e.g. Foo.astro?astro&type=script&index=0&lang.ts if (!parsedId.filename.endsWith('.astro') || parsedId.query.astro) { // Special edge case handling for Vite 6 beta, the style dependencies need ...
@@ -227,6 +227,15 @@ export default function astro({ settings, logger }: AstroPluginOptions): vite.Pl return; } + // If an Astro component is imported in code used on the client, we return an empty + // module so that Vite doesn’t bundle the server-side Astro code for the client. + if (!options?.ssr) {...
packages/astro/src/vite-plugin-astro/index.ts
26
TypeScript
0.786
bug
379
51
51
false
Stub out `.astro` imports in client modules
14,751
withastro/astro
47,179
TypeScript
delucis
delucis
.string({ invalid_type_error: 'Content entry `id` must be a string', }) .optional(), }) .passthrough(), ), ]); const collectionConfigParser = z.union([ z.object({ type: z.literal(CONTENT_LAYER_TYPE), schema: z.any().optional(), loader: z.union([ z.function(), z.object({ nam...
Need to figure this one out with team docs
.string({ invalid_type_error: 'Content entry `id` must be a string', }) .optional(), }) .passthrough(), ), ]); const collectionConfigParser = z.union([ z.object({ type: z.literal(CONTENT_LAYER_TYPE), schema: z.any().optional(), loader: z.union([ z.function(), z.object({ nam...
@@ -60,14 +60,39 @@ const collectionConfigParser = z.union([ z.function(), z.object({ name: z.string(), - load: z.function().args(z.custom<LoaderContext>()).returns( - z.custom<{ - schema?: any; - types?: string; - } | void>(), - ), - schema: z.any().optional(), - render: z.fu...
packages/astro/src/content/utils.ts
26
TypeScript
0.071
suggestion
42
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
if (lastSynced && (Date.now() - Number(lastSynced) < 1000 * 60)) { logger.info('Skipping sync'); return; } const posts = await fetch(config.url) .then((res) => res.json()); store.clear(); for (const data of posts) { store.set({id: data.id, data}); } meta.set('lastSynced', Strin...
```suggestion types: `export interface Collection { ``` Small typo, which I guess would be more common with this approach.
if (lastSynced && (Date.now() - Number(lastSynced) < 1000 * 60)) { logger.info('Skipping sync'); return; } const posts = await fetch(config.url) .then((res) => res.json()); store.clear(); for (const data of posts) { store.set({id: data.id, data}); } meta.set('lastSynced', Strin...
@@ -31,15 +31,23 @@ export function loader(config:PostLoaderConfig): Loader { } meta.set('lastSynced', String(Date.now())); }, - schema: async () => { + getSchemaContext: async () => { // Simulate a delay await new Promise((resolve) => setTimeout(resolve, 1000)); - return z.object({ + return { ...
packages/astro/test/fixtures/content-layer/src/loaders/post-loader.ts
26
TypeScript
0.857
suggestion
130
36
36
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
HiDeoo
florian-lefebvre
/** Generates a non-cryptographic content digest. This can be used to check if the data has changed */ generateDigest(data: Record<string, unknown> | string): string; /** When running in dev, this is a filesystem watcher that can be used to trigger updates */ watcher?: FSWatcher; /** If the loader has been trigg...
```suggestion schema: T; ``` Should this be `T`?
/** Generates a non-cryptographic content digest. This can be used to check if the data has changed */ generateDigest(data: Record<string, unknown> | string): string; /** When running in dev, this is a filesystem watcher that can be used to trigger updates */ watcher?: FSWatcher; /** If the loader has been trigg...
@@ -49,14 +49,27 @@ export interface LoaderContext { entryTypes: Map<string, ContentEntryType>; } -export interface Loader { +export type Loader<T extends ZodSchema = never> = { /** Unique name of the loader, e.g. the npm package name */ name: string; /** Do the actual loading of the data */ load: (context...
packages/astro/src/content/loaders/types.ts
26
TypeScript
0.643
question
57
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
ascorbic
florian-lefebvre
function generateIdDefault({ entry, base, data }: GenerateIdOptions): string { if (data.slug) { return data.slug as string; } const entryURL = new URL(encodeURI(entry), base); const { slug } = getContentEntryIdAndSlug({ entry: entryURL, contentDir: base, collection: '', }); return slug; } function checkP...
Can we keep the explicit return type in exported functions used in user code, so it satisfies `isolatedModuleDeclarations`? We're not returning a schema, so I don't think we need inference do we?
function generateIdDefault({ entry, base, data }: GenerateIdOptions): string { if (data.slug) { return data.slug as string; } const entryURL = new URL(encodeURI(entry), base); const { slug } = getContentEntryIdAndSlug({ entry: entryURL, contentDir: base, collection: '', }); return slug; } function checkP...
@@ -57,7 +57,7 @@ function checkPrefix(pattern: string | Array<string>, prefix: string) { * @param pattern A glob pattern to match files, relative to the content directory. */ -export function glob(globOptions: GlobOptions): Loader { +export function glob(globOptions: GlobOptions) {
packages/astro/src/content/loaders/glob.ts
26
TypeScript
0.714
question
195
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
ascorbic
florian-lefebvre
return collection.loader.schema; } const result = await getSchemaContextResult(collection, collectionKey); return result?.schema; } async function typeForCollection<T extends keyof ContentConfig['collections']>( collection: ContentConfig['collections'][T] | undefined, collectionKey: T, ): Promise<{ type: string...
This isn't the filename, is it? It should be the runtime type, so with a `.js` extension
createSchemaResultCache.set(collectionKey, result); return result; } } async function getContentLayerSchema<T extends keyof ContentConfig['collections']>( collection: ContentConfig['collections'][T], collectionKey: T, ): Promise<ZodSchema | undefined> { if (collection?.type !== CONTENT_LAYER_TYPE || typeof col...
@@ -342,58 +343,68 @@ function normalizeConfigPath(from: string, to: string) { return `"${isRelativePath(configPath) ? '' : './'}${normalizedPath}"` as const; } -const schemaCache = new Map<string, ZodSchema>(); +const schemaContextResultCache = new Map<string, { schema: ZodSchema; types: string }>(); -async fun...
packages/astro/src/content/types-generator.ts
26
TypeScript
0.571
suggestion
88
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
ascorbic
florian-lefebvre
const key = JSON.parse(collectionKey); contentCollectionManifest.collections.push({ hasSchema: Boolean( collectionConfig && (collectionConfig.schema || (typeof collectionConfig.loader !== 'function' && (collectionConfig.loader.schema || schemaContextResultCache.has(collectionKey))))...
I always complain about these sort of complex nested boolean expressions. Can this be refactored, as it's too easy to mess up the logic when it's like this.
} } if (settings.config.experimental.contentIntellisense) { let contentCollectionManifest: { collections: { hasSchema: boolean; name: string }[]; entries: Record<string, string>; } = { collections: [], entries: {}, }; Object.entries(contentCollectionsMap).forEach(([collectionKey, collection]) =...
@@ -487,7 +512,12 @@ async function writeContentFiles({ const key = JSON.parse(collectionKey); contentCollectionManifest.collections.push({ - hasSchema: Boolean(collectionConfig?.schema || schemaCache.has(collectionKey)), + hasSchema: Boolean( + collectionConfig && + (collectionConfig.schema ||...
packages/astro/src/content/types-generator.ts
26
TypeScript
0.429
refactor
156
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
ascorbic
florian-lefebvre
} if (collection.loader.schema) { return collection.loader.schema; } const result = await getSchemaContextResult(collection, collectionKey); return result?.schema; } async function typeForCollection<T extends keyof ContentConfig['collections']>( collection: ContentConfig['collections'][T] | undefined, collect...
```suggestion const filename = `loaders/${collectionKey.slice(1, -1)}.js`; ```
) { const result = await collection.loader.createSchema(); createSchemaResultCache.set(collectionKey, result); return result; } } async function getContentLayerSchema<T extends keyof ContentConfig['collections']>( collection: ContentConfig['collections'][T], collectionKey: T, ): Promise<ZodSchema | undefined...
@@ -342,58 +343,68 @@ function normalizeConfigPath(from: string, to: string) { return `"${isRelativePath(configPath) ? '' : './'}${normalizedPath}"` as const; } -const schemaCache = new Map<string, ZodSchema>(); +const schemaContextResultCache = new Map<string, { schema: ZodSchema; types: string }>(); -async fun...
packages/astro/src/content/types-generator.ts
26
TypeScript
0.571
suggestion
79
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
} if (collection.loader.schema) { return collection.loader.schema; } const result = await getSchemaContextResult(collection, collectionKey); return result?.schema; } async function typeForCollection<T extends keyof ContentConfig['collections']>( collection: ContentConfig['collections'][T] | undefined, collect...
The _filename_ isn't `.js`, is it? It's just the import.
) { const result = await collection.loader.createSchema(); createSchemaResultCache.set(collectionKey, result); return result; } } async function getContentLayerSchema<T extends keyof ContentConfig['collections']>( collection: ContentConfig['collections'][T], collectionKey: T, ): Promise<ZodSchema | undefined...
@@ -342,58 +343,68 @@ function normalizeConfigPath(from: string, to: string) { return `"${isRelativePath(configPath) ? '' : './'}${normalizedPath}"` as const; } -const schemaCache = new Map<string, ZodSchema>(); +const schemaContextResultCache = new Map<string, { schema: ZodSchema; types: string }>(); -async fun...
packages/astro/src/content/types-generator.ts
26
TypeScript
0.357
suggestion
56
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
ascorbic
florian-lefebvre
const lastValue = entry?.data.lastValue ?? 0; const raw = { id: 'value', data: { lastValue: lastValue + 1, lastUpdated: new Date(), refreshContextData, slug: 'slimy' }, } const parsed = await parseData(raw) store.set({ id: raw.id, data: parsed, rendered: await ...
```suggestion types: /* ts */`export interface Collection { ```
const entry = store.get<{ lastValue: number }>('value'); const lastValue = entry?.data.lastValue ?? 0; const raw = { id: 'value', data: { lastValue: lastValue + 1, lastUpdated: new Date(), refreshContextData, slug: 'slimy' }, } const parsed = await parseData(raw) store....
@@ -226,14 +226,22 @@ const increment = defineCollection({ rendered: await renderMarkdown(markdownContent) }); }, - // Example of a loader that returns an async schema function - schema: async () => - z.object({ + getSchemaContext: async () => { + return { + schema: z.object({ lastValue: z.nu...
packages/astro/test/fixtures/content-layer/src/content.config.ts
26
TypeScript
0.714
suggestion
66
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
z .object({ id: z .string({ invalid_type_error: 'Content entry `id` must be a string', }) .optional(), }) .passthrough(), ), ]); const collectionConfigParser = z.union([ z.object({ type: z.literal(CONTENT_LAYER_TYPE), schema: z.any().optional(), loader: z.union([ z.functi...
This needs reviewing from the docs team
z .object({ id: z .string({ invalid_type_error: 'Content entry `id` must be a string', }) .optional(), }) .passthrough(), ), ]); const collectionConfigParser = z.union([ z.object({ type: z.literal(CONTENT_LAYER_TYPE), schema: z.any().optional(), loader: z.union([ z.functi...
@@ -60,14 +60,39 @@ const collectionConfigParser = z.union([ z.function(), z.object({ name: z.string(), - load: z.function().args(z.custom<LoaderContext>()).returns( - z.custom<{ - schema?: any; - types?: string; - } | void>(), - ), - schema: z.any().optional(), - render: z.fu...
packages/astro/src/content/utils.ts
26
TypeScript
0.071
suggestion
39
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
return collection.loader.schema; } const result = await getCreateSchemaResult(collection, collectionKey); return result?.schema; } async function typeForCollection<T extends keyof ContentConfig['collections']>( collection: ContentConfig['collections'][T] | undefined, collectionKey: T, ): Promise<{ type: string;...
As we renamed `getSchemaContext()` → `createSchema()` maybe it could also be worth to see if the expected type name should be renamed too? Personally, I feel like something like `Entry` may be better suited than `Collection` as the schema define the shape of a collection entry, right?
createSchemaResultCache.set(collectionKey, result); return result; } } async function getContentLayerSchema<T extends keyof ContentConfig['collections']>( collection: ContentConfig['collections'][T], collectionKey: T, ): Promise<ZodSchema | undefined> { if (collection?.type !== CONTENT_LAYER_TYPE || typeof col...
@@ -342,58 +343,68 @@ function normalizeConfigPath(from: string, to: string) { return `"${isRelativePath(configPath) ? '' : './'}${normalizedPath}"` as const; } -const schemaCache = new Map<string, ZodSchema>(); +const createSchemaResultCache = new Map<string, { schema: ZodSchema; types: string }>(); -async func...
packages/astro/src/content/types-generator.ts
26
TypeScript
0.786
question
288
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
HiDeoo
florian-lefebvre
if (lastSynced && (Date.now() - Number(lastSynced) < 1000 * 60)) { logger.info('Skipping sync'); return; } const posts = await fetch(config.url) .then((res) => res.json()); store.clear(); for (const data of posts) { store.set({id: data.id, data}); } meta.set('lastSynced', Strin...
```suggestion types: /* ts */`export interface Entry { ```
if (lastSynced && (Date.now() - Number(lastSynced) < 1000 * 60)) { logger.info('Skipping sync'); return; } const posts = await fetch(config.url) .then((res) => res.json()); store.clear(); for (const data of posts) { store.set({id: data.id, data}); } meta.set('lastSynced', Strin...
@@ -31,15 +31,23 @@ export function loader(config:PostLoaderConfig): Loader { } meta.set('lastSynced', String(Date.now())); }, - schema: async () => { + createSchema: async () => { // Simulate a delay await new Promise((resolve) => setTimeout(resolve, 1000)); - return z.object({ + return { + ...
packages/astro/test/fixtures/content-layer/src/loaders/post-loader.ts
26
TypeScript
0.714
suggestion
61
36
36
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
const lastValue = entry?.data.lastValue ?? 0; const raw = { id: 'value', data: { lastValue: lastValue + 1, lastUpdated: new Date(), refreshContextData, slug: 'slimy' }, } const parsed = await parseData(raw) store.set({ id: raw.id, data: parsed, rendered: await ...
```suggestion types: /* ts */`export interface Entry { ```
const entry = store.get<{ lastValue: number }>('value'); const lastValue = entry?.data.lastValue ?? 0; const raw = { id: 'value', data: { lastValue: lastValue + 1, lastUpdated: new Date(), refreshContextData, slug: 'slimy' }, } const parsed = await parseData(raw) store....
@@ -226,14 +226,22 @@ const increment = defineCollection({ rendered: await renderMarkdown(markdownContent) }); }, - // Example of a loader that returns an async schema function - schema: async () => - z.object({ + createSchema: async () => { + return { + schema: z.object({ lastValue: z.number...
packages/astro/test/fixtures/content-layer/src/content.config.ts
26
TypeScript
0.714
suggestion
61
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
.object({ id: z .string({ invalid_type_error: 'Content entry `id` must be a string', }) .optional(), }) .passthrough(), ), ]); const collectionConfigParser = z.union([ z.object({ type: z.literal(CONTENT_LAYER_TYPE), schema: z.any().optional(), loader: z.union([ z.function()...
```suggestion `Your loader's schema is defined using a function. This is no longer supported and the schema will be ignored. Please update your loader to use the `createSchema()` utility instead, or report this to the loader author. In a future major version, this will cause the loader to break entirely.`, ``...
.object({ id: z .string({ invalid_type_error: 'Content entry `id` must be a string', }) .optional(), }) .passthrough(), ), ]); const collectionConfigParser = z.union([ z.object({ type: z.literal(CONTENT_LAYER_TYPE), schema: z.any().optional(), loader: z.union([ z.function()...
@@ -60,14 +60,39 @@ const collectionConfigParser = z.union([ z.function(), z.object({ name: z.string(), - load: z.function().args(z.custom<LoaderContext>()).returns( - z.custom<{ - schema?: any; - types?: string; - } | void>(), - ), - schema: z.any().optional(), - render: z.fu...
packages/astro/src/content/utils.ts
26
TypeScript
0.857
security
350
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
sarah11918
florian-lefebvre
body?: string; collection: "blog"; data: InferEntrySchema<"blog">; rendered?: RenderedContent; filePath?: string;`, 'Types file does not include empty collection type', ); fixture.thenFileContentShouldInclude( '.astro/content.d.ts', `"blogMeta": Record<string, { id: string; body?: string...
```suggestion fixture.thenWarnLogsInclude("Your loader's schema is defined using a function."); ```
body?: string; collection: "blog"; data: InferEntrySchema<"blog">; rendered?: RenderedContent; filePath?: string;`, 'Types file does not include empty collection type', ); fixture.thenFileContentShouldInclude( '.astro/content.d.ts', `"blogMeta": Record<string, { id: string; body?: string...
@@ -170,6 +192,13 @@ describe('astro sync', () => { 'Types file does not include empty collection type', ); }); + + it('fails when using a loader schema function', async () => { + await fixture.load('./fixtures/content-layer-loader-schema-function/'); + fixture.clean(); + await fixture.whenSyncing();...
packages/astro/test/astro-sync.test.js
26
JavaScript
0.714
suggestion
102
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
.object({ id: z .string({ invalid_type_error: 'Content entry `id` must be a string', }) .optional(), }) .passthrough(), ), ]); const collectionConfigParser = z.union([ z.object({ type: z.literal(CONTENT_LAYER_TYPE), schema: z.any().optional(), loader: z.union([ z.function()...
```suggestion `Your loader's schema is defined using a function. This is no longer supported and the schema will be ignored. Please update your loader to use the \`createSchema()\` utility instead, or report this to the loader author. In a future major version, this will cause the loader to break entirely.`, ``...
.object({ id: z .string({ invalid_type_error: 'Content entry `id` must be a string', }) .optional(), }) .passthrough(), ), ]); const collectionConfigParser = z.union([ z.object({ type: z.literal(CONTENT_LAYER_TYPE), schema: z.any().optional(), loader: z.union([ z.function()...
@@ -60,14 +60,39 @@ const collectionConfigParser = z.union([ z.function(), z.object({ name: z.string(), - load: z.function().args(z.custom<LoaderContext>()).returns( - z.custom<{ - schema?: any; - types?: string; - } | void>(), - ), - schema: z.any().optional(), - render: z.fu...
packages/astro/src/content/utils.ts
26
TypeScript
0.857
security
321
51
51
false
feat: `loader.createSchema()`
14,759
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
this.hint = hint; this.frame = frame; } public setLocation(location: ErrorLocation): void { this.loc = location; } public setName(name: string): void { this.name = name; } public setMessage(message: string): void { this.message = message; } public setHint(hint: string): void { this.hint = hint; ...
More a stylistic thing, but I guess we might as well use optional chaining for all of these? ```suggestion return (err as AstroError)?.type === 'AstroError'; ```
this.hint = hint; this.frame = frame; } public setLocation(location: ErrorLocation): void { this.loc = location; } public setName(name: string): void { this.name = name; } public setMessage(message: string): void { this.message = message; } public setHint(hint: string): void { this.hint = hint; ...
@@ -74,7 +74,7 @@ export class AstroError extends Error { } static is(err: unknown): err is AstroError { - return (err as AstroError).type === 'AstroError'; + return err != null && (err as AstroError).type === 'AstroError';
packages/astro/src/core/errors/errors.ts
26
TypeScript
0.929
suggestion
163
51
51
false
fix(errors): add type check to error
14,769
withastro/astro
47,179
TypeScript
delucis
adriandlam
outDir: fileURLToPath(getServerOutputDirectory(settings)), } } } }; const updatedViteBuildConfig = await runHookBuildSetup({ config: settings.config, pages: internals.pagesByKeys, vite: viteBuildConfig, target: 'server', logger: opts.logger, }); const builder = await vite.createBuilder(upd...
Can we use a more functional approach? Let the function return the needed value, and then we assign it. Two issues with the current approach: - We don't know if we found what we needed - If no value is extracted, we don't handle it Here's the proposal: ```js const maybePrerenderFile = extractPrerenderEntryFile...
ssr: { build: { outDir: fileURLToPath(getServerOutputDirectory(settings)), } } } }; const updatedViteBuildConfig = await runHookBuildSetup({ config: settings.config, pages: internals.pagesByKeys, vite: viteBuildConfig, target: 'server', logger: opts.logger, }); const builder = await...
@@ -252,6 +259,9 @@ async function buildEnvironments( // Build prerender environment for static generation const prerenderOutput = await builder.build(builder.environments.prerender); + // Extract prerender entry filename and store in internals + extractPrerenderEntryFileName(internals, prerenderOutput);
packages/astro/src/core/build/static-build.ts
26
TypeScript
1
refactor
478
51
51
false
fix: resolve environment-api build issues for client & CSS
14,770
withastro/astro
47,179
TypeScript
ematipico
matthewp
if (id === SERIALIZED_MANIFEST_RESOLVED_ID) { let manifestData: string; if (command === 'build') { // Emit placeholder token that will be replaced by plugin-manifest.ts in build:post // See plugin-manifest.ts for full architecture explanation manifestData = `'${MANIFEST_REPLACE}'`; } else ...
Why was this changed? It doesn't seem correct to me, since `routes` should already have ALL the routes. I think if we're doing this, then there's a bug somewhere else.
if (id === SERIALIZED_MANIFEST_RESOLVED_ID) { let manifestData: string; if (command === 'build') { // Emit placeholder token that will be replaced by plugin-manifest.ts in build:post // See plugin-manifest.ts for full architecture explanation manifestData = `'${MANIFEST_REPLACE}'`; } else ...
@@ -68,10 +68,10 @@ export function serializedManifestPlugin({ middleware: () => import('${MIDDLEWARE_MODULE_ID}'), sessionDriver: () => import('${VIRTUAL_SESSION_DRIVER_ID}'), serverIslandMappings: () => import('${SERVER_ISLAND_MANIFEST}'), - routes, + routes: _manifest.routes ?? ro...
packages/astro/src/manifest/serialized.ts
26
TypeScript
0.714
bug
168
51
51
false
fix: resolve environment-api build issues for client & CSS
14,770
withastro/astro
47,179
TypeScript
ematipico
matthewp
import type { BaseApp } from '../app/base.js'; import type { SSRManifest } from '../app/types.js'; import { NoPrerenderedRoutesWithDomains } from '../errors/errors-data.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; import { getRedirectLocationOrThrow, routeIsRedirect } from '../redirects/index.j...
I believe we should have `prerender-entry.mjs` in a const and use that one instead. I've seen it in other places
import type { BaseApp } from '../app/base.js'; import type { SSRManifest } from '../app/types.js'; import { NoPrerenderedRoutesWithDomains } from '../errors/errors-data.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; import { getRedirectLocationOrThrow, routeIsRedirect } from '../redirects/index.j...
@@ -45,7 +45,8 @@ export async function generatePages( const generatePagesTimer = performance.now(); const ssr = options.settings.buildOutput === 'server'; // Import from the single prerender entrypoint - const prerenderEntryUrl = new URL('prerender-entry.mjs', prerenderOutputDir); + const prerenderEntryFileName ...
packages/astro/src/core/build/generate.ts
26
TypeScript
0.571
suggestion
113
51
51
false
fix: resolve environment-api build issues for client & CSS
14,770
withastro/astro
47,179
TypeScript
ematipico
matthewp
import { isESMImportedImage } from '../utils/imageKind.js'; import { baseService, type LocalImageService } from './service.js'; // Empty service used for platforms that don't support Sharp / users who don't want transformations. const noopService: LocalImageService = { ...baseService, propertiesToHash: ['src'], val...
I'm not sure if we should just override format then pass to `validateOptions` something like this. ```ts if (isESMImportedImage(options.src)) { options.format = options.src.format; } return baseService.validateOptions?.(options, imageConfig) ?? options; ```
import { baseService, type LocalImageService } from './service.js'; // Empty service used for platforms that don't support Sharp / users who don't want transformations. const noopService: LocalImageService = { ...baseService, propertiesToHash: ['src'], async validateOptions(options, imageConfig) { const newOption...
@@ -1,9 +1,19 @@ +import { isESMImportedImage } from '../utils/imageKind.js'; import { baseService, type LocalImageService } from './service.js'; // Empty service used for platforms that don't support Sharp / users who don't want transformations. const noopService: LocalImageService = { ...baseService, propert...
packages/astro/src/assets/services/noop.ts
16
TypeScript
0.857
style
262
26
22
false
fix: `passthroughImageService` generate webp
14,776
withastro/astro
47,179
TypeScript
ktym4a
ktym4a
*/ async function syncContentCollections( settings: AstroSettings, { mode, logger, fs, routesList, manifest, }: Required<Pick<SyncOptions, 'mode' | 'logger' | 'fs' | 'routesList' | 'manifest'>>, ): Promise<void> { // Needed to load content config const tempViteServer = await createServer( await create...
```suggestion // Prevent mutation by vite plugins during sync buildOutput: undefined, ```
*/ async function syncContentCollections( settings: AstroSettings, { mode, logger, fs, routesList, manifest, }: Required<Pick<SyncOptions, 'mode' | 'logger' | 'fs' | 'routesList' | 'manifest'>>, ): Promise<void> { // Needed to load content config const tempViteServer = await createServer( await create...
@@ -251,7 +251,23 @@ async function syncContentCollections( ssr: { external: [] }, logLevel: 'silent', }, - { settings, logger, mode, command: 'build', fs, sync: true, routesList, manifest }, + { + settings: { + ...settings, + buildOutput: undefined,
packages/astro/src/core/sync/index.ts
26
TypeScript
0.714
suggestion
99
51
51
false
fix: sync override settings
14,782
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
* @param {typeof fsMod} options.fs The file system * @param {LogOptions} options.logging Logging options * @return {Promise<ProcessExit>} */ async function syncContentCollections( settings: AstroSettings, { mode, logger, fs, routesList, manifest, }: Required<Pick<SyncOptions, 'mode' | 'logger' | 'fs' |...
You might want to leave a longer comment that explains why we're doing this. Also, we want to explain why some properties are overridden while some others aren't. I believe it's very important
* @param {typeof fsMod} options.fs The file system * @param {LogOptions} options.logging Logging options * @return {Promise<ProcessExit>} */ async function syncContentCollections( settings: AstroSettings, { mode, logger, fs, routesList, manifest, }: Required<Pick<SyncOptions, 'mode' | 'logger' | 'fs' |...
@@ -251,7 +251,24 @@ async function syncContentCollections( ssr: { external: [] }, logLevel: 'silent', }, - { settings, logger, mode, command: 'build', fs, sync: true, routesList, manifest }, + { + settings: {
packages/astro/src/core/sync/index.ts
26
TypeScript
0.357
suggestion
195
51
51
false
fix: sync override settings
14,782
withastro/astro
47,179
TypeScript
ematipico
florian-lefebvre
* @return {Promise<ProcessExit>} */ async function syncContentCollections( settings: AstroSettings, { mode, logger, fs, routesList, manifest, }: Required<Pick<SyncOptions, 'mode' | 'logger' | 'fs' | 'routesList' | 'manifest'>>, ): Promise<void> { // Needed to load content config const tempViteServer = ...
@ematipico can you update the suggestion to explain what's going on with the build output? ```suggestion // TODO: ```
* @return {Promise<ProcessExit>} */ async function syncContentCollections( settings: AstroSettings, { mode, logger, fs, routesList, manifest, }: Required<Pick<SyncOptions, 'mode' | 'logger' | 'fs' | 'routesList' | 'manifest'>>, ): Promise<void> { // Needed to load content config const tempViteServer = ...
@@ -251,7 +251,24 @@ async function syncContentCollections( ssr: { external: [] }, logLevel: 'silent', }, - { settings, logger, mode, command: 'build', fs, sync: true, routesList, manifest }, + { + settings: { + ...settings, + // Prevent mutation by vite plugins during sync
packages/astro/src/core/sync/index.ts
26
TypeScript
0.714
suggestion
122
51
51
false
fix: sync override settings
14,782
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
settings: AstroSettings, { mode, logger, fs, routesList, manifest, }: Required<Pick<SyncOptions, 'mode' | 'logger' | 'fs' | 'routesList' | 'manifest'>>, ): Promise<void> { // Needed to load content config const tempViteServer = await createServer( await createVite( { server: { middlewareMode: tr...
```suggestion // Sync causes font resources and style hashes to be duplicated injectedCsp: { ```
settings: AstroSettings, { mode, logger, fs, routesList, manifest, }: Required<Pick<SyncOptions, 'mode' | 'logger' | 'fs' | 'routesList' | 'manifest'>>, ): Promise<void> { // Needed to load content config const tempViteServer = await createServer( await createVite( { server: { middlewareMode: tr...
@@ -251,7 +251,24 @@ async function syncContentCollections( ssr: { external: [] }, logLevel: 'silent', }, - { settings, logger, mode, command: 'build', fs, sync: true, routesList, manifest }, + { + settings: { + ...settings, + // Prevent mutation by vite plugins during sync + buildOutpu...
packages/astro/src/core/sync/index.ts
26
TypeScript
0.929
refactor
106
51
51
false
fix: sync override settings
14,782
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
*/ async function syncContentCollections( settings: AstroSettings, { mode, logger, fs, routesList, manifest, }: Required<Pick<SyncOptions, 'mode' | 'logger' | 'fs' | 'routesList' | 'manifest'>>, ): Promise<void> { // Needed to load content config const tempViteServer = await createServer( await create...
Do you think we can achieve this using TypeScript? I know it has the type [`Readonly`](https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype)
*/ async function syncContentCollections( settings: AstroSettings, { mode, logger, fs, routesList, manifest, }: Required<Pick<SyncOptions, 'mode' | 'logger' | 'fs' | 'routesList' | 'manifest'>>, ): Promise<void> { // Needed to load content config const tempViteServer = await createServer( await create...
@@ -251,7 +251,26 @@ async function syncContentCollections( ssr: { external: [] }, logLevel: 'silent', }, - { settings, logger, mode, command: 'build', fs, sync: true, routesList, manifest }, + { + // Prevent mutation of specific properties by vite plugins during sync + settings: { + ...sett...
packages/astro/src/core/sync/index.ts
26
TypeScript
0.643
refactor
164
51
51
false
fix: sync override settings
14,782
withastro/astro
47,179
TypeScript
ematipico
florian-lefebvre
await generatePathWithLogs(path, route, integrationRoute, i, paths, false); } } } } function* eachRouteInRouteData(route: RouteData) { yield route; for (const fallbackRoute of route.fallbackRoutes) { yield fallbackRoute; } } async function getPathsForRoute( route: RouteData, componentPath: string, p...
This feels wrong, there's something incorrect. We already have the pipeline here, so why are we passing `BaseApp`? Was it a mistake? I'm not really sure about this direction. Can you please explain what's going on?
await generatePathWithLogs(path, route, integrationRoute, i, paths, false); } } } } function* eachRouteInRouteData(route: RouteData) { yield route; for (const fallbackRoute of route.fallbackRoutes) { yield fallbackRoute; } } async function getPathsForRoute( route: RouteData, componentPath: string, p...
@@ -293,10 +293,12 @@ async function getPathsForRoute( route: RouteData, componentPath: string, pageMap: Map<string, () => Promise<SinglePageBuiltModule>>, + app: BaseApp, pipeline: BuildPipeline, builtPaths: Set<string>, ): Promise<Array<string>> { - const { logger, options, routeCache, manifest } = pipelin...
packages/astro/src/core/build/generate.ts
26
TypeScript
0.571
bug
215
51
51
false
Use routeCache from the pipeline
14,794
withastro/astro
47,179
TypeScript
ematipico
matthewp
import type { Defaults, FontType } from './types.js'; export const LOCAL_PROVIDER_NAME = 'local'; export const DEFAULTS: Defaults = { weights: ['400'], styles: ['normal', 'italic'], subsets: ['cyrillic-ext', 'cyrillic', 'greek-ext', 'greek', 'vietnamese', 'latin-ext', 'latin'], // Technically serif is the browser...
Oh, I’m seeing now we _already_ didn’t include some important subsets. I think this makes sense then, as much as I dislike encoding this bias. I’d say we should _require_ setting `subsets`, but given not all providers support it, that would end up being pretty confusing I think.
import type { Defaults, FontType } from './types.js'; export const LOCAL_PROVIDER_NAME = 'local'; export const DEFAULTS: Defaults = { weights: ['400'], styles: ['normal', 'italic'], subsets: ['latin'], // Technically serif is the browser default but most websites these days use sans-serif fallbacks: ['sans-serif...
@@ -5,7 +5,7 @@ export const LOCAL_PROVIDER_NAME = 'local'; export const DEFAULTS: Defaults = { weights: ['400'], styles: ['normal', 'italic'], - subsets: ['cyrillic-ext', 'cyrillic', 'greek-ext', 'greek', 'vietnamese', 'latin-ext', 'latin'],
packages/astro/src/assets/fonts/constants.ts
8
TypeScript
0.643
suggestion
280
33
33
false
feat(fonts)!: update default subsets
14,796
withastro/astro
47,179
TypeScript
delucis
florian-lefebvre
clientAddress, prerenderedErrorPageFetch: prerenderedErrorPageFetch, }); } const pathname = this.getPathnameFromRequest(request); const defaultStatus = this.getDefaultStatusCode(routeData, pathname); let response; let session: AstroSession | undefined; try { // Load route module. We also catc...
just for debugging? likely we don't want this
clientAddress, prerenderedErrorPageFetch: prerenderedErrorPageFetch, }); } const pathname = this.getPathnameFromRequest(request); const defaultStatus = this.getDefaultStatusCode(routeData, pathname); let response; let session: AstroSession | undefined; try { // Load route module. We also catc...
@@ -417,6 +418,7 @@ export abstract class BaseApp<P extends Pipeline = AppPipeline> { session = renderContext.session; response = await renderContext.render(componentInstance); } catch (err: any) { + console.log(err);
packages/astro/src/core/app/base.ts
26
TypeScript
0.214
bug
45
51
51
false
fix: logger level and static paths params
14,799
withastro/astro
47,179
TypeScript
matthewp
ematipico
outDir: fileURLToPath(new URL('./.prerender/', out)), rollupOptions: { input: 'astro/entrypoints/prerender', output: { entryFileNames: `${PRERENDER_ENTRY_FILENAME_PREFIX}.[hash].mjs`, format: 'esm', }, }, ssr: true, }, }, client: { build: { emitAsse...
What are we fixing/adding here?
outDir: fileURLToPath(new URL('./.prerender/', out)), rollupOptions: { input: 'astro/entrypoints/prerender', output: { entryFileNames: `${PRERENDER_ENTRY_FILENAME_PREFIX}.[hash].mjs`, format: 'esm', }, }, ssr: true, }, }, client: { build: { emitAsse...
@@ -235,6 +235,7 @@ async function buildEnvironments(opts: StaticBuildOptions, internals: BuildInter entryFileNames: `${settings.config.build.assets}/[name].[hash].js`, chunkFileNames: `${settings.config.build.assets}/[name].[hash].js`, assetFileNames: `${settings.config.build.assets}/[name].[ha...
packages/astro/src/core/build/static-build.ts
26
TypeScript
0.071
question
32
51
51
false
Fix image tests crashing
14,803
withastro/astro
47,179
TypeScript
ematipico
matthewp
}; // Additional data for the dev overlay const children = `window.__astro_dev_toolbar__ = ${JSON.stringify(additionalMetadata)}`; scripts.add({ props: {}, children }); } } // TODO: We should allow adding generic HTML elements to the head, not just scripts for (const script of setting...
If possible, we shouldn't rely on the loader anymore. We actually want to move away from it eventually, because it goes in conflicts with the new architecture. In fact, it's possible we won't need this pipeline anymore once we're able to provide all the features using `DevApp`
debugInfo: await getInfoOutput({ userConfig: settings.config, print: false }), }; // Additional data for the dev overlay const children = `window.__astro_dev_toolbar__ = ${JSON.stringify(additionalMetadata)}`; scripts.add({ props: {}, children }); } } // TODO: We should allow addin...
@@ -120,7 +121,7 @@ export class AstroServerPipeline extends Pipeline { } } - const { css } = await import('virtual:astro:dev-css'); + const { css } = await loader.import(getDevCSSModuleName(routeData.component));
packages/astro/src/vite-plugin-app/pipeline.ts
26
TypeScript
0.643
suggestion
280
51
51
false
Fix image tests crashing
14,803
withastro/astro
47,179
TypeScript
ematipico
matthewp
assert.match($('script').attr('src'), /^https:\/\/cdn\.example\.com\/_astro\/.*\.js$/); }); }); describe('with custom rollup output file names', () => { before(async () => { fixture = await loadFixture({ ...defaultFixtureOptions, outDir: './dist/with-rollup-output-file-names', vite: { buil...
The PR doesn't mention anything about this change. Is it related to the CSS? If so, how does it affect it? If not, what does this change do?
assert.match($('script').attr('src'), /^https:\/\/cdn\.example\.com\/_astro\/.*\.js$/); }); }); describe('with custom rollup output file names', () => { before(async () => { fixture = await loadFixture({ ...defaultFixtureOptions, outDir: './dist/with-rollup-output-file-names', vite: { buil...
@@ -138,14 +138,20 @@ describe('External scripts in SSR', () => { vite: { build: { assetsInlineLimit: 0, - rollupOptions: { - output: { - entryFileNames: 'assets/entry.[hash].mjs', - chunkFileNames: 'assets/chunks/chunk.[hash].mjs', - assetFileNames: 'assets/asset.[hash...
packages/astro/test/ssr-script.test.js
26
JavaScript
0.429
question
141
51
51
false
Fix image tests crashing
14,803
withastro/astro
47,179
TypeScript
ematipico
matthewp
} from '../core/csp/common.js'; import { createKey, encodeKey, getEnvironmentKey, hasEnvironmentKey } from '../core/encryption.js'; import { MIDDLEWARE_MODULE_ID } from '../core/middleware/vite-plugin.js'; import { SERVER_ISLAND_MANIFEST } from '../core/server-islands/vite-plugin-server-islands.js'; import { VIRTUAL_SE...
Unfortunately, I couldn't find a way to discriminate the hashing to a certain module.
} from '../core/csp/common.js'; import { createKey, encodeKey, getEnvironmentKey, hasEnvironmentKey } from '../core/encryption.js'; import { MIDDLEWARE_MODULE_ID } from '../core/middleware/vite-plugin.js'; import { SERVER_ISLAND_MANIFEST } from '../core/server-islands/vite-plugin-server-islands.js'; import { VIRTUAL_SE...
@@ -38,6 +38,10 @@ export function serializedManifestPlugin({ name: SERIALIZED_MANIFEST_ID, enforce: 'pre', + augmentChunkHash() { + return Date.now().toString();
packages/astro/src/manifest/serialized.ts
26
TypeScript
0.286
suggestion
86
51
51
false
fix: hashing of chunks
14,811
withastro/astro
47,179
TypeScript
ematipico
ematipico
export { getRenderer as getContainerRenderer }; export default function svelteIntegration(options?: Options): AstroIntegration { return { name: '@astrojs/svelte', hooks: { 'astro:config:setup': async ({ updateConfig, addRenderer }) => { addRenderer(getRenderer()); updateConfig({ vite: { plu...
resolve.dedupe is managed by vite-plugin-svelte already for svelte and all its subpath exports.
export { getRenderer as getContainerRenderer }; export default function svelteIntegration(options?: Options): AstroIntegration { return { name: '@astrojs/svelte', hooks: { 'astro:config:setup': async ({ updateConfig, addRenderer }) => { addRenderer(getRenderer()); updateConfig({ vite: { plu...
@@ -32,13 +32,36 @@ export default function svelteIntegration(options?: Options): AstroIntegration { function configEnvironmentPlugin(): Plugin { return { name: '@astrojs/svelte:config-environment', - configEnvironment(environmentName) { - return { + configEnvironment(environmentName, options) { + const fin...
packages/integrations/svelte/src/index.ts
26
TypeScript
0.214
suggestion
95
51
49
false
fix(deps): update `@sveltejs/vite-plugin-svelte` to v6
14,821
withastro/astro
47,179
TypeScript
dominikg
ocavue
} function configEnvironmentPlugin(): Plugin { return { name: '@astrojs/svelte:config-environment', configEnvironment(environmentName, options) { const finalOptions: EnvironmentOptions = { resolve: { dedupe: ['svelte'], }, optimizeDeps: { include: [], }, }; if ( environmentN...
finalOptions.optimizeDeps.exclude is not defined above so this never does anything?
} function configEnvironmentPlugin(): Plugin { return { name: '@astrojs/svelte:config-environment', configEnvironment(environmentName, options) { if ( environmentName === 'client' || ((environmentName === 'ssr' || environmentName === 'prerender') && options.optimizeDeps?.noDiscovery === false) ...
@@ -32,13 +32,36 @@ export default function svelteIntegration(options?: Options): AstroIntegration { function configEnvironmentPlugin(): Plugin { return { name: '@astrojs/svelte:config-environment', - configEnvironment(environmentName) { - return { + configEnvironment(environmentName, options) { + const fin...
packages/integrations/svelte/src/index.ts
26
TypeScript
0.214
performance
83
41
32
false
fix(deps): update `@sveltejs/vite-plugin-svelte` to v6
14,821
withastro/astro
47,179
TypeScript
dominikg
ocavue
* * ```js * // astro.config.mjs * import { defineConfig, envField } from "astro/config" * * export default defineConfig({ * env: { * schema: { * // ... * }, * validateSecrets: true * } * }) * ``` */ validateSecrets?: boolean; }; /** * * @name p...
```suggestion * Determines the default behavior when two routes generate the same prerendered URL: ```
*/ schema?: EnvSchema; /** * @docs * @name env.validateSecrets * @type {boolean} * @default `false` * @version 5.0.0 * @description * * Whether or not to validate secrets on the server when starting the dev server or running a build. * * By default, only public variables are valida...
@@ -2029,6 +2029,20 @@ export interface AstroUserConfig< validateSecrets?: boolean; }; + /** + * + * @name prerenderConflictBehavior + * @type {'warning' | 'error' | 'ignore'} + * @default `'warning'` + * @version 6.0 + * @description + * When two routes generate the same prerendered URL, defines Astro's ...
packages/astro/src/types/public/config.ts
26
TypeScript
0.714
suggestion
106
51
51
false
feat(astro)!: stabilize failOnPrerenderConflict
14,826
withastro/astro
47,179
TypeScript
sarah11918
florian-lefebvre
* import { defineConfig, envField } from "astro/config" * * export default defineConfig({ * env: { * schema: { * // ... * }, * validateSecrets: true * } * }) * ``` */ validateSecrets?: boolean; }; /** * * @name prerenderConflictBehavior * @type {'warn...
```suggestion * - `error`: fail the build and display an error, forcing you to resolve the conflict * - `warning` (default): log a warning when conflicts occur, but build using the highest-priority route * - `ignore`: silently build using the highest-priority route when conflicts occur ```
/** * @docs * @name env.validateSecrets * @type {boolean} * @default `false` * @version 5.0.0 * @description * * Whether or not to validate secrets on the server when starting the dev server or running a build. * * By default, only public variables are validated on the server when starti...
@@ -2029,6 +2029,20 @@ export interface AstroUserConfig< validateSecrets?: boolean; }; + /** + * + * @name prerenderConflictBehavior + * @type {'warning' | 'error' | 'ignore'} + * @default `'warning'` + * @version 6.0 + * @description + * When two routes generate the same prerendered URL, defines Astro's ...
packages/astro/src/types/public/config.ts
26
TypeScript
0.929
bug
300
51
51
false
feat(astro)!: stabilize failOnPrerenderConflict
14,826
withastro/astro
47,179
TypeScript
sarah11918
florian-lefebvre
session: z .object({ driver: z.string().optional(), options: z.record(z.any()).optional(), cookie: z .object({ name: z.string().optional(), domain: z.string().optional(), path: z.string().optional(), maxAge: z.number().optional(), sameSite: z.union([z.enum(['strict', 'lax', 'non...
I wonder it should be warn instead of waring, to be a verb like the 2 other options
session: z .object({ driver: z.string().optional(), options: z.record(z.any()).optional(), cookie: z .object({ name: z.string().optional(), domain: z.string().optional(), path: z.string().optional(), maxAge: z.number().optional(), sameSite: z.union([z.enum(['strict', 'lax', 'non...
@@ -463,6 +463,10 @@ export const AstroConfigSchema = z.object({ ttl: z.number().optional(), }) .optional(), + prerenderConflictBehavior: z + .enum(['error', 'warning', 'ignore'])
packages/astro/src/core/config/schemas/base.ts
26
TypeScript
0.286
suggestion
83
51
51
false
feat(astro)!: stabilize failOnPrerenderConflict
14,826
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
// paths to ensure routing priority rules are enforced in the final build. const matchedRoute = matchRoute(decodeURI(staticPath), options.routesList); if (!matchedRoute) { // No route matched this path, so we can skip it. return false; } if (matchedRoute === route) { // Current rout...
```suggestion } else if (config.prerenderConflictBehavior === 'warn') { ```
// paths to ensure routing priority rules are enforced in the final build. const matchedRoute = matchRoute(decodeURI(staticPath), options.routesList); if (!matchedRoute) { // No route matched this path, so we can skip it. return false; } if (matchedRoute === route) { // Current rout...
@@ -422,7 +422,7 @@ async function getPathsForRoute( ), hint: AstroErrorData.PrerenderRouteConflict.hint(matchedRoute.route, route.route), }); - } else { + } else if (config.prerenderConflictBehavior === 'warning') {
packages/astro/src/core/build/generate.ts
26
TypeScript
0.571
suggestion
81
51
51
false
feat(astro)!: stabilize failOnPrerenderConflict
14,826
withastro/astro
47,179
TypeScript
sarah11918
florian-lefebvre
}, devToolbar: { enabled: true, }, compressHTML: true, server: { host: false, port: 4321, open: false, allowedHosts: [], }, integrations: [], markdown: markdownConfigDefaults, vite: {}, legacy: {}, redirects: {}, security: { checkOrigin: true, allowedDomains: [], }, env: { schema: {}, va...
```suggestion prerenderConflictBehavior: 'warn', ```
}, devToolbar: { enabled: true, }, compressHTML: true, server: { host: false, port: 4321, open: false, allowedHosts: [], }, integrations: [], markdown: markdownConfigDefaults, vite: {}, legacy: {}, redirects: {}, security: { checkOrigin: true, allowedDomains: [], }, env: { schema: {}, va...
@@ -95,12 +95,12 @@ export const ASTRO_CONFIG_DEFAULTS = { validateSecrets: false, }, session: undefined, + prerenderConflictBehavior: 'warning',
packages/astro/src/core/config/schemas/base.ts
26
TypeScript
0.571
suggestion
55
51
51
false
feat(astro)!: stabilize failOnPrerenderConflict
14,826
withastro/astro
47,179
TypeScript
sarah11918
florian-lefebvre
*/ compressHTML?: boolean; /** * @docs * @name scopedStyleStrategy * @type {('where' | 'class' | 'attribute')} * @default `'attribute'` * @version 2.4 * @description * * Specify the strategy used for scoping styles within Astro components. Choose from: * - `'where'` - Use `:where` selectors, ...
```suggestion * @type {'warn' | 'error' | 'ignore'} ```
*/ compressHTML?: boolean; /** * @docs * @name scopedStyleStrategy * @type {('where' | 'class' | 'attribute')} * @default `'attribute'` * @version 2.4 * @description * * Specify the strategy used for scoping styles within Astro components. Choose from: * - `'where'` - Use `:where` selectors, ...
@@ -547,6 +547,20 @@ export interface AstroUserConfig< */ scopedStyleStrategy?: 'where' | 'class' | 'attribute'; + /** + * + * @name prerenderConflictBehavior + * @type {'warning' | 'error' | 'ignore'}
packages/astro/src/types/public/config.ts
26
TypeScript
0.714
suggestion
59
51
51
false
feat(astro)!: stabilize failOnPrerenderConflict
14,826
withastro/astro
47,179
TypeScript
sarah11918
florian-lefebvre
* @type {('where' | 'class' | 'attribute')} * @default `'attribute'` * @version 2.4 * @description * * Specify the strategy used for scoping styles within Astro components. Choose from: * - `'where'` - Use `:where` selectors, causing no specificity increase. * - `'class'` - Use class-based selec...
```suggestion * - `warn` (default): log a warning when conflicts occur, but build using the highest-priority route ```
* @type {('where' | 'class' | 'attribute')} * @default `'attribute'` * @version 2.4 * @description * * Specify the strategy used for scoping styles within Astro components. Choose from: * - `'where'` - Use `:where` selectors, causing no specificity increase. * - `'class'` - Use class-based selec...
@@ -547,6 +547,20 @@ export interface AstroUserConfig< */ scopedStyleStrategy?: 'where' | 'class' | 'attribute'; + /** + * + * @name prerenderConflictBehavior + * @type {'warning' | 'error' | 'ignore'} + * @default `'warning'` + * @version 6.0 + * @description + * Determines the default behavior when two ...
packages/astro/src/types/public/config.ts
26
TypeScript
0.714
suggestion
122
51
51
false
feat(astro)!: stabilize failOnPrerenderConflict
14,826
withastro/astro
47,179
TypeScript
sarah11918
florian-lefebvre
* @description * * Specify the strategy used for scoping styles within Astro components. Choose from: * - `'where'` - Use `:where` selectors, causing no specificity increase. * - `'class'` - Use class-based selectors, causing a +1 specificity increase. * - `'attribute'` - Use `data-` attributes, ...
```suggestion prerenderConflictBehavior?: 'warn' | 'error' | 'ignore'; ```
* @description * * Specify the strategy used for scoping styles within Astro components. Choose from: * - `'where'` - Use `:where` selectors, causing no specificity increase. * - `'class'` - Use class-based selectors, causing a +1 specificity increase. * - `'attribute'` - Use `data-` attributes, ...
@@ -547,6 +547,20 @@ export interface AstroUserConfig< */ scopedStyleStrategy?: 'where' | 'class' | 'attribute'; + /** + * + * @name prerenderConflictBehavior + * @type {'warning' | 'error' | 'ignore'} + * @default `'warning'` + * @version 6.0 + * @description + * Determines the default behavior when two ...
packages/astro/src/types/public/config.ts
26
TypeScript
0.714
suggestion
77
51
51
false
feat(astro)!: stabilize failOnPrerenderConflict
14,826
withastro/astro
47,179
TypeScript
sarah11918
florian-lefebvre
import { defineConfig } from 'astro/config'; export default defineConfig({ prerenderConflictBehavior: 'warning', });
```suggestion prerenderConflictBehavior: 'warn', ```
import { defineConfig } from 'astro/config'; export default defineConfig({ prerenderConflictBehavior: 'warn', });
@@ -1,7 +1,5 @@ import { defineConfig } from 'astro/config'; export default defineConfig({ - experimental: { - failOnPrerenderConflict: false, - }, + prerenderConflictBehavior: 'warning',
packages/astro/test/fixtures/prerender-conflict-dynamic-dynamic/astro.config.mjs
4
JavaScript
0.571
suggestion
56
6
6
false
feat(astro)!: stabilize failOnPrerenderConflict
14,826
withastro/astro
47,179
TypeScript
sarah11918
florian-lefebvre
if (isVirtualId(id)) return; // Handle aliases found from `compilerOptions.paths`. Unlike Vite aliases, tsconfig aliases // are best effort only, so we have to manually replace them here, instead of using `vite.resolve.alias` for (const alias of configAlias) { if (alias.find.test(id)) { const upda...
The TODO doesn't state the conditions under which it's safe to remove it. If we don't it, no developers will when/how to address this comment
}, async resolveId(id, importer, options) { if (isVirtualId(id)) return; // Handle aliases found from `compilerOptions.paths`. Unlike Vite aliases, tsconfig aliases // are best effort only, so we have to manually replace them here, instead of using `vite.resolve.alias` for (const alias of configAlias) ...
@@ -107,6 +160,7 @@ export default function configAliasVitePlugin({ return plugin; } +// TODO this is a deprecated API and should be removed when its safe to do so
packages/astro/src/vite-plugin-config-alias/index.ts
26
TypeScript
0.429
suggestion
141
51
51
false
Fix config alias by using resolve.alias config
14,828
withastro/astro
47,179
TypeScript
ematipico
matthewp
const resolvedBaseUrl = path.resolve(path.dirname(tsConfigPath), effectiveBaseUrl); const aliases: Array<{ find: string | RegExp; replacement: string; customResolver?: any }> = []; // Build aliases with custom resolver that tries multiple paths if (paths) { for (const [aliasPattern, values] of Object.entries(pat...
Can you add a comment that explains the regex?
const resolvedBaseUrl = path.resolve(path.dirname(tsConfigPath), effectiveBaseUrl); const aliases: Array<{ find: string | RegExp; replacement: string; customResolver?: any }> = []; // Build aliases with custom resolver that tries multiple paths if (paths) { for (const [aliasPattern, values] of Object.entries(pat...
@@ -65,6 +67,49 @@ const getConfigAlias = (settings: AstroSettings): Alias[] | null => { return aliases; }; +/** Generate vite.resolve.alias entries from tsconfig paths */ +const getViteResolveAlias = (settings: AstroSettings) => { + const { tsConfig, tsConfigPath } = settings; + if (!tsConfig || !tsConfigPath || ...
packages/astro/src/vite-plugin-config-alias/index.ts
26
TypeScript
0.071
question
47
51
51
false
Fix config alias by using resolve.alias config
14,828
withastro/astro
47,179
TypeScript
ematipico
matthewp
import { type BuildInternals, hasPrerenderedPages } from './internal.js'; import type { StaticBuildOptions } from './types.js'; import { getTimeStat, shouldAppendForwardSlash } from './util.js'; export async function generatePages( options: StaticBuildOptions, internals: BuildInternals, prerenderOutputDir: URL, ) {...
`setLogger` is redundant. At line 59, we already use `setOptions` and we pass `options`. Update the `setOptions` function to set the logger.
import { type BuildInternals, hasPrerenderedPages } from './internal.js'; import type { StaticBuildOptions } from './types.js'; import { getTimeStat, shouldAppendForwardSlash } from './util.js'; export async function generatePages( options: StaticBuildOptions, internals: BuildInternals, prerenderOutputDir: URL, ) {...
@@ -57,6 +57,7 @@ export async function generatePages( const app = prerenderEntry.app as BuildApp; app.setInternals(internals); app.setOptions(options); + app.setLogger(options.logger);
packages/astro/src/core/build/generate.ts
26
TypeScript
0.571
suggestion
141
51
51
false
Fixes assetQueryParams and public folder tests
14,853
withastro/astro
47,179
TypeScript
ematipico
matthewp
import type * as vite from 'vite'; export const NOOP_MODULE_ID = 'virtual:astro:noop'; const RESOLVED_NOOP_MODULE_ID = '\0' + NOOP_MODULE_ID; // An empty module that does nothing. This can be used as a placeholder // when you just need a module to be in the graph. // We use this for the client build when there are no...
I'll be honest, even after reading the comment, I don't understand why we need a noop plugin. The comment doesn't explain what's the correlation between a "plugin that does nothing" and "placeholder [..] module to be in the graph". If there are some vitejs resources, let's use them. The comment from line 8 to line 9...
import type * as vite from 'vite'; export const NOOP_MODULE_ID = 'virtual:astro:noop'; const RESOLVED_NOOP_MODULE_ID = '\0' + NOOP_MODULE_ID; // An empty module that does nothing. This can be used as a placeholder // when you just need a module to be in the graph. // We use this for the client build when there are no...
@@ -0,0 +1,24 @@ +import type * as vite from 'vite'; + +export const NOOP_MODULE_ID = 'virtual:astro:noop'; +const RESOLVED_NOOP_MODULE_ID = '\0' + NOOP_MODULE_ID; + +// An empty module that does nothing. This can be used as a placeholder +// when you just need a module to be in the graph. +// We use this for the clien...
packages/astro/src/core/build/plugins/plugin-noop.ts
10
TypeScript
0.643
bug
527
25
34
false
Fixes assetQueryParams and public folder tests
14,853
withastro/astro
47,179
TypeScript
ematipico
matthewp
bundle: true, minify: false, // ensure node built-in modules are namespaced with `node:` plugins: [ { name: 'esbuild-namespace-node-built-in-modules', setup(build) { const filter = new RegExp(builtinModules.map((mod) => `(^${mod}$)`).join('|')); build.onResolve( { fi...
If we throw the error below, do we need it to include it in the log here?
bundle: true, minify: false, // ensure node built-in modules are namespaced with `node:` plugins: [ { name: 'esbuild-namespace-node-built-in-modules', setup(build) { const filter = new RegExp(builtinModules.map((mod) => `(^${mod}$)`).join('|')); build.onResolve( { fi...
@@ -45,42 +41,53 @@ export async function generateEdgeMiddleware( // https://vercel.com/docs/concepts/functions/edge-middleware#create-edge-middleware const bundledFilePath = fileURLToPath(outPath); const esbuild = await import('esbuild'); - await esbuild.build({ - stdin: { - contents: code, - resolveDir: fi...
packages/integrations/vercel/src/serverless/middleware.ts
26
TypeScript
0.357
question
73
51
51
false
Revert fix: Allow node: prefix for Node builtins for Vercel middleware
14,863
withastro/astro
47,179
TypeScript
florian-lefebvre
drwpow
// Open server to the correct path. We pass the `base` here as we didn't pass the // base to the initial Vite config const open = isServerOpenURL ? serverOpen : isServerOpenBoolean ? base : false; // The client entrypoint for renderers. Since these are imported dynamically // we need to tell Vite to preoptimize t...
FYI, I added `skipBuildOutputAssignment` as a workaround. Do you think it makes sense to keep it, or should we try to find a better fix later?
// Open server to the correct path. We pass the `base` here as we didn't pass the // base to the initial Vite config const open = isServerOpenURL ? serverOpen : isServerOpenBoolean ? base : false; // The client entrypoint for renderers. Since these are imported dynamically // we need to tell Vite to preoptimize t...
@@ -89,7 +89,11 @@ export async function createContainer({ fsMod: nodeFs, }, logger, - { dev: true, skipBuildOutputAssignment: false }, + { + dev: true, + // If the adapter explicitly set a buildOutput, don't override it + skipBuildOutputAssignment: !!settings.adapter?.adapterFeatures?.buildOutput
packages/astro/src/core/dev/container.ts
26
TypeScript
0.571
question
143
51
51
false
Fixes for e2e tests in environment branch
14,870
withastro/astro
47,179
TypeScript
ematipico
matthewp
); if (firstIntegrationWithTSSettings) { // Every major framework, apart from Vue and Svelte requires different `jsxImportSource`, as such it's impossible to config // all of them in the same `tsconfig.json`. However, Vue only need `"jsx": "preserve"` for template intellisense which // can be compatible with s...
this warning wasnt printing before because presets is a map so this PR will also fix this
} const output = JSON.stringify(outputConfig, null, 2); const diff = getDiffContent(inputConfigText, output); if (!diff) { return UpdateResult.none; } const message = `\n${boxen(diff, { margin: 0.5, padding: 0.5, borderStyle: 'round', title: configFileName, })}\n`; logger.info( 'SKIP_FORMAT', ...
@@ -967,25 +1043,27 @@ async function updateTSConfig( `\n ${magenta(`Astro will make the following changes to your ${configFileName}:`)}\n${message}`, ); - // Every major framework, apart from Vue and Svelte requires different `jsxImportSource`, as such it's impossible to config - // all of them in the same `ts...
packages/astro/src/cli/add/index.ts
26
TypeScript
0.286
suggestion
89
51
51
false
feat: include .worker-configuration.d.ts in tsconfig when running astro add cloudflare
14,888
withastro/astro
47,179
TypeScript
OliverSpeir
OliverSpeir
// https://astro.build/db/config export default defineDb({ tables: {} }); `, DB_SEED: `\ import { db } from 'astro:db'; // https://astro.build/db/seed export default async function seed() { // TODO } `, CLOUDFLARE_WRANGLER_CONFIG: (name: string) => `\ { "main": "dist/_worker.js/index.js", "name": ${JSON.stringi...
This PR started going to main, where this src/env.d.ts was needed Since [Astro.locals.runtime was changed](https://github.com/withastro/astro/blob/next/packages/integrations/cloudflare/CHANGELOG.md#major-changes-1) is this still necessary?
export default defineDb({ tables: {} }); `, DB_SEED: `\ import { db } from 'astro:db'; // https://astro.build/db/seed export default async function seed() { // TODO } `, CLOUDFLARE_WRANGLER_CONFIG: (name: string) => `\ { "compatibility_date": ${JSON.stringify(new Date().toISOString().slice(0, 10))}, "compatibil...
@@ -99,6 +100,11 @@ export default async function seed() { } }`, CLOUDFLARE_ASSETSIGNORE: `_worker.js\n_routes.json`, + CLOUDFLARE_ENV_D_TS: `type Runtime = import('@astrojs/cloudflare').Runtime<Env>; + +declare namespace App { + interface Locals extends Runtime {} +}`,
packages/astro/src/cli/add/index.ts
26
TypeScript
0.5
question
244
51
51
false
feat: include .worker-configuration.d.ts in tsconfig when running astro add cloudflare
14,888
withastro/astro
47,179
TypeScript
OliverSpeir
OliverSpeir
*/ export const NoPrerenderedRoutesWithDomains = { name: 'NoPrerenderedRoutesWithDomains', title: "Prerendered routes aren't supported when internationalization domains are enabled.", message: (component: string) => `Static pages aren't yet supported with multiple domains. To enable this feature, you must disable...
@sarah11918 I'd like your review on this
*/ export const NoPrerenderedRoutesWithDomains = { name: 'NoPrerenderedRoutesWithDomains', title: "Prerendered routes aren't supported when internationalization domains are enabled.", message: (component: string) => `Static pages aren't yet supported with multiple domains. To enable this feature, you must disable...
@@ -1168,6 +1168,18 @@ export const MissingMiddlewareForInternationalization = { "Your configuration setting `i18n.routing: 'manual'` requires you to provide your own i18n `middleware` file.", } satisfies ErrorData; +/** + * @docs + * @description + * Astro throws an error if the user passes an invalid configurat...
packages/astro/src/core/errors/errors-data.ts
26
TypeScript
0.071
suggestion
40
51
51
false
fix: i18n middleware impossible config
14,890
withastro/astro
47,179
TypeScript
florian-lefebvre
florian-lefebvre
* @description * Static pages aren't yet supported with i18n domains. If you wish to enable this feature, you have to disable prerendering. */ export const NoPrerenderedRoutesWithDomains = { name: 'NoPrerenderedRoutesWithDomains', title: "Prerendered routes aren't supported when internationalization domains are en...
```suggestion * An invalid i18n middleware configuration was detected. ``` Shouldn't this be more like this? Reminder: this is what will show up here in docs (as a subheading) - compare to the previous ones: <img width="871" height="232" alt="image" src="https://github.com/user-attachments/assets/aa8d4ae8-08...
* @description * Static pages aren't yet supported with i18n domains. If you wish to enable this feature, you have to disable prerendering. */ export const NoPrerenderedRoutesWithDomains = { name: 'NoPrerenderedRoutesWithDomains', title: "Prerendered routes aren't supported when internationalization domains are en...
@@ -1168,6 +1168,18 @@ export const MissingMiddlewareForInternationalization = { "Your configuration setting `i18n.routing: 'manual'` requires you to provide your own i18n `middleware` file.", } satisfies ErrorData; +/** + * @docs + * @description + * Astro throws an error if the user passes an invalid configurat...
packages/astro/src/core/errors/errors-data.ts
26
TypeScript
0.857
suggestion
349
51
51
false
fix: i18n middleware impossible config
14,890
withastro/astro
47,179
TypeScript
sarah11918
florian-lefebvre
message: (component: string) => `Static pages aren't yet supported with multiple domains. To enable this feature, you must disable prerendering for the page ${component}`, } satisfies ErrorData; /** * @docs * @description * Astro throws an error if the user enables manual routing, but it doesn't have a middlewar...
```suggestion 'The option `redirectToDefaultLocale` can be enabled only when `prefixDefaultLocale` is also set to `true`, otherwise redirects might cause infinite loops. Enable the option `prefixDefaultLocale` to continue to use `redirectToDefaultLocale`, or ensure neither are set.', ``` There are a few ways we co...
message: (component: string) => `Static pages aren't yet supported with multiple domains. To enable this feature, you must disable prerendering for the page ${component}`, } satisfies ErrorData; /** * @docs * @description * Astro throws an error if the user enables manual routing, but it doesn't have a middlewar...
@@ -1168,6 +1168,18 @@ export const MissingMiddlewareForInternationalization = { "Your configuration setting `i18n.routing: 'manual'` requires you to provide your own i18n `middleware` file.", } satisfies ErrorData; +/** + * @docs + * @description + * Astro throws an error if the user passes an invalid configurat...
packages/astro/src/core/errors/errors-data.ts
26
TypeScript
0.857
bug
766
51
51
false
fix: i18n middleware impossible config
14,890
withastro/astro
47,179
TypeScript
sarah11918
florian-lefebvre
if (!parsedId.filename.endsWith('.astro') || parsedId.query.astro) { // Special edge case handling for Vite 6 beta, the style dependencies need to be registered here take affect // TODO: Remove this when Vite fixes it (https://github.com/vitejs/vite/pull/18103) if (this.environment.name === 'client') { ...
Do you think this should happen in v6?
if (!parsedId.filename.endsWith('.astro') || parsedId.query.astro) { // Special edge case handling for Vite 6 beta, the style dependencies need to be registered here take affect // TODO: Remove this when Vite fixes it (https://github.com/vitejs/vite/pull/18103) if (this.environment.name === 'client') { ...
@@ -231,7 +231,14 @@ export default function astro({ settings, logger }: AstroPluginOptions): vite.Pl // If an Astro component is imported in code used on the client, we return an empty // module so that Vite doesn’t bundle the server-side Astro code for the client. - if (!options?.ssr) { + if ( + !opt...
packages/astro/src/vite-plugin-astro/index.ts
26
TypeScript
0.143
question
38
51
51
false
Fix `AstroContainer` usage in Vitest client environments
14,894
withastro/astro
47,179
TypeScript
florian-lefebvre
delucis
store.addAssetImports(existingEntry.assetImports, existingEntry.filePath); } fileToIdMap.set(filePath, id); return; } const relativePath = posixRelative(fileURLToPath(config.root), filePath); const parsedData = await parseData({ id, data, filePath, }); if (entr...
Can you use only one interpolated string?
store.addAssetImports(existingEntry.assetImports, existingEntry.filePath); } fileToIdMap.set(filePath, id); return; } const relativePath = posixRelative(fileURLToPath(config.root), filePath); const parsedData = await parseData({ id, data, filePath, }); if (entr...
@@ -172,6 +172,14 @@ export function glob(globOptions: GlobOptions): Loader { } let render = renderFunctionByContentType.get(entryType); + + if (store.has(id)) { + logger.warn( + `Duplicate content entry ID "${id}" detected. ` +
packages/astro/src/content/loaders/glob.ts
26
TypeScript
0.143
question
41
51
51
false
fix(content): warn on duplicate Markdown content entry IDs
14,901
withastro/astro
47,179
TypeScript
florian-lefebvre
Darknab
// @ts-expect-error - It is safe to expect the error here. import { env as globalEnv } from 'cloudflare:workers'; import { sessionKVBindingName } from 'virtual:astro-cloudflare:config'; import type { Response as CfResponse, ExecutionContext, ExportedHandlerFetchHandler, } from '@cloudflare/workers-types'; import { c...
I think we may want to change this object shape? `locals.runtime.ctx` may not make a lot of sense anymore. What about, idk, `locals.cfContext`?
import { env as globalEnv } from 'cloudflare:workers'; import { sessionKVBindingName } from 'virtual:astro-cloudflare:config'; import type { Response as CfResponse, ExecutionContext, ExportedHandlerFetchHandler, } from '@cloudflare/workers-types'; import { createApp } from 'astro/app/entrypoint'; import { setGetEnv ...
@@ -18,11 +17,8 @@ export type Env = { setGetEnv(createGetEnv(globalEnv as Env)); -export interface Runtime<T extends object = object> { +export interface Runtime { runtime: {
packages/integrations/cloudflare/src/utils/handler.ts
21
TypeScript
0.571
question
143
46
46
false
Fix remaining cloudflare tests
14,912
withastro/astro
47,179
TypeScript
florian-lefebvre
matthewp
conf.ssr.noExternal = true; } }, }, createConfigPlugin({ sessionKVBindingName: SESSION_KV_BINDING_NAME, }), ], }, image: setImageConfig(args?.imageService ?? 'compile', config.image, command, logger), }); addWatchFile(new URL('./wrangler.t...
You may need to update the `package.json` exports to make it work
} }, }, createConfigPlugin({ sessionKVBindingName: SESSION_KV_BINDING_NAME, }), ], }, image: setImageConfig(args?.imageService ?? 'compile', config.image, command, logger), }); addWatchFile(new URL('./wrangler.toml', config.root)); addWatchFile(...
@@ -258,10 +258,15 @@ export default function createIntegration(args?: Options): AstroIntegration { 'astro:routes:resolved': ({ routes }) => { _routes = routes; }, - 'astro:config:done': ({ setAdapter, config, buildOutput }) => { + 'astro:config:done': ({ setAdapter, config, buildOutput, injectTypes })...
packages/integrations/cloudflare/src/index.ts
26
TypeScript
0.357
suggestion
65
51
51
false
Fix remaining cloudflare tests
14,912
withastro/astro
47,179
TypeScript
florian-lefebvre
matthewp
edgeMiddleware: false, buildOutput: 'server', }, previewEntrypoint: '@astrojs/cloudflare/entrypoints/preview', supportedAstroFeatures: { serverOutput: 'stable', hybridOutput: 'stable', staticOutput: 'unsupported', i18nDomains: 'experimental', sharpImageService: {...
This function can throw a runtime error, we should catch it and maybe: - handle it gracefully with a log - or throw and `AstroError`
edgeMiddleware: false, buildOutput: 'server', }, previewEntrypoint: '@astrojs/cloudflare/entrypoints/preview', supportedAstroFeatures: { serverOutput: 'stable', hybridOutput: 'stable', staticOutput: 'unsupported', i18nDomains: 'experimental', sharpImageService: {...
@@ -297,6 +305,15 @@ export default function createIntegration(args?: Options): AstroIntegration { envGetSecret: 'stable', }, }); + + // Assign .dev.vars to process.env so astro:env can find these vars + const devVarsPath = new URL('.dev.vars', config.root); + if (existsSync(devVarsPath)) { +...
packages/integrations/cloudflare/src/index.ts
26
TypeScript
0.714
suggestion
132
51
51
false
Fix astro:env tests in Cloudflare
14,925
withastro/astro
47,179
TypeScript
ematipico
matthewp
} export interface MetaStore { get: (key: string) => string | undefined; set: (key: string, value: string) => void; delete: (key: string) => void; has: (key: string) => boolean; } export type BaseSchema = ZodType; export type SchemaContext = { image: ImageFunction }; type ContentLayerConfig<S extends BaseSchema...
The loader constraint is important, this is what allowed the loader API breaking change
has: (key: string) => boolean; } export interface MetaStore { get: (key: string) => string | undefined; set: (key: string, value: string) => void; delete: (key: string) => void; has: (key: string) => boolean; } export type BaseSchema = zCore.$ZodType; export type { ImageFunction }; export type SchemaContext = ...
@@ -80,22 +103,10 @@ export type LiveCollectionConfig< loader: L; }; -type LoaderConstraint<TData extends { id: string }> =
packages/astro/src/content/config.ts
26
TypeScript
0.286
suggestion
87
51
51
false
feat: add legacy.collectionsBackwardsCompat flag for v6 content colle…
14,927
withastro/astro
47,179
TypeScript
florian-lefebvre
matthewp