mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
fix: docs and types (#13087)
This commit is contained in:
parent
18a2699f53
commit
c3ed9ee7b5
6 changed files with 28 additions and 27 deletions
4
packages/astro/client.d.ts
vendored
4
packages/astro/client.d.ts
vendored
|
@ -189,14 +189,14 @@ declare module 'astro:middleware' {
|
|||
export * from 'astro/virtual-modules/middleware.js';
|
||||
}
|
||||
|
||||
declare module 'astro:manifest/server' {
|
||||
declare module 'astro:config/server' {
|
||||
// biome-ignore format: bug
|
||||
type ServerConfigSerialized = import('./dist/types/public/manifest.js').ServerDeserializedManifest;
|
||||
const manifest: ServerConfigSerialized;
|
||||
export default manifest;
|
||||
}
|
||||
|
||||
declare module 'astro:manifest/client' {
|
||||
declare module 'astro:config/client' {
|
||||
// biome-ignore format: bug
|
||||
type ClientConfigSerialized = import('./dist/types/public/manifest.js').ClientDeserializedManifest;
|
||||
const manifest: ClientConfigSerialized;
|
||||
|
|
|
@ -17,6 +17,19 @@ export interface ErrorData {
|
|||
* @name Astro Errors
|
||||
*/
|
||||
// Astro Errors, most errors will go here!
|
||||
|
||||
/**
|
||||
* @docs
|
||||
* @description
|
||||
* Cannot use the module `astro:config` without enabling the experimental feature.
|
||||
*/
|
||||
export const CantUseAstroConfigModuleError = {
|
||||
name: 'CantUseAstroConfigModuleError',
|
||||
title: 'Cannot use the `astro:config` module without enabling the experimental feature.',
|
||||
message: (moduleName) =>
|
||||
`Cannot import the module "${moduleName}" because the experimental feature is disabled. Enable \`experimental.serializeManifest\` in your \`astro.config.mjs\` `,
|
||||
} satisfies ErrorData;
|
||||
|
||||
/**
|
||||
* @docs
|
||||
* @message
|
||||
|
@ -1758,6 +1771,7 @@ export const UnsupportedConfigTransformError = {
|
|||
hint: 'See the devalue library for all supported types: https://github.com/rich-harris/devalue',
|
||||
} satisfies ErrorData;
|
||||
|
||||
|
||||
/**
|
||||
* @docs
|
||||
* @kind heading
|
||||
|
@ -1822,18 +1836,6 @@ export const ActionCalledFromServerError = {
|
|||
hint: 'See the `Astro.callAction()` reference for usage examples: https://docs.astro.build/en/reference/api-reference/#callaction',
|
||||
} satisfies ErrorData;
|
||||
|
||||
/**
|
||||
* @docs
|
||||
* @description
|
||||
* Cannot use the module `astro:config` without enabling the experimental feature.
|
||||
*/
|
||||
export const CantUseManifestModule = {
|
||||
name: 'CantUseManifestModule',
|
||||
title: 'Cannot use the `astro:config` module without enabling the experimental feature.',
|
||||
message: (moduleName) =>
|
||||
`Cannot import the module "${moduleName}" because the experimental feature is disabled. Enable \`experimental.serializeManifest\` in your \`astro.config.mjs\` `,
|
||||
} satisfies ErrorData;
|
||||
|
||||
// Generic catch-all - Only use this in extreme cases, like if there was a cosmic ray bit flip.
|
||||
export const UnknownError = { name: 'UnknownError', title: 'Unknown Error.' } satisfies ErrorData;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import type { Plugin } from 'vite';
|
||||
import { CantUseManifestModule } from '../core/errors/errors-data.js';
|
||||
import { CantUseAstroConfigModuleError } from '../core/errors/errors-data.js';
|
||||
import { AstroError, AstroErrorData } from '../core/errors/index.js';
|
||||
import type { Logger } from '../core/logger/core.js';
|
||||
import { fromRoutingStrategy } from '../i18n/utils.js';
|
||||
|
@ -37,8 +37,8 @@ export default function virtualModulePlugin({
|
|||
if (id === RESOLVED_VIRTUAL_CLIENT_ID) {
|
||||
if (!settings.config.experimental.serializeConfig) {
|
||||
throw new AstroError({
|
||||
...CantUseManifestModule,
|
||||
message: CantUseManifestModule.message(VIRTUAL_CLIENT_ID),
|
||||
...CantUseAstroConfigModuleError,
|
||||
message: CantUseAstroConfigModuleError.message(VIRTUAL_CLIENT_ID),
|
||||
});
|
||||
}
|
||||
// There's nothing wrong about using `/client` on the server
|
||||
|
@ -48,8 +48,8 @@ export default function virtualModulePlugin({
|
|||
else if (id == RESOLVED_VIRTUAL_SERVER_ID) {
|
||||
if (!settings.config.experimental.serializeConfig) {
|
||||
throw new AstroError({
|
||||
...CantUseManifestModule,
|
||||
message: CantUseManifestModule.message(VIRTUAL_SERVER_ID),
|
||||
...CantUseAstroConfigModuleError,
|
||||
message: CantUseAstroConfigModuleError.message(VIRTUAL_SERVER_ID),
|
||||
});
|
||||
}
|
||||
if (!opts?.ssr) {
|
||||
|
|
|
@ -271,12 +271,12 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
|
|||
* ```js
|
||||
* export default defineConfig({
|
||||
* redirects: {
|
||||
* '/old': '/new',
|
||||
* '/old': '/new',
|
||||
* '/blog/[...slug]': '/articles/[...slug]',
|
||||
* '/about': 'https://example.com/about',
|
||||
* '/news': {
|
||||
* status: 302,
|
||||
* destination: 'https://example.com/news'
|
||||
* status: 302,
|
||||
* destination: 'https://example.com/news'
|
||||
* }
|
||||
* }
|
||||
* })
|
||||
|
|
|
@ -6,7 +6,7 @@ import { AstroError } from '../dist/core/errors/index.js';
|
|||
import testAdapter from './test-adapter.js';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
describe('astro:manifest/client', () => {
|
||||
describe('astro:config/client', () => {
|
||||
/** @type {import('./test-utils').Fixture} */
|
||||
let fixture;
|
||||
let devServer;
|
||||
|
@ -29,7 +29,7 @@ describe('astro:manifest/client', () => {
|
|||
it('should throw an error when importing the module', async () => {
|
||||
const response = await fixture.fetch('/');
|
||||
const html = await response.text();
|
||||
assert.match(html, /CantUseManifestModule/);
|
||||
assert.match(html, /CantUseAstroConfigModuleError/);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -112,7 +112,7 @@ describe('astro:manifest/client', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('astro:manifest/server', () => {
|
||||
describe('astro:config/server', () => {
|
||||
/** @type {import('./test-utils').Fixture} */
|
||||
let fixture;
|
||||
let devServer;
|
||||
|
@ -150,7 +150,7 @@ describe('astro:manifest/server', () => {
|
|||
it('should throw an error when importing the module', async () => {
|
||||
const response = await fixture.fetch('/server');
|
||||
const html = await response.text();
|
||||
assert.match(html, /CantUseManifestModule/);
|
||||
assert.match(html, /CantUseAstroConfigModuleError/);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
1
pnpm-lock.yaml
generated
1
pnpm-lock.yaml
generated
|
@ -8926,7 +8926,6 @@ packages:
|
|||
|
||||
libsql@0.4.5:
|
||||
resolution: {integrity: sha512-sorTJV6PNt94Wap27Sai5gtVLIea4Otb2LUiAUyr3p6BPOScGMKGt5F1b5X/XgkNtcsDKeX5qfeBDj+PdShclQ==}
|
||||
cpu: [x64, arm64, wasm32]
|
||||
os: [darwin, linux, win32]
|
||||
|
||||
lightningcss-darwin-arm64@1.29.1:
|
||||
|
|
Loading…
Add table
Reference in a new issue