Files
Bendik Aagaard LynghaugandClaude Fable 5 ce1ec9e4a9 rebrand: buuh — a friendly public fork under the uhhm org
Packages renamed to the @uhhm scope (@uhhm/buuh, @uhhm/buuh-html,
@uhhm/buuh-component, @uhhm/buuh-devtools, @uhhm/buuh-migrate,
@uhhm/bankai). Scoping is load-bearing twice over: npm routes registries
per scope so @uhhm/* resolves against project.uhhm.no while everything
else stays on npmjs, and it means this fork never squats upstream's
names anywhere. The codemod now migrates choo v7 apps to the @uhhm
names. README rewritten with the fork framing and full upstream credit;
the choojs RFC moves to docs/upstream-rfc-draft.md, in the drawer for if
this work ever goes home. API unchanged — choo() is still choo().

Also: Gitea Actions CI + release workflows (npm publish to the uhhm
registry on tag push, CDN bundle uploaded as a generic package),
npm run bundle producing dist-cdn/buuh.js (the whole framework as one
minified ES module for import-map use), docs/publishing.md explaining
what Gitea Packages is (a real npm registry) and is not (a CDN — serve
the bundle from a static host with module-safe MIME instead), and
onload.js constructing window.MutationObserver to match its own guard
(surfaced by smoke-testing the bundle outside a full browser).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014NgfSjHE11oFpoSnLVKLXd
2026-09-08 19:55:20 +02:00

93 lines
3.1 KiB
JavaScript

import { test } from 'node:test'
import assert from 'node:assert'
import transform from '../lib/transform.js'
test('converts a classic choo v7 header to v8 ESM', () => {
const src = [
"var choo = require('choo')",
"var html = require('choo/html')",
"var devtools = require('choo-devtools')",
'',
'var app = choo()',
"app.use(devtools())",
'module.exports = app'
].join('\n')
const { code, changed, notes } = transform(src)
assert.ok(changed)
assert.match(code, /import choo from '@uhhm\/buuh'/)
assert.match(code, /import html from '@uhhm\/buuh-html'/)
assert.match(code, /import devtools from '@uhhm\/buuh-devtools'/)
assert.match(code, /export default app/)
assert.deepStrictEqual(notes, [])
})
test('destructured and property requires', () => {
const src = [
"const { render } = require('some-lib')",
"const thing = require('other-lib').thing",
"const dflt = require('third-lib').default",
"require('./side-effect')"
].join('\n')
const { code } = transform(src)
assert.match(code, /import { render } from 'some-lib'/)
assert.match(code, /import { thing as thing } from 'other-lib'/)
assert.match(code, /import dflt from 'third-lib'/)
assert.match(code, /import '\.\/side-effect'/)
})
test('already-ESM sources get specifiers remapped', () => {
const src = [
"import choo from 'choo'",
"import html from 'nanohtml'",
"import raw from 'nanohtml/raw'",
"import morph from 'nanomorph'",
"import Component from 'nanocomponent'"
].join('\n')
const { code } = transform(src)
assert.match(code, /from '@uhhm\/buuh'/)
assert.match(code, /from '@uhhm\/buuh-html'\n/)
assert.match(code, /from '@uhhm\/buuh-html\/raw'/)
assert.match(code, /from '@uhhm\/buuh-html\/morph'/)
assert.match(code, /from '@uhhm\/buuh-component'/)
})
test('retired packages produce notes, not rewrites', () => {
const src = [
"var nanobus = require('nanobus')",
"var lazyRoute = require('choo-lazy-route')"
].join('\n')
const { code, notes } = transform(src)
assert.match(code, /from 'nanobus'/, 'retired specifier left for the human')
assert.ok(notes.some((n) => n.includes('nanobus')))
assert.ok(notes.some((n) => n.includes('lazy()')), 'choo-lazy-route points at lazy()')
})
test('dynamic import() specifiers are remapped too', () => {
const { code } = transform("const mod = await import('choo/html')")
assert.match(code, /import\('@uhhm\/buuh-html'\)/)
})
test('unconvertible CJS is reported honestly', () => {
const src = [
"module.exports.helper = function () {}",
"function f () { const x = require('choo') }"
].join('\n')
const { code, notes } = transform(src)
assert.match(code, /require\('@uhhm\/buuh'\)/, 'specifier remapped even inside functions')
assert.ok(notes.some((n) => n.includes('module.exports')))
assert.ok(notes.some((n) => n.includes('require() calls remain')))
})
test('non-choo sources pass through untouched', () => {
const src = "import fs from 'node:fs'\nexport const x = 1\n"
const { changed, notes } = transform(src)
assert.strictEqual(changed, false)
assert.deepStrictEqual(notes, [])
})