From c844019737a48e1ca8752d81c15f0ce4e2621e0e Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 1 Nov 2019 18:49:26 +0100 Subject: [PATCH] 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 --- .gitignore | 2 ++ npm/hello-world.js | 9 +++++++++ npm/index.html | 15 +++++++++++++++ npm/package.json | 17 +++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 .gitignore create mode 100644 npm/hello-world.js create mode 100644 npm/index.html create mode 100644 npm/package.json 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" +} -- 2.39.2