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
This commit is contained in:
ThatGuySam 2026-04-04 15:41:03 -05:00
parent 1248c705b0
commit 6fc59d6034

View file

@ -1,11 +1,11 @@
import dotenv from 'dotenv'
import { createRequire } from 'node:module'
dotenv.config()
const require = createRequire( import.meta.url )
const packageJson = require( '../package.json' )
const packageVerbiage = packageJson.config?.verbiage || {}
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 ) {
@ -19,8 +19,8 @@ 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, packageVerbiage.macs || null ),
processorsVerbiage: getRuntimeValue( process.env.npm_package_config_verbiage_processors, packageVerbiage.processors || null ),
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 () {