Skip to content
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

Is it necessary to redundantly specify components ? #1120

Closed
pushqrdx opened this issue Jan 19, 2018 · 3 comments
Closed

Is it necessary to redundantly specify components ? #1120

pushqrdx opened this issue Jan 19, 2018 · 3 comments

Comments

@pushqrdx
Copy link

pushqrdx commented Jan 19, 2018

Well, Svelte so far is pretty darn smooth (from me reading the docs) but somethings are plain weird. I mean why would it be necessary to redundantly do this

<!-- App.html -->
<h1>Hello {{$name}}!</h1>
<Greeting/>

<script>
  import Greeting from './Greeting.html';
  export default {
    components: { Greeting } //WHY THIS.
  };
</script>

Isn't the import and the element tag fair enough reasons for the compiler to assume that it's a currently used component ?...

@Conduitry
Copy link
Member

There's already some discussion about how to make this more succinct in #1038.

Svelte compiles each component separately (and then they get bundled together later), so it can't actually tell whether a given import is intended as a component. And, similarly if you used a component without importing it, the bundler would not know where the component is supposed to come from.

@pushqrdx
Copy link
Author

pushqrdx commented Jan 19, 2018

Well, It can tell by Convention, Let's say we have a <Greeting/> Tag. If we already are importing Greeting, the compiler, by convention, should assume that it's a component.

@arxpoetica
Copy link
Member

Closing this issue in favor of continuing the discussion on duplicate ticket #1038. @pushqrdx my convenient answer ;) is to offport such "magic" to a bundler like Rollup or WebPack, but let's take the discussion over to the already-open ticket. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants