Choose a library name that is not already registered in npm.
Create the library by entering
npx degit sveltejs/component-template library-namecd library-name
Change the input property in rollup.config.js
from src/index.svelte to src/index.js.
Add a name property in package.json.
"name": "library-name",Add a version property in package.json.
"version": "0.1.0",Change the value of the main property in package.json.
"main": "index.js",Rename src/index.svelte to src/index.js.
Replace the content of src/index.js with a line like the following for each component:
export {default as MyComponentName} from './MyComponentName.svelte';Create the component .svelte files in the src directory.
Create a GitHub repository for the library.
Add the contents of this directory to the GitHub repository.
If not already logged into npm, enter npm login.
Every time changes need to be published,
bump the version in package.json
and tag the GitHub repository.
npm version patch|minor|majorgit push --tagsgit pushPublish this library to npm with npm pub.
npm install library-nameimport {LabeledInput, Select} from rmv-svelte-components;For example:
<script>
import {LabeledInput, Select} from 'rmv-svelte-components';
let color = '';
let name = 'Mark';
let options = ['', 'red', 'green', 'blue'];
</script>
<main>
<LabeledInput label="Name" bind:value="{name}" />
<p>Hello, {name}!</p>
<Select options={options} on:select={event => color = event.detail} />
<p>You selected the color {color}.</p>
</main>