doesitarm/helpers/public-runtime-config.mjs
ThatGuySam 6fc59d6034 fix(runtime-config): avoid package.json fallback in prerender bundle
The previous verbiage fallback loaded package.json via createRequire(), which broke Astro/Netlify prerender bundling because the relative package.json path is not available inside the generated chunk layout. Replace it with static fallback strings so the app-test text stays populated without depending on runtime file access.

Constraint: Must restore Netlify production builds immediately
Rejected: Revert the verbiage fix entirely | would reintroduce the blank app-test subtitle in production
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep public runtime fallbacks bundle-safe; do not require repo files from prerender/runtime chunks
Tested: pnpm run typecheck (workspace); GitHub Actions failure analysis for netlify-build
Not-tested: Full redeploy completion at commit time
2026-04-04 15:41:03 -05:00

36 lines
1.1 KiB
JavaScript

import dotenv from 'dotenv'
dotenv.config()
const fallbackVerbiage = {
macs: 'Apple M4 Max or M3 Ultra Mac',
processors: 'Apple M4 Max and M3 Ultra'
}
function getRuntimeValue ( envValue, fallbackValue = null ) {
if ( typeof envValue === 'string' && envValue.length > 0 ) {
return envValue
}
return fallbackValue
}
export const publicRuntimeConfig = {
allUpdateSubscribe: process.env.ALL_UPDATE_SUBSCRIBE,
testResultStore: process.env.TEST_RESULT_STORE,
siteUrl: process.env.URL,
macsVerbiage: getRuntimeValue( process.env.npm_package_config_verbiage_macs, fallbackVerbiage.macs ),
processorsVerbiage: getRuntimeValue( process.env.npm_package_config_verbiage_processors, fallbackVerbiage.processors ),
}
export function makeViteDefinitions () {
const definitions = {}
for ( const key in publicRuntimeConfig ) {
definitions[`this.$config.${key}`] = JSON.stringify( publicRuntimeConfig[key] )
definitions[`global.$config.${key}`] = JSON.stringify( publicRuntimeConfig[key] )
definitions[`global.$config`] = JSON.stringify( publicRuntimeConfig )
}
return definitions
}