Skip to content

Instantly share code, notes, and snippets.

View thepassle's full-sized avatar

Pascal Schilp thepassle

View GitHub Profile
@thepassle
thepassle / sw.js
Created October 28, 2019 14:48
clientsclaim9
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();
class MyElement extends LitElement {
foo() {
this.myPropertyA = 1;
}
}
console.log(1);
Promise.resolve().then(() => {
console.log(2);
});
console.log(3);
class Batching {
/**
* We declare and initialize a variable to keep track of whether
* or not an update has already been requested
*/
updateRequested = false;
scheduleUpdate() {
/**
class Batching {
// ...
async scheduleUpdate() {
if(!this.updateRequested) {
this.updateRequested = true;
this.updateRequested = await false;
this.update();
}
}
<html>
<body>
<form id="todoInput">
<input type="text" name="todo"></input>
<button type="submit">submit</button>
</form>
<ul id="todoList">

./fixtures/-TEST/package/my-element.js:

class: SuperClass

Superclass

name module package
LitElement lit-element
@thepassle
thepassle / ajax.md
Last active February 12, 2021 10:25

./index.js:

Exports

kind name declaration module package
js ajax ajax ./src/ajax.js
js setAjax setAjax ./src/ajax.js
js AjaxClass AjaxClass ./src/AjaxClass.js
js cancelInterceptorFactory cancelInterceptorFactory ./src/interceptors.js
@thepassle
thepassle / generateReadme.js
Last active February 16, 2021 19:32
Generate README files for generic-components as a custom-elements-manifest plugin
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 = [];
@thepassle
thepassle / conclusion.md
Last active January 19, 2022 10:08
css modules conclusion

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.

image (5)