Fix Firefox test build: add import.meta.env?.DEV replacement plugin to vite.config.mjs#21116
Conversation
…or in Firefox Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
COMPUTED_GETTERS TypeError in Firefox by unconditional WeakSet initialization
|
@copilot, this fix is not appropriate, given the original change here: https://github.com/emberjs/ember.js/pull/21115/changes#diff-6915e9ed2703a5079ad681e814d82b43a93abc150305760d2f640cff21de2bd2 It implies that we build the project wrong, and import.meta.env?.DEV is false. When we build for the firefox tests, |
…o vite.config.mjs Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
You're right. Reverted the The real issue is that Vite doesn't natively replace Fixed in 462a664 by adding the same plugin to |
COMPUTED_GETTERS TypeError in Firefox by unconditional WeakSet initializationimport.meta.env?.DEV replacement plugin to vite.config.mjs
Firefox 115 ESR tests were failing with
TypeError: COMPUTED_GETTERS is undefinedbecause Vite does not natively replaceimport.meta.env?.DEV(optional chaining) during builds — onlyimport.meta.env.DEV(without?.) is handled by Vite's built-in env replacement. Whenimport.meta.env?.DEVgoes unreplaced in the build output, it evaluates toundefinedat runtime in the browser (sinceimport.meta.envis a Vite build-time artifact, not present at runtime), leavingCOMPUTED_GETTERSuninitialized.The
rollup.config.mjsalready had adefine custom import.meta.envplugin that replacesimport.meta.env?.DEVwithtrue/false, butvite.config.mjs(used for the Firefox CI test build viapnpm vite build --mode=development) was missing it.Changes
vite.config.mjs: Added adefine custom import.meta.envVite plugin (placed before the Babel plugin) that replacesimport.meta.env?.DEVwithtruein development mode andfalsein production mode — mirroring the equivalent plugin already present inrollup.config.mjs.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.