Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions:
contents: read

jobs:
jest:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand Down
1,483 changes: 44 additions & 1,439 deletions bun.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[test]
preload = ["@happy-dom/global-registrator/register"]
1,472 changes: 0 additions & 1,472 deletions docs/bun.lock

This file was deleted.

7 changes: 2 additions & 5 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@
"scripts": {
"dev": "next",
"prebuild": "bun run build:meta && bun run build:theme",
"build:meta": "cd ../packages/meta && bunx microbundle --jsxImportSource react --jsx jsx --globals react/jsx-runtime=jsxRuntime",
"build:theme": "cd ../packages/theme && bunx microbundle",
"build:meta": "cd ../packages/meta && bun run build.ts",
"build:theme": "cd ../packages/theme && bun run build.ts",
"build": "next build",
"start": "bun run dev"
},
"dependencies": {
"@emotion/react": "^11.14.0",
"@hackclub/meta": "workspace:*",
"@hackclub/theme": "workspace:*",
"@mdx-js/loader": "^3.1.1",
"@next/mdx": "^16.1.6",
"@theme-ui/css": "^0.17.4",
"@theme-ui/style-guide": "^0.17.4",
"lodash": "^4.17.23",
"next": "^16.2.0",
"react": "^19.2.4",
"react-dom": "^19.2.4",
Expand Down
40 changes: 6 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"build": "lerna run build",
"prepare": "bun run build",
"clean": "lerna run clean",
"test": "jest",
"test": "bun test",
"test:e2e": "bun run clean && bun run build && bun run test && node scripts/dist-smoke.cjs && bun run --cwd docs build",
"format": "prettier --write .",
"checkFormat": "prettier --check ."
Expand All @@ -14,44 +14,16 @@
"docs"
],
"devDependencies": {
"@swc/core": "^1.15.18",
"@swc/jest": "^0.2.39",
"@happy-dom/global-registrator": "^20.8.4",
"@testing-library/dom": "^10.4.1",
"@testing-library/react": "^16.3.2",
"jest": "^30.2.0",
"jest-environment-jsdom": "^30.2.0",
"happy-dom": "^20.8.4",
"lerna": "^9.0.5",
"microbundle": "^0.15.1",
"prettier": "^3.8.1",
"react": "^19.2.4",
"react-dom": "^19.2.4"
},
"jest": {
"testEnvironment": "jsdom",
"transform": {
"^.+\\.[jt]sx?$": [
"@swc/jest",
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": true
},
"transform": {
"react": {
"runtime": "automatic"
}
}
}
}
]
},
"testMatch": [
"**/packages/**/test/*.js"
],
"testPathIgnorePatterns": [
"/node_modules/"
]
},
"dependencies": {}
"dependencies": {
"@types/bun": "^1.3.11"
}
}
45 changes: 45 additions & 0 deletions packages/meta/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { rmSync, readFileSync, writeFileSync } from 'fs'

rmSync('./dist', { recursive: true, force: true })

const shared = {
entrypoints: ['./src/index.tsx'],
external: [
'react',
'react-dom',
'react/jsx-runtime',
'react/jsx-dev-runtime'
],
minify: true,
sourcemap: 'linked' as const,
define: {
'process.env.NODE_ENV': '"production"'
}
}

await Bun.build({
...shared,
outdir: './dist',
naming: 'index.js',
format: 'cjs'
})
await Bun.build({
...shared,
outdir: './dist',
naming: 'index.esm.mjs',
format: 'esm'
})

const tsc = Bun.spawnSync(['bunx', 'tsc', '--emitDeclarationOnly'], {
cwd: import.meta.dir
})
if (tsc.exitCode !== 0) {
console.error(tsc.stderr.toString())
process.exit(1)
}

const dtsPath = `${import.meta.dir}/dist/index.d.ts`
const dts = readFileSync(dtsPath, 'utf8')
writeFileSync(`${import.meta.dir}/dist/index.d.mts`, dts)

writeFileSync(dtsPath, dts.replace('export default ', 'export = '))
30 changes: 22 additions & 8 deletions packages/meta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,31 @@
"name": "@hackclub/meta",
"description": "Generate meta tags for Hack Club pages",
"version": "1.2.0",
"source": "src/index.js",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"unpkg": "dist/index.umd.js",
"types": "dist/index.d.ts",
"module": "dist/index.esm.mjs",
"unpkg": "dist/index.esm.mjs",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.esm.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"default": "./dist/index.js"
}
},
"files": [
"dist/"
],
"sideEffects": false,
"scripts": {
"build": "rm -rf ./dist && microbundle --jsxImportSource react --jsx jsx --globals react/jsx-runtime=jsxRuntime",
"build": "bun run build.ts",
"prepare": "bun run build",
"watch": "microbundle watch --jsxImportSource react --jsx jsx --globals react/jsx-runtime=jsxRuntime --no-compress",
"watch": "bun run --watch build.ts",
"clean": "rm -rf ./dist"
},
"publishConfig": {
Expand All @@ -27,9 +43,7 @@
"react-dom": ">=19.0.0"
},
"devDependencies": {
"microbundle": "^0.15.1",
"react": "^19.2.4",
"react-dom": "^19.2.4"
},
"gitHead": "029e83b336da014076112a68048dfa65565013ee"
}
}
21 changes: 17 additions & 4 deletions packages/meta/src/index.js → packages/meta/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
const makeTitle = (title, name) =>
import type { ReactNode, ElementType as ReactElementType } from 'react'

