Accept optional mapFilename
config for rollup-app-reexports
#1202
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.
I brought this up in Discord the other day and didn't get any immediate vehement "no way" responses, so I'm going ahead and proposing it here.
Tl;dr: in
@embroider/addon-dev
's tooling for generating app reexports, I'd like to be able to define a mapping between the source and reexport paths for an entity instead of assuming they're exactly the same.Background
For addons that expose many resolvable entities (components, helpers, services, etc), it can be helpful to somehow namespace those entities to make it clear to consumers where they're coming from when they see a component invocation or service injection.
Short of no-longer-the-future Batman namespacing, a lighter-weight way to do that is by grouping those entities together under a directory so that everything your addon exposes is clearly prefixed with an indicator of where it's from. Concretely, rather than directly having
components/foo
in mycool-addon
package, I might havecomponents/cool-addon/foo
, and consumers would write<CoolAddon::Foo />
in their templates.It's a bit cumbersome to have that extra directory in the canonical path for the implementation, though: it's an additional layer of nesting to navigate through in editors and code browsers, and you end up writing somewhat redundant import paths like
cool-addon/components/cool-addon/foo
. The latter point also becomes a bit more painful as first-class component templates pick up steam and consumers begin needing to care about the import paths of the components, helpers and modifiers they use.To mitigate this in a v1 addon, I can put my reexport in
app/components/cool-addon/foo.js
while leaving my implementation inaddon/components/foo.hbs
, but since reexports are managed as part of build tooling for v2 addons, I don't have that flexibility.This Change
This change adds an optional
appReexports
function that devs can pass toappReexports
to remap the names of files emitted as part of theirapp-js
content.By configuring my v2
cool-addon
like the snippet above, I can provide a reasonably ergonomic form factor for consuming myFoo
component unambiguously in a loose-mode template (<CoolAddon::Foo />
) or a strict-mode one (import Foo from 'cool-addon/components/foo'
).