Precise DOM morphing
morphing typescript dom

Simple build

+26
+16
build.ts
···
··· 1 + import { build } from "bun" 2 + import { $ } from "bun" 3 + 4 + // Build and minify with Bun 5 + await build({ 6 + entrypoints: ["./src/morphlex.ts"], 7 + outdir: "./dist", 8 + minify: true, 9 + sourcemap: "external", 10 + naming: "[dir]/[name].min.[ext]", 11 + }) 12 + 13 + // Generate TypeScript declarations (skip lib check to avoid node type errors) 14 + await $`tsc --emitDeclarationOnly --declaration --outDir dist --skipLibCheck` 15 + 16 + console.log("Build complete")
bun.lockb

This is a binary file and will not be displayed.

+2
package.json
··· 16 "url": "https://github.com/sponsors/joeldrapper" 17 }, 18 "scripts": { 19 "test": "vitest run", 20 "test:watch": "vitest", 21 "test:ui": "vitest --ui" 22 }, 23 "devDependencies": { 24 "@vitest/coverage-v8": "^4.0.5", 25 "@vitest/ui": "^4.0.5", 26 "gzip-size-cli": "^5.1.0",
··· 16 "url": "https://github.com/sponsors/joeldrapper" 17 }, 18 "scripts": { 19 + "build": "bun run build.ts", 20 "test": "vitest run", 21 "test:watch": "vitest", 22 "test:ui": "vitest --ui" 23 }, 24 "devDependencies": { 25 + "@types/bun": "^1.3.1", 26 "@vitest/coverage-v8": "^4.0.5", 27 "@vitest/ui": "^4.0.5", 28 "gzip-size-cli": "^5.1.0",
+7
src/morphlex.ts
··· 1 type IdSet = Set<string> 2 type IdMap = WeakMap<ReadonlyNode<Node>, IdSet> 3
··· 1 + // Type declaration for moveBefore API (not yet in TypeScript DOM types) 2 + declare global { 3 + interface Element { 4 + moveBefore?(node: Node, child: Node | null): Node 5 + } 6 + } 7 + 8 type IdSet = Set<string> 9 type IdMap = WeakMap<ReadonlyNode<Node>, IdSet> 10
+1
tsconfig.json
··· 8 "target": "es2022", 9 "removeComments": false, 10 "outDir": "dist", 11 "baseUrl": ".", 12 "noEmit": false, 13 "declaration": true,
··· 8 "target": "es2022", 9 "removeComments": false, 10 "outDir": "dist", 11 + "skipLibCheck": true, 12 "baseUrl": ".", 13 "noEmit": false, 14 "declaration": true,