npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

create-lit-pwa

v0.1.44

Published

Create super simple PWA template

Downloads

12

Readme

Create Lit PWA

To install, run

npm init lit-pwa@latest

Introduction

This is a simple template for a PWA that uses only native Web Components, with only Google's Lit library to make working with Web Components easier.

  • PWA Installable on desktop, tablet and mobile
  • Works offline
  • Passes all Lighthouse tests
  • TS and JS can be used simultaneously

Why Lit?

Lit handles smart reactive rendering in a way similar to React, but without the overhead of a Virtual DOM.
It uses native ES String Literals and variables. Hence the name 'lit'.

import {html, css, LitElement} from 'lit';
import {customElement, property} from 'lit/decorators.js';

@customElement('simple-greeting')
export class SimpleGreeting extends LitElement {
  static styles = css`p { color: blue }`;

  @property()
  name = 'Somebody';

  render() {
    return html`<p>Hello, ${this.name}!</p>`;
  }
}

The library adds just 5KB to your bundle.
💡 Learn Lit:

Dev Tools

  • Uses TypeScript and ESLint for static analysis
  • Uses ESBuild for:
    • TypeScript compilation
    • Bundling
    • Development web server

VS Code Extensions

It is highly recommended to install following extensions:

  • esbenp.prettier-vscode
  • runem.lit-plugin
  • dbaeumer.vscode-eslint

Service worker

Lit PWA uses a service worker to implement the following features:

  • Installability
  • Work offline
  • Runtime caching
  • Serving index.html in case the server is not available or does not implement "spa behavior"

For day-to-day development, Lit PWA uses a 'Dev' service worker, which is "transparent" in the sense that it doesn't have any caching. Using this worker helps achieve a better development experience.

NPM scripts

We included 2 options for starting a development server, based on different development scenarios:

1: Common frontend development

  • 'Hot' browser reloading at every code change
  • 'Transparent' development service worker
npm start

2: Developing offline features, testing caching, running Lighthouse tests

  • Rebuild on change
  • No Live reloading
  • Fully functional service worker
npm run serve

Build for production:

npm run build

Run tests:

npm test

Debug tests:

npm run test:debug

Testing

Lit PWA uses @web/test-runner for testing. You can read more about it here:

https://modern-web.dev/guides/test-runner/getting-started https://modern-web.dev/guides/test-runner/watch-and-debug/ https://www.npmjs.com/package/web-test-runner-jasmine