0
Fork 0
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:
Florian Lefebvre 2024-06-07 14:38:11 +02:00 committed by GitHub
parent 8c4539145f
commit 734b98fecf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 10 additions and 11 deletions

View 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`

View file

@ -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'];

View file

@ -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",

View file

@ -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
View file

@ -0,0 +1 @@
export { setGetEnv, type GetEnv } from './runtime.js';

View file

@ -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)) {

View file

@ -1 +0,0 @@
export { setGetEnv, type GetEnv } from '../env/runtime.js';

View file

@ -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];