Skip to content

Support for ES module named exports #1080

Closed
@chrisnicola

Description

@chrisnicola

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>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions