| name | module | package |
|---|---|---|
| LitElement | lit-element |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| self.addEventListener('install', event => { | |
| // cache a cat SVG | |
| event.waitUntil( | |
| caches.open('static-v1') | |
| .then(cache => cache.add('cat.svg')) | |
| ); | |
| }); | |
| self.addEventListener('activate', event => { | |
| clients.claim(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyElement extends LitElement { | |
| foo() { | |
| this.myPropertyA = 1; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log(1); | |
| Promise.resolve().then(() => { | |
| console.log(2); | |
| }); | |
| console.log(3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Batching { | |
| /** | |
| * We declare and initialize a variable to keep track of whether | |
| * or not an update has already been requested | |
| */ | |
| updateRequested = false; | |
| scheduleUpdate() { | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Batching { | |
| // ... | |
| async scheduleUpdate() { | |
| if(!this.updateRequested) { | |
| this.updateRequested = true; | |
| this.updateRequested = await false; | |
| this.update(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <body> | |
| <form id="todoInput"> | |
| <input type="text" name="todo"></input> | |
| <button type="submit">submit</button> | |
| </form> | |
| <ul id="todoList"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import path from 'path'; | |
| import fs from 'fs'; | |
| import { customElementsManifestToMarkdown } from '../custom-elements-json-to-markdown/index.js'; | |
| function generateReadme() { | |
| const components = ['generic-disclosure', 'generic-switch']; | |
| const fauxCEM = {"modules": [{"declarations": []}]; | |
| return { | |
| packageLinkPhase(cem) { | |
| const classDocForComponents = []; |
Fwiw, the past couple of weeks I've been working on supporting import assertions and CSS/JSON modules in our app at work, I thought it might be worth to share the experience and also prompted by this, maybe its helpful to someone looking into doing the same.
We currently transform our app to Systemjs. My initial thought was to start using es-module-shims, for several reasons:
- We use importmaps
- It supports CSS/JSON modules
- It would save a buildtime transformation to Systemjs
I initially thought that bundling from ESM to ESM would be at least somewhat noticeably faster than bundling from ESM to Systemjs, because of the code transform, but after running some benchmarks in our pipeline, it seemed to not make a significant difference.
