Allow named exports for .vue components. Don't require having a default export
See original GitHub issueWhat problem does this feature solve?
I know that it is subjective to some extend, but there are proponents of named exports and I am one of them:
- Default exporting objects is usually an anti-pattern
- Why we have banned default exports and you should do the same
Most important aspect for me is the ability to refactor in less time, when dealing with named exports.
People who don’t care about the consistence in code or just by a mistake might import giving a different name every time or even once.
Then, the inconsistency will increase the complexity.
Hence, ALLOW NAMED EXPORTS, so there would be an opportunity to name all of the Vue components and prevent the possibility of people, importing same module giving a different name (obviously, there would still be export {module as anotherName} from './path'
), but no typos and still better organization of code.
What does the proposed API look like?
Don’t require having a default export. Export .vue components as:
// App.vue
export const app = {}
// instead of (without prohibiting default exporting for backwards compatibility)
export default {}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:8 (3 by maintainers)
Top GitHub Comments
Is there any means to sidestep this? It really makes refactoring a large project a nightmare, the alias allows the codebase and naming to diverge on a per file basis and unless you are religiously strict and review any Vue component renaming it has the potential to become inconsistent.
This is definitely not a problem on small to medium scale applications but we are currently porting away from a large product to Vue and this is causing us some concern going forward.
The component itself must be the default export. That’s a requirement.