Coder Social home page Coder Social logo

Comments (7)

Conduitry avatar Conduitry commented on June 14, 2024 3

Closed this in #20 which makes it a bit easier to transition to a multiple-component package and adds a short note to the readme.

from component-template.

rixo avatar rixo commented on June 14, 2024 2

Currently, Svelma is shipping precompiled components. That means you can use them anywhere, especially outside of a Svelte application. However, that also means that they are bundled with their own copy of Svelte's runtime.

This is suboptimal if you use the components in a Svelte application that you compile yourself. And, depending on the Svelte features that are used by your components, mixing different Svelte runtime can also cause weird issues for the consumer. That's why you've got this recommendation in the README of this template:

Your package.json has a "svelte" field pointing to src/index.svelte, which allows Svelte apps to import the source code directly

I've not tested this extensively, but apparently the following seems to work (at least with rollup-plugin-svelte) for what you want to do.

In your package.json:

-  "svelte": "src/index.svelte",
+  "svelte": "src/index.js",

In index.js:

export { default as FirstComponent } from './FirstComponent.svelte'
export { default as SecondComponent } from './SecondComponent.svelte'
// etc...

from component-template.

mvolkmann avatar mvolkmann commented on June 14, 2024 2

Which is the more common case, that people want to use this to create a library containing one component or multiple? My guess is that multiple is more common. But this is set up to only support one and changes are required to support multiple. I think it should be changed to support multiple components out of the box.

from component-template.

soullivaneuh avatar soullivaneuh commented on June 14, 2024

I found an example here : https://github.com/c0bra/svelma/blob/master/src/index.js

But it is not a svelte file. What is the difference comparing this template?

from component-template.

soullivaneuh avatar soullivaneuh commented on June 14, 2024

Thanks for your knowledge share @rixo ! 👍

I'll try it as soon as possible.

from component-template.

mvolkmann avatar mvolkmann commented on June 14, 2024

I have documented all the steps required to get this to work at https://github.com/mvolkmann/svelte-components. Some of these steps could be removed with minor changes to component-template.

from component-template.

soullivaneuh avatar soullivaneuh commented on June 14, 2024

Thanks a lot @Conduitry, great addition to simplify the usage and motivate people to do more awesome stuff with svelte! 👍

I'll try it right now.

from component-template.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.