diff options
author | 2025-01-29 14:33:40 +0000 | |
---|---|---|
committer | 2025-01-29 15:33:40 +0100 | |
commit | c3ed9ee7b5c8e1814f535e57dc9945ed572565c1 (patch) | |
tree | cb06b36976d7b3b0bf7a1e94ca52fccf496a8958 | |
parent | 18a2699f5320f4c3c01d8fe502f7b66c78014f94 (diff) | |
download | astro-c3ed9ee7b5c8e1814f535e57dc9945ed572565c1.tar.gz astro-c3ed9ee7b5c8e1814f535e57dc9945ed572565c1.tar.zst astro-c3ed9ee7b5c8e1814f535e57dc9945ed572565c1.zip |
fix: docs and types (#13087)
-rw-r--r-- | packages/astro/client.d.ts | 4 | ||||
-rw-r--r-- | packages/astro/src/core/errors/errors-data.ts | 26 | ||||
-rw-r--r-- | packages/astro/src/manifest/virtual-module.ts | 10 | ||||
-rw-r--r-- | packages/astro/src/types/public/config.ts | 6 | ||||
-rw-r--r-- | packages/astro/test/serializeManifest.test.js | 8 | ||||
-rw-r--r-- | pnpm-lock.yaml | 1 |
6 files changed, 28 insertions, 27 deletions
diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts index daffd2d57..543e00d8e 100644 --- a/packages/astro/client.d.ts +++ b/packages/astro/client.d.ts @@ -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; diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index f0df38bea..ef7719e73 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -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; diff --git a/packages/astro/src/manifest/virtual-module.ts b/packages/astro/src/manifest/virtual-module.ts index d812ce25a..03b856265 100644 --- a/packages/astro/src/manifest/virtual-module.ts +++ b/packages/astro/src/manifest/virtual-module.ts @@ -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) { diff --git a/packages/astro/src/types/public/config.ts b/packages/astro/src/types/public/config.ts index 228a6141f..a65d1eccc 100644 --- a/packages/astro/src/types/public/config.ts +++ b/packages/astro/src/types/public/config.ts @@ -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' * } * } * }) diff --git a/packages/astro/test/serializeManifest.test.js b/packages/astro/test/serializeManifest.test.js index a47a63499..6fb4903b0 100644 --- a/packages/astro/test/serializeManifest.test.js +++ b/packages/astro/test/serializeManifest.test.js @@ -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/); }); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bb3d953c4..54533611a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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: |