Skip to content

Instantly share code, notes, and snippets.

View thepassle's full-sized avatar

Pascal Schilp thepassle

  • Tranquility Base Hotel & Casino
View GitHub Profile
import { pathToFileURL } from 'url';
import { createModuleGraph } from '@thepassle/module-graph';
import { nodeResolve } from '@rollup/plugin-node-resolve';
function createResolve(resolveOptions = {}) {
const r = nodeResolve(resolveOptions);
return {
resolve() {
return null;
import fs from "fs";
import path from "path";
import { pathToFileURL, fileURLToPath } from "url";
import { builtinModules } from "module";
import { init, parse } from "es-module-lexer";
import { moduleResolve } from "import-meta-resolve";
/**
* @param {string} specifier
* @returns {boolean}
import fs from "fs";
import path from "path";
import { pathToFileURL, fileURLToPath } from "url";
import { builtinModules } from "module";
import { init, parse } from "es-module-lexer";
import { moduleResolve } from "import-meta-resolve";
class ModuleGraph {
/**
* @param {string} basePath
@thepassle
thepassle / swsr.js
Last active April 23, 2024 08:17
swsr.js
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify';
import path from 'path';
import fs from 'fs';
import { injectManifest } from 'workbox-build';
import { build } from "esbuild";
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
@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)

@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 / 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

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

class: SuperClass

Superclass

name module package
LitElement lit-element
<html>
<body>
<form id="todoInput">
<input type="text" name="todo"></input>
<button type="submit">submit</button>
</form>
<ul id="todoList">
class Batching {
// ...
async scheduleUpdate() {
if(!this.updateRequested) {
this.updateRequested = true;
this.updateRequested = await false;
this.update();
}
}