Comments (7)
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.
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.
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.
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.
Thanks for your knowledge share @rixo ! 👍
I'll try it as soon as possible.
from component-template.
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.
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)
- Repository as template
- Binding a DOM element doesn't work when imported in a different project HOT 1
- Build error: " `this` has been rewritten to `undefined` " HOT 2
- warning: option.name should be capitalized
- some documentation suggestions HOT 1
- Storybook implementation HOT 3
- Document how to use a component outside of svelte HOT 2
- Add a TypeScript component template HOT 19
- Local dev server for building and testing components HOT 12
- What is the meaning of these lines in rollup.config.js? HOT 5
- Why does it need to be a template only project, why not a full CLI? HOT 4
- emitCss HOT 1
- Upgrade template for v3 of Svelte HOT 7
- Custom Element build target is missing HOT 2
- ES5 transpiling ? HOT 3
- Preprocessor support HOT 13
- how to use it? what is .mjs file? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from component-template.