All Projects → bitflower → stencil-lerna

bitflower / stencil-lerna

Licence: other
A starter kit for developing PWAs in a lerna monorepo including a web-component design-system in Typescript.

Programming Languages

typescript
32286 projects
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to stencil-lerna

elements
Lovingly crafted ui components based on web components. Works well with all Frameworks - including Angular, React and Vue.
Stars: ✭ 42 (-10.64%)
Mutual labels:  stencil, web-components, lerna, design-system
Bolt
The Bolt Design System provides robust Twig and Web Component-powered UI components, reusable visual styles, and powerful tooling to help developers, designers, and content authors build, maintain, and scale best of class digital experiences.
Stars: ✭ 186 (+295.74%)
Mutual labels:  web-components, lerna, design-system
Carbon Web Components
Carbon Design System variant on top of Web Components
Stars: ✭ 171 (+263.83%)
Mutual labels:  web-components, design-system
solar-components
Web Components Implementation of Solar Design System
Stars: ✭ 16 (-65.96%)
Mutual labels:  stencil, design-system
ionic-custom-components
🌈 Ionic Tutorial: Mastering Web Components in Ionic Framework. This repo is an Ionic project showcasing Angular custom components and Stencil custom web components.
Stars: ✭ 30 (-36.17%)
Mutual labels:  stencil, web-components
Stylable
Stylable - CSS for components
Stars: ✭ 1,109 (+2259.57%)
Mutual labels:  web-components, design-system
Minna Ui
😸 A fast, friendly, and fun web UI kit for everyone.
Stars: ✭ 86 (+82.98%)
Mutual labels:  web-components, design-system
sodium-ui
Sodium is a simple, modular and customizable web component library to build elegant and accessible UI pieces for your React Application.
Stars: ✭ 23 (-51.06%)
Mutual labels:  web-components, design-system
Awesome Stenciljs
List of Awesome Web Components Built with StencilJS
Stars: ✭ 520 (+1006.38%)
Mutual labels:  stencil, web-components
Animatable Component
Animate once, use Everywhere! 💫
Stars: ✭ 188 (+300%)
Mutual labels:  stencil, web-components
web-components
A set of high-quality standards based web components for enterprise web applications. Part of Vaadin 20+
Stars: ✭ 322 (+585.11%)
Mutual labels:  web-components, design-system
Blazor.fast
A tiny wrapper around Fast and Fluent Web Components to integrate with Blazor and easily use the EditForm components
Stars: ✭ 23 (-51.06%)
Mutual labels:  web-components, design-system
Web Skills
A visual overview of useful skills to learn as a web developer
Stars: ✭ 5,107 (+10765.96%)
Mutual labels:  web-components, frameworks
Scale
The Scale library offers a set of customizable web components written with Stencil.js & TypeScript. The default theme of the library can be easily replaced so that a corresponding corporate identity of a dedicated brand can be represented.
Stars: ✭ 87 (+85.11%)
Mutual labels:  web-components, design-system
Clarity
Clarity is a scalable, accessible, customizable, open source design system built with web components. Works with any JavaScript framework, built for enterprises, and designed to be inclusive.
Stars: ✭ 6,398 (+13512.77%)
Mutual labels:  web-components, design-system
finastra-design-system
The Finastra Design System provided as a theme and components library
Stars: ✭ 100 (+112.77%)
Mutual labels:  web-components, design-system
bui
‹b› Web components for creating applications – built by Blackstone Publishing using lit-html and lit-element
Stars: ✭ 29 (-38.3%)
Mutual labels:  web-components, design-system
belleui
Web Components UI library
Stars: ✭ 36 (-23.4%)
Mutual labels:  web-components, lerna
anywhere-webcomponents
A UI work in progress based on custom elements (web components) for use in anywhere.
Stars: ✭ 17 (-63.83%)
Mutual labels:  stencil, web-components
ViennaUI
Raiffeisenbank Design System
Stars: ✭ 32 (-31.91%)
Mutual labels:  lerna, design-system

Stencil monorepo with Lerna + Typescript Project References

This is a "bare minimum" repo that shows one way to configure several Stencil and other TypeScript projects with lerna. it uses Project References. There are a lot of different ways you can set things up and this isn't intended to be authoratitive guidance or exclusionary of other ways that might work better in your project.

This repo started as a clone of https://github.com/RyanCavanaugh/learn-a.

Prerequisites

npm i lerna -g

Setting up this repo

> git clone https://github.com/bitflower/stencil-lerna.git
> cd stencil-lerna
> npm install
> lerna bootstrap
> npm run build

