-
Notifications
You must be signed in to change notification settings - Fork 142
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
Allow for more flexible addon-dev appReexports #1642
Allow for more flexible addon-dev appReexports #1642
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.
Thanks, I hadn't noticed that initializers need this, but I see you are correct.
(It's arguably a mistake that initializers ever worked this way, given how everything else in the traditional system works, but that ship has sailed and this is a feature for achieving compatibility, so I agree we should support it.)
My suggestion for how to address the concerns I've pointed out here is an API like:
function appReexports(opts: {
from: string;
to: string;
include: string[];
mapFilename?: (filename: string) => string;
+ exports?: (filename: string) => string[] | undefined;
}) {}
Returning undefined
from exports
would be treated the same as returning ['default']
.
A usage for initializers would look like:
addon.appReexports(['**/*.js'], {
exports(filename) {
if (/\/initializers\//.test(filename)) {
return ['default', 'initialize'];
}
}
})
30401ec
to
b06850b
Compare
b06850b
to
f1b9788
Compare
Thanks @ef4, good feedback, everything is addressed. One note: I changed function signature to |
@ef4 Any other feedback here? |
Backport #1642 to stable: Allow for more flexible addon-dev appReexports
While
appReexports
is pretty great at what it's doing it's not very flexible when you don't justexport { default }
. For example, if you have an initializer in v2 addon and you want to make it available to app without any additional config. But initializers requireinitialize
function to be exported too. In our case some modules need to haveexport *
as well.This change creates a way to have support for such scenarios:
addon.appReexports
can be called multiple times in the rollup config (we resetapp-js
initially when addon instance is created so there's no leftover stuff in there)defaultExport
can be also passed in which can be set to*
or{ default, initialize }
Tests were adjusted to account for all this. Let me know how this looks, any guidance will be appreciated. Cheers