Refactor: Centralize calls to emberSafeRequire#2653
Merged
mansona merged 6 commits intoemberjs:mainfrom Jun 19, 2025
Merged
Conversation
2c7bc8d to
3d23d20
Compare
3d23d20 to
8135c6d
Compare
…ed from utils/ember
d0f17f4 to
4dc681b
Compare
BlueCutOfficial
commented
Jun 17, 2025
Comment on lines
-20
to
+29
| try { | ||
| requireModule( | ||
| '@glimmer/manager', | ||
| ).CustomModifierManager.prototype.getDebugInstance = (args) => | ||
| args.modifier || args.delegate; | ||
| } catch { | ||
| // nope | ||
| if (GlimmerManager) { | ||
| GlimmerManager.CustomModifierManager.prototype.getDebugInstance = ( | ||
| args, | ||
| ) => args.modifier || args.delegate; |
Contributor
Author
There was a problem hiding this comment.
There are several places where I replaced try..catch with if. This is because in the initial implementation, requireModule could throw. With the new import from ember-debug/utils/ember, the method emberSafeRequire already handles the catch, so in this example GlimmerManager could just be undefined if the module is not found.
emberSafeRequireemberSafeRequire
emberSafeRequireemberSafeRequire
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.
Description
This PR is part of implementing Vite apps support for the inspector.
Inspecting an Ember app built with Vite or Ember CLI+Broccoli will change how the
ember_debug.jsscript interacts with ember-source (specifically how Ember modules are imported). To implement with more confidence howember_debugshould adapt its behavior depending on that context, we started to centralize all the interactions with ember-source in one single script (ember_debug/utils/ember.js).This PR continues this work by removing all the calls to
emberSafeRequireover the differentember_debugfiles and replacing them with imports fromember_debug/utils/ember.js.