Skip to content
Merged

Build #108

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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.6.1] - 2026-03-08

### Fixed

- TypeScript declaration files (`.d.ts`) for the public API were missing
from the published package, breaking type resolution for consumers.

## [0.6.0] - 2026-02-28

### Added
Expand Down Expand Up @@ -318,6 +325,7 @@ a build error. Do to npm's policy, the version number cannot be reused.

First public version.

[0.6.1]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.6.1
[0.6.0]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.6.0
[0.1.0]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.1.0
[0.2.0]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.2.0
Expand Down
12 changes: 2 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pdfmkr",
"version": "0.6.0",
"version": "0.6.1",
"description": "Generate PDF documents from JavaScript objects",
"license": "MIT",
"repository": {
Expand All @@ -25,7 +25,7 @@
"npm": ">=10"
},
"scripts": {
"build": "rm -rf build/ dist/ && tsc -p tsconfig.build.json && esbuild src/index.ts --bundle --sourcemap --platform=browser --target=es2022 --outdir=dist --format=esm --external:@ralfstx/pdf-core && cp -a build/index.d.ts build/api/ dist/",
"build": "./scripts/build.sh",
"lint": "eslint . --max-warnings=0 && prettier --check .",
"test": "vitest run test",
"verify": "npm run lint && npm run test && npm run examples && npm run build",
Expand Down
26 changes: 26 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e

cd "$(dirname "$0")/.."

rm -rf build/ dist/

# Generate declaration files
tsc -p tsconfig.build.json

# Bundle the library
esbuild src/index.ts \
--bundle \
--sourcemap \
--platform=browser \
--target=es2022 \
--outdir=dist \
--format=esm \
--external:@ralfstx/pdf-core

# Copy declaration files to dist
cp build/index.d.ts dist/
cp -a build/api dist/api

# Verify that all references in dist/index.d.ts resolve
node scripts/check-dist.ts
33 changes: 33 additions & 0 deletions scripts/check-dist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Verifies that all module references in dist/index.d.ts resolve to
* existing files. Catches packaging bugs where declaration files are
* missing from the dist/ directory.
*/
import { existsSync, readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';

const indexDts = 'dist/index.d.ts';
const content = readFileSync(indexDts, 'utf-8');
const dir = dirname(indexDts);

// Match all from/import specifiers that are relative paths
const pattern = /from\s+['"](\.[^'"]+)['"]/g;
const errors: string[] = [];

for (const match of content.matchAll(pattern)) {
const specifier = match[1];
// TypeScript resolves ./foo.ts to ./foo.d.ts in declaration files
const resolved = specifier.replace(/\.ts$/, '.d.ts');
const fullPath = resolve(dir, resolved);
if (!existsSync(fullPath)) {
errors.push(`${indexDts}: unresolved reference '${specifier}' (expected ${fullPath})`);
}
}

if (errors.length > 0) {
console.error('dist check failed:');
for (const error of errors) {
console.error(` ${error}`);
}
process.exit(1);
}