Skip to content

Fix Firefox test build: add import.meta.env?.DEV replacement plugin to vite.config.mjs#21116

Merged
NullVoxPopuli merged 3 commits intonvp/no-more-macrosfrom
copilot/sub-pr-21115
Feb 25, 2026
Merged

Fix Firefox test build: add import.meta.env?.DEV replacement plugin to vite.config.mjs#21116
NullVoxPopuli merged 3 commits intonvp/no-more-macrosfrom
copilot/sub-pr-21115

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

Firefox 115 ESR tests were failing with TypeError: COMPUTED_GETTERS is undefined because Vite does not natively replace import.meta.env?.DEV (optional chaining) during builds — only import.meta.env.DEV (without ?.) is handled by Vite's built-in env replacement. When import.meta.env?.DEV goes unreplaced in the build output, it evaluates to undefined at runtime in the browser (since import.meta.env is a Vite build-time artifact, not present at runtime), leaving COMPUTED_GETTERS uninitialized.

The rollup.config.mjs already had a define custom import.meta.env plugin that replaces import.meta.env?.DEV with true/false, but vite.config.mjs (used for the Firefox CI test build via pnpm vite build --mode=development) was missing it.

Changes

  • vite.config.mjs: Added a define custom import.meta.env Vite plugin (placed before the Babel plugin) that replaces import.meta.env?.DEV with true in development mode and false in production mode — mirroring the equivalent plugin already present in rollup.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.

…or in Firefox

Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove macros in favor of import.meta.env?.DEV Fix COMPUTED_GETTERS TypeError in Firefox by unconditional WeakSet initialization Feb 25, 2026
@NullVoxPopuli
Copy link
Contributor

@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, import.meta.env?.DEV should be true

…o vite.config.mjs

Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 25, 2026

@copilot, this fix is not appropriate, given the original change here: https://github.com/emberjs/ember.js/pull/21115/changes#diff-6915e9ed2703a5079ad681e814d82b43a93abc150305760d2f640cff21de2bd2

I...

You're right. Reverted the decorator.ts change.

The real issue is that Vite doesn't natively replace import.meta.env?.DEV (optional chaining) — only import.meta.env.DEV (without ?.). The rollup.config.mjs already had a define custom import.meta.env plugin that does this replacement, but vite.config.mjs (used for the Firefox test build via pnpm vite build --mode=development) was missing it.

Fixed in 462a664 by adding the same plugin to vite.config.mjs, placed before the Babel plugin to ensure the pattern is replaced before Babel could transform it.

Copilot AI changed the title Fix COMPUTED_GETTERS TypeError in Firefox by unconditional WeakSet initialization Fix Firefox test build: add import.meta.env?.DEV replacement plugin to vite.config.mjs Feb 25, 2026
@NullVoxPopuli NullVoxPopuli marked this pull request as ready for review February 25, 2026 22:30
@NullVoxPopuli NullVoxPopuli merged commit 74a8054 into nvp/no-more-macros Feb 25, 2026
@NullVoxPopuli NullVoxPopuli deleted the copilot/sub-pr-21115 branch February 25, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants