-
Notifications
You must be signed in to change notification settings - Fork 915
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
Support for ES module named exports #1080
Comments
Yes, I agree with this. Another use case we have been trying to solve is to have a component be able to export constants that you want defined to use with that component. export const INPUT_TYPES = ["option1", "option2"] export default component; |
I have tried a way to support named exports in Vue SFC. But the default export of a Thanks. |
@Jinjiang yeah I can see the potential issue there. Perhaps this better support for injection for testability can be considered as a wider issue then. My main issue with SFCs right now is the idea of having to rely on My current workaround is simply assigning dependencies to a |
@Jinjiang, that makes sense actually. The default export would contain all the script, template, style stuff while the non default exports would just have those named objects. Thanks for getting this implemented. Once it is released I can give it and test and let you know how it goes. |
Looks good, thanks for the feature! Tested it with 13.6.0 |
What problem does this feature solve?
The primary purpose for this feature is to improve testability of Vue single file components. With named exports it is possible to have both a default export of the component with all dependencies assigned as well as a named constructor function export which would allow substitutes to be injected.
This avoids the need to use things like the inject-loader.
There are probably other use cases for supporting named exports, but testability is the primary one for me.
Related discussion on the forum: https://forum.vuejs.org/t/vue-loader-proposal-to-support-named-exports-for-testability
What does the proposed API look like?
The text was updated successfully, but these errors were encountered: