Closed
Description
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?
<script>
import dep1 from 'dep1'
import dep2 from 'dep2'
export function component(dep1, dep2) {
...
return {
properties: {},
data() { },
methods: {},
...
};
}
export default component(dep1, dep2);
</script>