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.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user