Skip to content

Conversation

@w8r
Copy link
Owner

@w8r w8r commented Jul 21, 2025

Summary

  • Complete migration from JavaScript to TypeScript with modern tooling
  • Vite build system replaces Rollup for faster development and building
  • Vitest test runner replaces tape for modern testing experience
  • Bundled TypeScript declarations in single file for cleaner distribution
  • Working demo updated to use new build system
  • 22 passing tests converted from tape to Vitest format

Key Changes

Build System

  • Before: Rollup + Buble + tape
  • After: Vite + TypeScript + Vitest
  • Result: Faster builds, better DX, modern tooling

Output Files

  • dist/martinez.js - ES module build
  • dist/martinez.cjs - CommonJS build
  • dist/index.d.ts - Single bundled TypeScript declarations file

Scripts

  • npm run build - Build library with Vite
  • npm run test - Run tests in watch mode
  • npm run test:run - Run tests once
  • npm run dev - Start dev server with demo
  • npm run typecheck - Type checking

Source Code

  • All 18 JavaScript files converted to TypeScript with proper typing
  • Maintained 100% API compatibility
  • Added comprehensive type definitions for geometric operations

Testing

  • 4 test files converted from tape to Vitest (22 tests passing)
  • 7 additional test files remain to be converted
  • Modern expect/describe/it syntax

Test Plan

  • Library builds successfully: npm run build
  • Tests pass: npm run test:run ✅ (22/22)
  • Demo works: npm run dev
  • TypeScript declarations generated correctly ✅
  • ES module and CommonJS outputs created ✅
  • No breaking changes to public API ✅

Breaking Changes

None - fully backward compatible API

🤖 Generated with Claude Code

w8r and others added 5 commits July 21, 2025 15:52
- Convert all JavaScript source files to TypeScript with proper typing
- Replace Rollup build system with Vite for faster development
- Replace tape test runner with Vitest for modern testing
- Bundle TypeScript declarations into single file
- Update demo to work with new build system
- Maintain backward compatibility with existing API

New build outputs:
- dist/martinez.js (ES module)
- dist/martinez.cjs (CommonJS)
- dist/index.d.ts (bundled TypeScript declarations)

Scripts:
- npm run build: Build library
- npm run test: Run tests with Vitest
- npm run dev: Start dev server with demo
- npm run typecheck: Type checking

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove ESLint, TypeScript ESLint plugins, and related dependencies
- Add oxlint (Rust-based linter) for significantly faster performance
- Configure oxlint with TypeScript support and reasonable rule set
- Maintain code quality standards while improving build speed

Performance improvement:
- ESLint: ~2-3 seconds on 18 files
- oxlint: 9ms on 18 files with 96 rules using 8 threads

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
TypeScript fixes:
- Fix BBox type from interface to tuple [number, number, number, number]
- Fix connectEdges function call signature (remove unused operation parameter)
- Fix variable type conflicts in connect_edges.ts (separate tmpEvent and tmpPos)
- Add proper null assertion operators for guaranteed non-null properties

Build verification:
- ✅ Build completes successfully: dist/martinez.js, dist/martinez.cjs, dist/index.d.ts
- ✅ All 22 tests pass with Vitest
- ✅ Library functions correctly
- ✅ Main TypeScript errors resolved

Remaining errors are only in debug utilities and test files, not in core library.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
✅ Successfully converted 7 additional test files:
- compute_fields.test.js → compute_fields.test.ts (1 test)
- featureTypes.test.js → featureTypes.test.ts (16 tests)
- genericTestCases.test.js → genericTestCases.test.ts (27 tests)
- index.test.js → index.test.ts (14 tests)
- segment_intersection.test.js → segment_intersection.test.ts (11 tests)
- sweep_event.test.js → sweep_event.test.ts (6 tests)
- sweep_line.test.js → sweep_line.test.ts (1 test)

🎯 Test migration results:
- **Before**: 22 tests passing (4 converted files)
- **After**: 98 tests passing (11 converted files)
- **Improvement**: 76 additional tests (+345% increase)

🔧 Key changes:
- Converted complex nested tape test structures to proper Vitest describe/it blocks
- Updated all assertions from tape to Vitest expect syntax
- Added TypeScript support with proper type assertions
- Added glob dependency for file system test discovery
- Fixed import statements for modern package versions
- Maintained all original test logic and fixtures

All tests now run with Vitest and provide comprehensive coverage
of the martinez polygon clipping library functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants