mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
feat(astro): update astro env setup (#11206)
* feat(astro): update astro env setup * Update silly-beds-hammer.md
This commit is contained in:
parent
8c4539145f
commit
734b98fecf
8 changed files with 10 additions and 11 deletions
7
.changeset/silly-beds-hammer.md
Normal file
7
.changeset/silly-beds-hammer.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
**BREAKING CHANGE to the experimental `astro:env` feature only**
|
||||
|
||||
Updates the adapter `astro:env` entrypoint from `astro:env/setup` to `astro/env/setup`
|
4
packages/astro/client.d.ts
vendored
4
packages/astro/client.d.ts
vendored
|
@ -164,10 +164,6 @@ declare module 'astro:components' {
|
|||
export * from 'astro/components';
|
||||
}
|
||||
|
||||
declare module 'astro:env/setup' {
|
||||
export * from 'astro/virtual-modules/env-setup.js';
|
||||
}
|
||||
|
||||
type MD = import('./dist/@types/astro.js').MarkdownInstance<Record<string, any>>;
|
||||
interface ExportedMarkdownModuleEntities {
|
||||
frontmatter: MD['frontmatter'];
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
},
|
||||
"./env": "./env.d.ts",
|
||||
"./env/runtime": "./dist/env/runtime.js",
|
||||
"./env/setup": "./dist/env/setup.js",
|
||||
"./types": "./types.d.ts",
|
||||
"./client": "./client.d.ts",
|
||||
"./astro-jsx": "./astro-jsx.d.ts",
|
||||
|
|
1
packages/astro/src/env/constants.ts
vendored
1
packages/astro/src/env/constants.ts
vendored
|
@ -4,7 +4,6 @@ export const VIRTUAL_MODULES_IDS = {
|
|||
internal: 'virtual:astro:env/internal',
|
||||
};
|
||||
export const VIRTUAL_MODULES_IDS_VALUES = new Set(Object.values(VIRTUAL_MODULES_IDS));
|
||||
export const VIRTUAL_MODULE_SETUP_ID = 'astro:env/setup';
|
||||
|
||||
export const PUBLIC_PREFIX = 'PUBLIC_';
|
||||
export const ENV_TYPES_FILE = 'env.d.ts';
|
||||
|
|
1
packages/astro/src/env/setup.ts
vendored
Normal file
1
packages/astro/src/env/setup.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export { setGetEnv, type GetEnv } from './runtime.js';
|
4
packages/astro/src/env/vite-plugin-env.ts
vendored
4
packages/astro/src/env/vite-plugin-env.ts
vendored
|
@ -9,7 +9,6 @@ import {
|
|||
TYPES_TEMPLATE_URL,
|
||||
VIRTUAL_MODULES_IDS,
|
||||
VIRTUAL_MODULES_IDS_VALUES,
|
||||
VIRTUAL_MODULE_SETUP_ID,
|
||||
} from './constants.js';
|
||||
import type { EnvSchema } from './schema.js';
|
||||
import { getEnvFieldType, validateEnvVariable } from './validators.js';
|
||||
|
@ -81,9 +80,6 @@ export function astroEnv({
|
|||
if (VIRTUAL_MODULES_IDS_VALUES.has(id)) {
|
||||
return resolveVirtualModuleId(id);
|
||||
}
|
||||
if (id === VIRTUAL_MODULE_SETUP_ID) {
|
||||
return this.resolve('astro/virtual-modules/env-setup.js');
|
||||
}
|
||||
},
|
||||
load(id, options) {
|
||||
if (id === resolveVirtualModuleId(VIRTUAL_MODULES_IDS.client)) {
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export { setGetEnv, type GetEnv } from '../env/runtime.js';
|
|
@ -53,7 +53,7 @@ export default function ({
|
|||
${
|
||||
env
|
||||
? `
|
||||
await import('astro:env/setup')
|
||||
await import('astro/env/setup')
|
||||
.then(mod => mod.setGetEnv((key) => {
|
||||
const data = ${JSON.stringify(env)};
|
||||
return data[key];
|
||||
|
|
Loading…
Reference in a new issue