fix(esm): improve ESM compatibility and modernize package configuration

This commit is contained in:
2026-05-01 18:49:10 +00:00
parent 319011b8ff
commit add1cad575
14 changed files with 5143 additions and 3579 deletions
+30 -1
View File
@@ -1,4 +1,33 @@
export * from './smartspawn.classes.threadsimple.js';
export * from './smartspawn.wrap.js';
export * from 'threads';
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
export interface IThreadsModule {
BlobWorker: new (...args: unknown[]) => unknown;
DefaultSerializer: unknown;
Pool: unknown;
Thread: {
terminate: (threadArg: unknown) => Promise<void> | void;
events?: (threadArg: unknown) => unknown;
};
Transfer: (payloadArg: unknown, transferablesArg?: Transferable[]) => unknown;
Worker: new (workerPathArg: string | URL, optionsArg?: unknown) => unknown;
registerSerializer: (serializerArg: unknown) => void;
spawn: <T = unknown>(workerArg: unknown, optionsArg?: unknown) => Promise<T>;
}
const threads = require('threads') as IThreadsModule;
export const {
BlobWorker,
DefaultSerializer,
Pool,
Thread,
Transfer,
Worker,
registerSerializer,
spawn,
} = threads;