mirror of
https://github.com/withastro/astro.git
synced 2025-03-10 23:01:26 -05:00
fix: astro:env getSecret (#11296)
This commit is contained in:
parent
150ab5e36c
commit
9e198c41bf
2 changed files with 16 additions and 6 deletions
|
@ -263,7 +263,10 @@ export default function vercelServerless({
|
|||
vite: {
|
||||
...getSpeedInsightsViteConfig(speedInsights?.enabled),
|
||||
ssr: {
|
||||
external: ['@vercel/nft'],
|
||||
external: [
|
||||
'@vercel/nft',
|
||||
...((await shouldExternalizeAstroEnvSetup()) ? ['astro/env/setup'] : []),
|
||||
],
|
||||
},
|
||||
},
|
||||
...getAstroImageConfig(
|
||||
|
@ -442,6 +445,16 @@ export default function vercelServerless({
|
|||
|
||||
type Runtime = `nodejs${string}.x`;
|
||||
|
||||
// TODO: remove once we don't use a TLA anymore
|
||||
async function shouldExternalizeAstroEnvSetup() {
|
||||
try {
|
||||
await import('astro/env/setup');
|
||||
return false;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class VercelBuilder {
|
||||
readonly NTF_CACHE = {};
|
||||
|
||||
|
|
|
@ -8,13 +8,10 @@ import {
|
|||
ASTRO_PATH_PARAM,
|
||||
} from './adapter.js';
|
||||
|
||||
type EnvSetupModule = typeof import('astro/env/setup');
|
||||
|
||||
// Won't throw if the virtual module is not available because it's not supported in
|
||||
// the users's astro version or if astro:env is not enabled in the project
|
||||
const setupModule = 'astro/env/setup';
|
||||
await import(/* @vite-ignore */ setupModule)
|
||||
.then((mod: EnvSetupModule) => mod.setGetEnv((key) => process.env[key]))
|
||||
await import('astro/env/setup')
|
||||
.then((mod) => mod.setGetEnv((key) => process.env[key]))
|
||||
.catch(() => {});
|
||||
|
||||
applyPolyfills();
|
||||
|
|
Loading…
Add table
Reference in a new issue