Also note that I haven't updated this readme.md in total to represent the Stencil use case.

Live/Hot Reload

  1. Start Production build watch of design-system:
cd packages/design-system
npm run build-watch
  1. Start main app which consumes design-system:
cd packages/app
npm start

General Structure

As with a normal lerna repo, there's a packages folder. Inside we have three creatively named packages design-system, app as well as pkg1, pkg2 and pkg3.


packages/
| tsconfig.settings.json
| tsconfig.json
| app/
| tsconfig.json
| src/
| | (typescript files)
| design-system/
| tsconfig.json
| src/
| | (typescript files)
| pkg1/
| tsconfig.json
| src/
| | (typescript files)
| lib/
| | (javascript files)
| | (.d.ts files)
| pkg2/
| (same as pkg1)
| pkg3/
| (same as pkg1)

Let's review each file in the repo and explain what's going on

tsconfig.settings.json

{
    "compilerOptions": {
        // Always include these settings
        "composite": true,
        "declaration": true,
        "declarationMap": true,
        "sourceMap": true,

        // These settings are totally up to you
        "esModuleInterop": true,
        "target": "es2017",
        "module": "esnext",
        "strict": true
    }
}

This file contains the "default" settings that all packages will use for compilation. You will definitely want the composite, declaration, declarationMap, and sourceMap settings enabled for all projects, so include those in this file. Other settings, like target and strict, can be specified here if you'd like to enable them by default. You'll also be able to override these settings on a per-package basis if needed.

tsconfig.json

{
  "files": [],
  "references": [
    { "path": "pkg1" },
    { "path": "pkg2" },
    { "path": "pkg3" },
    { "path": "design-system" },
    { "path": "app" }
  ]
}

This file is pretty simple - simply list the packages that need to be built with tsc in the references array. You should also include "files": [] in this file - this will prevent an incorrect invocation of tsc without -b from trying to build the entire packages folder source files as one compilation (which will fail, but drop a bunch of .js files in random places as an annoying side effect).

packages/pkg2/tsconfig.json

We'll just cover one of the pkg1 / pkg2 / pkg3 packages since they're basically identical for the purposes of this demo. Here's pkg2's tsconfig.json:

{
  "extends": "../tsconfig.settings.json",
  "compilerOptions": {
    "outDir": "lib",
    "rootDir": "src"
  },
  "references": [{ "path": "../pkg1" }]
}

The extends property pulls in the settings we wrote in tsconfig.settings.json, so we don't have to duplicate any settings described there.

In compilerOptions, we've set outDir to lib and rootDir to src, then placed all my .ts files in src. This means src/index.ts will build to lib/index.js and lib/index.d.ts. This is also the place where you could override settings like strict or target if you needed to change them on a per-project basis.

In the references array, we list the paths to the other projects' tsconfig.json files (or containing folders, as shown here). This will both ensure that we locate the .d.ts files correctly, and set up a proper build ordering.

packages/pkg2/src/index.ts

import * as p1 from '@ryancavanaugh/pkg1';

export function fn4() {
  p1.fn();
}

Nothing unusual going on here. We import and export with the usual syntax. Notably, if you open this repo in an editor, you can still "Go to Definition (F12)" on p1.fn here and land in pkg1/foo.ts - the original sourcecode - even though "under the covers" it's using the much faster .d.ts file for typechecking.

packages/pkg2/package.json

Here are the relevant excerpts from the package.json:

{
  "main": "lib/index.js",
  "typings": "lib/index.d.ts",
  "scripts": {
    "prepublishOnly": "tsc -b ."
  },
  "devDependencies": {
    "typescript": "^3.4.5"
  }
}

Because we build to lib, we need to set main to the .js file there and typings to the .d.ts file.

In scripts, we use the local copy of tsc (listed here as a dev dependency) to run a build mode compilation on the project. This will ensure that the lib folder is always built before npm publish, and blocks any publishes that try to push non-compiling code.

packages/pkg2/.npmignore / packages/pkg2/.gitignore

.gitignore

lib/

.npmignore

# Empty, but needs to exist

The .gitignore stops us from checking in build outputs, which is generally a good idea. By default, npm won't publish files that are ignored by git, so we need a separate .npmignore file so that the lib folder still gets published!

Workflow

All your lerna commands and workflow will work as expected here.

To build the TypeScript projects, you can run individual builds with tsc -b:

 > tsc -b packages/pkg3

Or just build everything:

 > tsc -b packages
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].