-
-
Notifications
You must be signed in to change notification settings - Fork 408
Description
Historically, Ember compiles a moduleName into the wire format of each template. The Ember Inspector displays this when navigating the hierarchy of components.
This isn't really viable going forward, for two reasons:
-
moduleNameas traditionally understood doesn't exist reliably anymore- it used to be the "runtime" name of a module, which was unambiguous because all packages were forced into one flat namespace. But we don't do that anymore. Under embroider (and even in classic builds when consuming v2 addons), we follow normal node_modules resolution, so packages are not a flat namespace.
- the mapping from publicly-visible name to internal-name can be complicated, based on the full feature set of package.json exports. For us to try to produce a traditional
moduleNamewe would need to faithfully run that transformation, backwards.
-
The existence of Template Tag means that templates are not one-to-one with modules anymore. So identifying which module a component lives in is not enough to unambiguously locate it.
Since templates are javascript values (or to be precise: templates are a detail of components and components are javascript values), it's worth asking: why do we think we need to label them with their module names, when we don't do that with any other javascript values?
I would like to suggest that instead of trying to label components by their template moduleName, we can change the inspector to offer a "jump to definition" button on components.
- For class-based components,
window.inspect(theComponentInstance.constructor)already works. - But for template-only components, there's no function present to point at.
- we could introduce one inside the wire format of the template
- or we could make
templateOnlyComponent()capture an Exception and save its stack so that it would be possible to navigate back to the site at which the component was defined.
A related concern here is that AST transforms can see moduleName and I know some rely on it. They need a deprecation path to stop doing that. It's going to troll them anyway as soon as people are using template tag.