Fix embroiderVite-basics: guard COMPUTED_GETTERS.has() with DEV check#21118
Merged
NullVoxPopuli merged 2 commits intonvp/no-more-macrosfrom Feb 26, 2026
Merged
Fix embroiderVite-basics: guard COMPUTED_GETTERS.has() with DEV check#21118NullVoxPopuli merged 2 commits intonvp/no-more-macrosfrom
NullVoxPopuli merged 2 commits intonvp/no-more-macrosfrom
Conversation
When building with `vite build --mode test`, import.meta.env.DEV is false, so COMPUTED_GETTERS (a WeakSet) is never initialized. The assert() call in makeComputedDecorator was unconditionally evaluating COMPUTED_GETTERS.has(), causing TypeError: Cannot read properties of undefined (reading 'has'). Guard the .has() call with `import.meta.env?.DEV &&` so it short-circuits before accessing the undefined WeakSet in production/test builds. 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 embroiderVite-basics: guard COMPUTED_GETTERS.has() with DEV check
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When building with
vite build --mode test, Vite setsimport.meta.env.DEVtofalse, soCOMPUTED_GETTERS(aWeakSet) is never initialized — butCOMPUTED_GETTERS.has()was called unconditionally as an argument toassert(). Sinceassertis a no-op in production (not tree-shaken away entirely), its arguments are still evaluated, causing a crash at startup.Change
packages/@ember/-internals/metal/lib/decorator.ts: Guard the.has()call inmakeComputedDecorator'sassert()withimport.meta.env?.DEV &&so it short-circuits before touching the uninitialized WeakSet in non-dev builds:The assertion still works correctly in dev mode; in production/test builds the condition simply evaluates to
true(no-op), matching the intended behavior sinceassertis already a no-op there.💡 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.