interface MetaProps {
as?: ReactElementType
name?: string
title?: string
description?: string
image?: string
color?: string
manifest?: string | false
children?: ReactNode
}

const makeTitle = (title: string, name: string) =>
title === name ? title : `${title} – ${name}`

const Meta = ({
as: ElementType = 'div',
name = 'Hack Club', // site name
title = 'Hack Club', // page title
name = 'Hack Club',
title = 'Hack Club',
description,
image,
color = '#ec3750',
manifest = 'https://assets.hackclub.com/favicons/site.webmanifest',
children
}) => (
}: MetaProps) => (
<ElementType>
<meta key="og_locale" property="og:locale" content="en_US" />
<meta key="og_type" property="og:type" content="website" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { test, expect, afterEach } from 'bun:test'
import { render, cleanup } from '@testing-library/react'
import Meta from '../src'

Expand Down
17 changes: 17 additions & 0 deletions packages/meta/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "ES2018",
"module": "commonjs",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./dist",
"removeComments": true,
"jsx": "react-jsx",
"esModuleInterop": true,
"types": [],
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src"]
}
38 changes: 38 additions & 0 deletions packages/theme/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { rmSync, readFileSync, writeFileSync } from 'fs'

rmSync('./dist', { recursive: true, force: true })

const shared = {
entrypoints: ['./src/index.ts'],
external: ['react', 'react-dom', 'theme-ui', '@emotion/react'],
minify: true,
sourcemap: 'linked' as const
}

await Bun.build({
...shared,
outdir: './dist',
naming: 'index.js',
format: 'cjs'
})
await Bun.build({
...shared,
outdir: './dist',
naming: 'index.esm.mjs',
format: 'esm'
})

// Generate type declarations
const tsc = Bun.spawnSync(['bunx', 'tsc', '--emitDeclarationOnly'], {
cwd: import.meta.dir
})
if (tsc.exitCode !== 0) {
console.error(tsc.stderr.toString())
process.exit(1)
}

const dtsPath = './dist/index.d.ts'
const dts = readFileSync(dtsPath, 'utf-8')
writeFileSync('./dist/index.d.mts', dts)

writeFileSync(dtsPath, dts.replace(/export default (\w+)/g, 'export = $1'))
29 changes: 22 additions & 7 deletions packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,33 @@
"description": "Hack Club’s theme for Theme UI websites",
"version": "1.0.0",
"author": "Lachlan Campbell <lachlan@hackclub.com> (https://lachlanjc.com)",
"source": "src/index.ts",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"unpkg": "dist/index.umd.js",
"module": "dist/index.esm.mjs",
"unpkg": "dist/index.esm.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.esm.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"default": "./dist/index.js"
},
"./fonts/*": "./fonts/*"
},
"files": [
"dist/",
"fonts/"
],
"sideEffects": false,
"scripts": {
"build": "microbundle",
"build": "bun run build.ts",
"prepare": "bun run build",
"watch": "microbundle watch --no-compress",
"watch": "bun run --watch build.ts",
"clean": "rm -rf ./dist"
},
"publishConfig": {
Expand All @@ -29,11 +46,9 @@
"react-dom": ">=19.0.0"
},
"devDependencies": {
"microbundle": "^0.15.1",
"react": "^19.2.4",
"react-dom": "^19.2.4"
},
"gitHead": "029e83b336da014076112a68048dfa65565013ee",
"dependencies": {
"@emotion/react": "^11.14.0",
"theme-ui": "^0.17.4"
Expand Down
1 change: 1 addition & 0 deletions packages/theme/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/* Module Resolution Options */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"types": [] /* Do not auto-include @types or bun-types */,

/* Advanced Options */
"skipLibCheck": true /* Skip type checking of declaration files. */,
Expand Down
10 changes: 5 additions & 5 deletions scripts/dist-smoke.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ const assertThemeShape = theme => {

const main = async () => {
const metaCjs = require('../packages/meta/dist/index.js')
const metaModern = await importModule('packages/meta/dist/index.modern.mjs')
const metaEsm = await importModule('packages/meta/dist/index.esm.js')
const themeCjs = require('../packages/theme/dist/index.js')
const themeModern = await importModule('packages/theme/dist/index.modern.mjs')
const themeEsm = await importModule('packages/theme/dist/index.esm.js')

assert.equal(typeof getDefault(metaCjs), 'function')
assert.equal(typeof getDefault(metaModern), 'function')
assert.equal(typeof getDefault(metaEsm), 'function')

assertMetaRender(getDefault(metaCjs))
assertMetaRender(getDefault(metaModern))
assertMetaRender(getDefault(metaEsm))

assertThemeShape(getDefault(themeCjs))
assertThemeShape(getDefault(themeModern))
assertThemeShape(getDefault(themeEsm))

console.log(
'Distribution smoke checks passed for @hackclub/meta and @hackclub/theme'
Expand Down
Loading