Skip to content
Draft
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
33 changes: 33 additions & 0 deletions .changeset/publish-types-layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
"@tko/bind": patch
"@tko/binding.component": patch
"@tko/binding.core": patch
"@tko/binding.foreach": patch
"@tko/binding.if": patch
"@tko/binding.template": patch
"@tko/builder": patch
"@tko/build.knockout": patch
"@tko/build.reference": patch
"@tko/computed": patch
"@tko/filter.punches": patch
"@tko/lifecycle": patch
"@tko/observable": patch
"@tko/provider": patch
"@tko/provider.attr": patch
"@tko/provider.bindingstring": patch
"@tko/provider.component": patch
"@tko/provider.databind": patch
"@tko/provider.multi": patch
"@tko/provider.mustache": patch
"@tko/provider.native": patch
"@tko/provider.virtual": patch
"@tko/utils": patch
"@tko/utils.component": patch
"@tko/utils.functionrewrite": patch
"@tko/utils.jsx": patch
"@tko/utils.parser": patch
---

Publish generated `types/` folders for all public packages and both bundled builds, and advertise those declarations through package `types` metadata and `exports` conditions so consumer imports resolve the shipped type surface instead of repo-only sources.

This also corrects the published module metadata for modern TypeScript package modes by routing `import` and `require` consumers to mode-appropriate JavaScript and declaration entrypoints. Packages now publish ESM/CJS-aware declaration entries so `bundler`, `node16`, and `nodenext` consumers resolve the shipped surface consistently instead of hitting Node-specific module-resolution mismatches.
3 changes: 3 additions & 0 deletions .github/workflows/lint-and-typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ jobs:

- name: Typecheck
run: bunx tsc

- name: Verify types (smoke test .d.ts)
run: bun run verify:types
34 changes: 2 additions & 32 deletions .github/workflows/publish-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,5 @@ jobs:
- name: Build all packages
run: bun run build

- name: Check package contents
run: |
# Verify each public package has dist files and valid package.json
for pkg in packages/*/; do
if [ -f "$pkg/package.json" ]; then
name=$(node -e "const p=require('./$pkg/package.json'); if(!p.private) console.log(p.name)")
if [ -n "$name" ]; then
echo "Checking $name..."
# Verify dist directory exists and has files
if [ ! -d "$pkg/dist" ] || [ -z "$(ls -A "$pkg/dist" 2>/dev/null)" ]; then
echo "ERROR: $name has no dist output"
exit 1
fi
# Run npm pack dry-run to verify publishable
(cd "$pkg" && npm pack --dry-run 2>&1) || exit 1
fi
fi
done
for pkg in builds/*/; do
if [ -f "$pkg/package.json" ]; then
name=$(node -e "const p=require('./$pkg/package.json'); if(!p.private) console.log(p.name)")
if [ -n "$name" ]; then
echo "Checking $name..."
if [ ! -d "$pkg/dist" ] || [ -z "$(ls -A "$pkg/dist" 2>/dev/null)" ]; then
echo "ERROR: $name has no dist output"
exit 1
fi
(cd "$pkg" && npm pack --dry-run 2>&1) || exit 1
fi
fi
done
echo "All packages pass publish check."
- name: Check published package layout and types
run: bun run verify:publish-types
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ COVERAGE.md
builds/**/meta
.nyc_output
**/dist/*
packages/*/types/*
builds/*/types/*
!packages/tko/dist/*

*-debug.log
Expand Down
16 changes: 12 additions & 4 deletions builds/knockout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
]
},
"files": [
"dist/"
"dist/",
"types/"
],
"licenses": [
{
Expand All @@ -53,8 +54,14 @@
},
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
"import": {
"types": "./types/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./types/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"tko": {
Expand All @@ -71,5 +78,6 @@
"mvvm",
"data-binding",
"compatible"
]
],
"types": "./types/index.d.ts"
}
13 changes: 11 additions & 2 deletions builds/knockout/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ const expressionRewriting = {
preProcessBindings: s => dataBindProvider.preProcessBindings(s)
}

type KnockoutBuildExtensions = {
version: string
components: typeof components
Component: typeof components.ComponentABC
expressionRewriting: typeof expressionRewriting
}

const provider = new MultiProvider({
providers: [new ComponentProvider(), dataBindProvider, new VirtualProvider(), new AttributeProvider()]
})
Expand All @@ -47,9 +54,11 @@ const builder = new Builder({
})

const version = BUILD_VERSION
export default builder.create({
const knockoutBuild: KnockoutBuildExtensions = {
version,
components,
Component: components.ComponentABC,
expressionRewriting
})
}

export default builder.create(knockoutBuild)
16 changes: 12 additions & 4 deletions builds/reference/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"@tko/utils": "^4.1.0"
},
"files": [
"dist/"
"dist/",
"types/"
],
"homepage": "https://tko.io",
"licenses": [
Expand All @@ -39,8 +40,14 @@
],
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
"import": {
"types": "./types/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./types/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"bugs": {
Expand All @@ -59,5 +66,6 @@
"mvvm",
"tsx",
"modern"
]
],
"types": "./types/index.d.ts"
}
33 changes: 18 additions & 15 deletions builds/reference/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { bindings as componentBindings } from '@tko/binding.component'
import { filters } from '@tko/filter.punches'

import components from '@tko/utils.component'
import { createElement, Fragment } from '@tko/utils.jsx'
import { JsxObserver } from '@tko/utils.jsx'
import { createElement, Fragment, render } from '@tko/utils.jsx'
import type { JsxRenderResult } from '@tko/utils.jsx'

import { options } from '@tko/utils'

Expand All @@ -27,6 +27,17 @@ declare const BUILD_VERSION: string
/** Use === and !== instead of == and != in binding expressions */
options.strictEquality = true

type ReferenceBuildExtensions = {
jsx: {
createElement: typeof createElement
Fragment: typeof Fragment
render(jsx: any): JsxRenderResult
}
components: typeof components
version: string
Component: typeof components.ComponentABC
}

const builder = new Builder({
filters,
extenders: {},
Expand Down Expand Up @@ -54,23 +65,15 @@ const builder = new Builder({

const version = BUILD_VERSION

export default builder.create({
const referenceBuild: ReferenceBuildExtensions = {
jsx: {
createElement,
Fragment,
/** Public render function that converts JSX to DOM nodes */
render(jsx: any) {
const fragment = document.createDocumentFragment()
const observer = new JsxObserver(jsx, fragment)
// Return the first child if single node, or the fragment if multiple
const node = fragment.childNodes.length === 1 ? fragment.firstChild : fragment
return {
node,
dispose: () => observer.dispose()
}
}
render
},
components,
version,
Component: components.ComponentABC
})
}

export default builder.create(referenceBuild)
Loading
Loading