From f7139495feeda5ff3f40e3c3dc115e5779504d37 Mon Sep 17 00:00:00 2001 From: hypercross Date: Sat, 8 Aug 2026 15:40:32 +0800 Subject: [PATCH] fix(proxy): load clipper-lib via require in ESM The compiled server runs Node's native ESM loader, where the CommonJS namespace object nests the real exports under 'default', so 'import * as ClipperLib' left JoinType undefined and crashed with offset. Match the existing vtracer pattern and require() the package instead. --- apps/proxy/src/routes/svgShape.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/proxy/src/routes/svgShape.ts b/apps/proxy/src/routes/svgShape.ts index 0e1fd7d..b6d7b8d 100644 --- a/apps/proxy/src/routes/svgShape.ts +++ b/apps/proxy/src/routes/svgShape.ts @@ -1,7 +1,12 @@ -import * as ClipperLib from 'clipper-lib'; +import { createRequire } from 'module'; import svgpath from 'svgpath'; import type { TracedShape } from '@tts/shared'; +// clipper-lib is a CommonJS package; load it via require so the enums and +// classes resolve under Node's native ESM loader without a `default` unwrap. +const require = createRequire(import.meta.url); +const ClipperLib = require('clipper-lib') as typeof import('clipper-lib'); + /** Number of samples per cubic bezier when flattening curves to polylines. */ const CURVE_STEPS = 12;