question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow named exports for .vue components. Don't require having a default export

See original GitHub issue

What 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:

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:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
fungus1487commented, Jun 6, 2018

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.

2reactions
yyx990803commented, Apr 10, 2018

The component itself must be the default export. That’s a requirement.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Named Exports for Components - Get Help - Vue Forum
Source: Allow named exports for .vue components. Don't require having a default export · Issue #1234 · vuejs/vue-loader · GitHub.
Read more >
Do Vue single file components (.vue files) have to `export ...
The default export should be a Vue.js component options object. Exporting an extended constructor created by Vue.extend() is also supported, ...
Read more >
A Beginners Guide to Exports in ES6 | Vue.js Developers
Lets take a closer look at the two main ways to achieve this in ES6. Default Exports. With default exports, you can only...
Read more >
Multi Export Vue.js Single File UI Components
Learn how to use named exports to export multiple components from a single .vue file and how to use JSX to build powerful...
Read more >
vue router does not provide an export named 'default' - You.com
The thing you want to do is import vue but it doesnot have a default export function or either the default thing to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found