-
Notifications
You must be signed in to change notification settings - Fork 152
Virtual fix for ember-inspector #2455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So looking at this PR I figured it looked strange that a virtual file would have a namespace that really exists in a ember-source 🤔 and also one that we expect to make a real file in some future version of ember-source
I know I kept saying "Virtual file" when we talked about this but with the fact that it's something that could change with different Ember versions and exists in a real namespace I think we should add this to the ember-source compat adapter
I'm pretty sure the replaceFile()
function that I created should be able to create new files 🤔 https://github.com/embroider-build/embroider/blob/main/packages/compat/src/compat-adapters/ember-source.ts#L320C5-L320C16
7fea563
to
0d6967f
Compare
d916978
to
43f44d7
Compare
hi, I saw that this work started 👍 |
@patricklx yes that was at the bottom of the barrel file which is now deprecated, likely won't be included if you're using vite and will be removed in Ember 7 👍 so we can't rely on that for our architecture |
Here is also a similar implementation directly in ember.js. |
59e5ab9
to
0c27ce3
Compare
c93760e
to
0148ef0
Compare
…n bring support to ember-source >= 6.1
…g multiple apps support in the future
…ains only existing modules
…ect set with macros, auto-name the app
…on, and add a TS app example
7849851
to
4474208
Compare
4474208
to
3a86309
Compare
Fixes #2484
Context
As part of the Ember Initiative, @mansona and I are trying to get ember-inspector to work for Vite apps. In the big lines, this support will imply that
ember.js
exposes a new Vite-compatible API for tools like the inspector, and the inspector should use this API instead of importing globally exposed things as it does now.However, Vite is available from Ember 3.28 to the latest, and we need the inspector to work for these versions.
We want to bring Vite compatibility to the pieces of the ecosystem that weren't designed for it. In other words, what we implement here is a "compat" piece. It's not about how the inspector should work in the future in a perfect world; it's about unblocking the inspector for people who use Vite from Ember 3.28 to [whatever version will have the future API that is not designed yet].
Changes
As it is now, the Ember Inspector relies on AMD modules that are made available globally, so we replace that with ESM modules that are made available globally. We think it’s a reasonable thing to do to make the bridge between old things and Vite world in a somewhat time-sensitive context (compatibility should work before Vite becomes the default experience).
This PR introduces a Vite plugin called
inspectorSupport()
. It's executed with the other ember() plugins that are part of the "Vite for Ember" config.This plugin provides a virtual file that can be imported (or not) into
app.js
. When it's imported and its default function is called, the globalemberInspectorApps
becomes available and can be used by the Ember Inspector. If the Ember Inspector starts to run, it will load the ES modules listed in theload()
function to retrieve the information about the app, an "equivalent" way to do what it currently does when it inspects a classic app with AMD.💡 The script we need here contains a list of imports that make sense in the context of the app. That's why we choose to approach this in a virtual file, so the imports are analysed by the build system in a context that makes sense.
How to test
app-template
onhttp://localhost:4200/
mainmatter/ember-inspector
and switch to vite-support branchember-inspector
's README aboutpnpm serve:bookmarklet
to run the local inspector againsthttp://localhost:4200/
👀 The Inspector should load correctly, and you should see the component tree in the window.
About a build mode issue (probably unrelated to the PR)
When building the app to inspect with
pnpm build
, the component tree window is blank, and the app console shows the errorCannot read properties of undefined (reading '_debugRenderTree')
(See ember_debug/libs/render-tree.js). This issue happens with theapp-template
(5.12), but not with a 4.12 app importing a./compat-inspector-support
file. There's still differences in the information on screen:Build:

Local:
