Skip to content

Commit 835c417

Browse files
falworks-dyFAL
andauthored
native ESM 対応、およびテスト・ビルドの設定最新化 (#13)
* build: publish対象のfilesを修正 * docs: update AGENTS.md * chore: update fontkit * chore: relative import path にファイル拡張子を付与 * build: update tsconfig * chore: use type-only exports * chore: update package.json types and exports * build: CJS形式のビルドを廃止 * test: Jestのモジュール解決が失敗するようになったのを解消 * build: 各種 preset shaper クラスを露出 * chore: install vitest * fix: UPNGのimportが失敗するケースに対する暫定措置 * test: relative import path にファイル拡張子を付与、かつJestからvitestに移行 * chore: uninstall Jest * docs: update AGENTS.md * test: apps下のテストコードを更新 * build: ビルド結果の es, umd を dist ディレクトリー下に移動 * test: refactor fontkit import * docs: 古いドキュメントに注意書きを追加 * test: apps系のテストを最新化 * docs: update changelog * style: run lint fix * test: fix import paths in scratchpad * ci: fix pipelines * ci: improve npm scripts * test: minor fix * ci: テスト・ビルド用の npm scripts および tsconfig を全体的に整理 * chore: add "engines" in package.json * docs: update AGENTS.md --------- Co-authored-by: FAL <contact@fal-works.com>
1 parent 4f24c70 commit 835c417

File tree

260 files changed

+2008
-3357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

260 files changed

+2008
-3357
lines changed

.github/workflows/npm-publish-github-packages.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ jobs:
2727
with:
2828
name: build-output
2929
path: |
30-
cjs/
31-
es/
32-
umd/
30+
dist/
3331
3432
publish-gpr:
3533
needs: build

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ jobs:
3333
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3434

3535
- run: yarn dev:prep
36-
3736
- run: yarn typecheck
3837
- run: yarn lint
3938
- run: yarn test
39+
- run: yarn build
40+
- run: yarn apps:typecheck

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ apps/node-build/
33
node_modules/
44
coverage/
55
ts3.4/
6-
build/
76
umd/
87
cjs/
98
es/

AGENTS.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,32 @@
22

33
## Mission & Purpose
44
- `@denkiyagi/pdf-lib` extends the upstream `pdf-lib` to power PDF generation for `yagisan-reports`, a PDF report generation engine.
5-
- Current focus areas: richer custom font handling via `@denkiyagi/fontkit`, groundwork for improved error handling, adding PDF encryption support, and fixing upstream bugs.
5+
- Current focus areas: richer custom font handling via `@denkiyagi/fontkit`, improved error handling, adding PDF encryption support, native ESM support, and fixing upstream bugs.
66
- Keep the fork aligned with upstream quality while preserving `yagisan-reports`-specific behaviors; prefer additive changes and call out intentional divergences in `MODIFICATIONS.md` or `MODIFICATION-DEVELOPMENT.md`.
77

88
## Project Orientation
99
- `src/` – Primary TypeScript source for the library; exports must remain framework-agnostic and compatible with browsers and Node.
10-
- `tests/`Jest-powered regression coverage.
10+
- `tests/`vitest-powered unit tests.
1111
- `apps/` – Example and manual-test harnesses used to validate real-world document flows.
12+
- `dist/` – Build outputs (`dist/es` ESM + typings, `dist/umd` UMD bundle).
1213
- `assets/` – Sample PDFs, fonts, and images consumed by docs and tests; treat as fixtures when updating expectations.
13-
- `build/`, `rollup.config.mjs`, `tsconfig.json`, `jest.json` – Tooling scaffolding for bundling, type emission, and tests.
14-
- `docs/` – Markdown/docs site material mirrored from upstream; update only when behavior changes.
14+
- `tsconfig.json`, `tsconfig.build.json`, `rollup.config.mjs`, `vitest.config.ts` – Tooling scaffolding for bundling, type emission, and tests.
15+
- `docs/` – Markdown/docs site material mirrored from upstream. CAUTION: do not rely on them; they may be outdated.
1516
- `scratchpad/` – Throwaway experiments; do not rely on contents for production logic.
1617

1718
## Tech Stack
1819
- Node.js 20+ runtime, Yarn package manager.
19-
- TypeScript 4.x across source and typings.
20+
- TypeScript 5.x across source and typings.
21+
- Native ES modules both for source and build outputs.
22+
- vitest for unit testing.
2023
- Critical dependency: `@denkiyagi/fontkit` (our fork) powers font parsing, embedding, and subsetting.
2124

2225
## Common Commands
23-
- `yarn typecheck` – Checks TypeScript types across the codebase.
24-
- `yarn lint` – Runs the lint rules expected by CI; fix warnings locally to avoid pipeline noise.
26+
- `yarn typecheck` – Checks TypeScript types across `src/` and `tests/`.
27+
- `yarn lint` – Runs and fixes the lint rules expected by CI.
28+
- `yarn test` – Runs the full test suite once.
29+
- `yarn build` – Builds the library into `dist/` (uses `tsconfig.build.json`).
30+
- `yarn apps:typecheck` – Checks TypeScript types across `apps/` (requires a prior build).
2531

2632
## Helpful References
2733
- Change log: `MODIFICATIONS.md` (what differs from upstream).

MODIFICATIONS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Modifications
22

3+
## [Unreleased]
4+
5+
- Native ESM everywhere: all src/tests/apps use `.js`-suffixed local imports; Jest replaced with vitest; CJS build removed.
6+
- Build outputs relocated to `dist/`: `dist/es` (native ESM + typings) and `dist/umd` (bundled).
7+
- Package now uses conditional exports; consumers must import via the published entry points (`import`/`exports` map) rather than deep-linking files.
8+
39
## [1.17.1-mod.2025.8]
410

511
### Feature Removals

apps/node/index.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ import os from 'os';
44
import { sep } from 'path';
55
import readline from 'readline';
66

7-
import test1 from './tests/test1';
8-
import test2 from './tests/test2';
9-
import test3 from './tests/test3';
10-
import test4 from './tests/test4';
11-
import test5 from './tests/test5';
12-
import test6 from './tests/test6';
13-
import test7 from './tests/test7';
14-
import test8 from './tests/test8';
15-
import test9 from './tests/test9';
16-
import test10 from './tests/test10';
17-
import test11 from './tests/test11';
18-
import test12 from './tests/test12';
19-
import test13 from './tests/test13';
20-
import test14 from './tests/test14';
21-
import test15 from './tests/test15';
22-
import test16 from './tests/test16';
23-
import test17 from './tests/test17';
24-
import test18 from './tests/test18';
25-
import test19 from './tests/test19';
26-
import test20 from './tests/test20';
7+
import test1 from './tests/test1.js';
8+
import test2 from './tests/test2.js';
9+
import test3 from './tests/test3.js';
10+
import test4 from './tests/test4.js';
11+
import test5 from './tests/test5.js';
12+
import test6 from './tests/test6.js';
13+
import test7 from './tests/test7.js';
14+
import test8 from './tests/test8.js';
15+
import test9 from './tests/test9.js';
16+
import test10 from './tests/test10.js';
17+
import test11 from './tests/test11.js';
18+
import test12 from './tests/test12.js';
19+
import test13 from './tests/test13.js';
20+
import test14 from './tests/test14.js';
21+
import test15 from './tests/test15.js';
22+
import test16 from './tests/test16.js';
23+
import test17 from './tests/test17.js';
24+
import test18 from './tests/test18.js';
25+
import test19 from './tests/test19.js';
26+
import test20 from './tests/test20.js';
2727

2828
const cli = readline.createInterface({
2929
input: process.stdin,

apps/node/tests/test1.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Assets } from '..';
1+
import { Assets } from '../index.js';
22
import {
33
clip,
44
clipEvenOdd,
@@ -18,9 +18,9 @@ import {
1818
rgb,
1919
setLineJoin,
2020
StandardFonts,
21-
} from '../../..';
22-
import { AFRelationship } from '../../../cjs/core';
23-
import { typedArrayFor } from '../../../cjs/utils';
21+
} from '../../../dist/es/index.js';
22+
import { AFRelationship } from '../../../dist/es/core/index.js';
23+
import { typedArrayFor } from '../../../dist/es/utils/index.js';
2424

2525
const ipsumLines = [
2626
'Eligendi est pariatur quidem in non excepturi et.',

apps/node/tests/test10.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Assets } from '..';
2-
import { PDFDocument, StandardFonts, PDFFont } from '../../..';
1+
import { Assets } from '../index.js';
2+
import { PDFDocument, StandardFonts, PDFFont } from '../../../dist/es/index.js';
33

44
// prettier-ignore
55
const winAnsiCodePoints = [

apps/node/tests/test11.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Assets } from '..';
2-
import { PDFDocument, PDFFont, StandardFonts } from '../../..';
3-
import { charAtIndex, last } from '../../../cjs/utils';
1+
import { Assets } from '../index.js';
2+
import { PDFDocument, PDFFont, StandardFonts } from '../../../dist/es/index.js';
3+
import { charAtIndex, last } from '../../../dist/es/utils/index.js';
44

55
const breakTextIntoLines = (
66
text: string,

apps/node/tests/test12.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Assets } from '..';
1+
import { Assets } from '../index.js';
22
import {
33
PageSizes,
44
PDFDocument,
@@ -8,8 +8,8 @@ import {
88
degrees,
99
rgb,
1010
grayscale,
11-
} from '../../..';
12-
import { values } from '../../../cjs/utils';
11+
} from '../../../dist/es/index.js';
12+
import { values } from '../../../dist/es/utils/index.js';
1313

1414
const inchToPt = (inches: number) => Math.round(inches * 72);
1515

0 commit comments

Comments
 (0)