Skip to content

Commit

Permalink
feat(astro): update astro env setup (#11206)
Browse files Browse the repository at this point in the history
* feat(astro): update astro env setup

* Update silly-beds-hammer.md
  • Loading branch information
florian-lefebvre committed Jun 7, 2024
1 parent 8c45391 commit 734b98f
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 11 deletions.
7 changes: 7 additions & 0 deletions .changeset/silly-beds-hammer.md
Original file line number Diff line number Diff line change
@@ -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 changes: 0 additions & 4 deletions packages/astro/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
1 change: 1 addition & 0 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/env/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/env/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { setGetEnv, type GetEnv } from './runtime.js';
4 changes: 0 additions & 4 deletions packages/astro/src/env/vite-plugin-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)) {
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/virtual-modules/env-setup.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/astro/test/test-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 734b98f

Please sign in to comment.