From: Martin Pitt Date: Fri, 1 Nov 2019 17:49:26 +0000 (+0100) Subject: Add npm: Separate html and js, taking lit-* from npm X-Git-Url: https://piware.de/gitweb/?a=commitdiff_plain;h=c844019737a48e1ca8752d81c15f0ce4e2621e0e;p=webcomponents.git Add npm: Separate html and js, taking lit-* from npm This does not work yet, due to lit-element's bare import of lit-html: TypeError: Error resolving module specifier: lit-html --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5f19d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +package-lock.json diff --git a/npm/hello-world.js b/npm/hello-world.js new file mode 100644 index 0000000..b3e3b9a --- /dev/null +++ b/npm/hello-world.js @@ -0,0 +1,9 @@ +import { LitElement, html, css } from './node_modules/lit-element/lit-element.js'; + +class HelloWorld extends LitElement { + render() { + return html`

Hello world! Came here from ${document.referrer || 'unset-referrer' }

`; + } +} + +customElements.define('hello-world', HelloWorld); diff --git a/npm/index.html b/npm/index.html new file mode 100644 index 0000000..b3b0e39 --- /dev/null +++ b/npm/index.html @@ -0,0 +1,15 @@ + + lit-html npm example + + + + + + +

Hello world with lit-html from npm

+ +

If you don't see hello world below, you need to run npm install.

+ + + + diff --git a/npm/package.json b/npm/package.json new file mode 100644 index 0000000..9e8ff49 --- /dev/null +++ b/npm/package.json @@ -0,0 +1,17 @@ +{ + "name": "webcomponents-npm-test", + "version": "0.0.1", + "private": "true", + "description": "test", + "main": "index.js", + "dependencies": { + "lit-element": "^2.2.1" + }, + "devDependencies": {}, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "run": "python -m http.server -b localhost" + }, + "author": "", + "license": "ISC" +}