I am looking at web components in a big to put together the simplest library of components as a proof of concept. The question here is around development environment and distribution.
The library will be written in Typescript. Lets say this is the simplest component:
MyFirstComponent.ts
class MyFirstComponent extends HTMLElement {
constructor() {
super();
this.textContent = "Lorem ipsum";
}
}
customElements.define('my-first-component', MyFirstComponent);
Questions
How can I share MyFirstComponent library with other projects I have/will create? I am looking from a private perspective without putting components into the public domain, although I am interested to see any options here.
Would I deploy both Typescript
and Javascript
files from my library?
I am after any professional guidance of anyone who does this for public projects or internal projects within a company.
Scenario
Suppose I have created Project 1 as a nodejs
project and I want to consume the MyFirstComponent library. I don't want both Project 1 and MyFirstComponent library to reside in the same git repository
.
The mechanism would hopefully integrate into a CI/CD workflow.
Investigations and findings
So far my research has not resulted in many findings.
I have come across bit.dev which seems to offer the above workflow with other nice bells and whistles.
Alternatively the only other way I was thinking would be to create the library as a nodejs
project and push it to the npm repository - then install the MyFirstComponent library package in projects.
I am asking a different question to this micro-frontends-web-components-and-sharing-libraries