diff --git a/.changeset/sharp-carpets-perform.md b/.changeset/sharp-carpets-perform.md new file mode 100644 index 00000000..60ae3df8 --- /dev/null +++ b/.changeset/sharp-carpets-perform.md @@ -0,0 +1,5 @@ +--- +"@fake-scope/fake-pkg": patch +--- + +fix: resolve circular imports in worker diff --git a/packages/eslint-mdx/src/helpers.ts b/packages/eslint-mdx/src/helpers.ts index 0aba3ab7..e3f6387d 100644 --- a/packages/eslint-mdx/src/helpers.ts +++ b/packages/eslint-mdx/src/helpers.ts @@ -4,15 +4,9 @@ import path from 'node:path' import { pathToFileURL } from 'node:url' import type { Position } from 'acorn' -import { createSyncFn } from 'synckit' import type { Point } from 'unist' -import type { - NormalPosition, - WorkerOptions, - WorkerParseResult, - WorkerProcessResult, -} from './types' +import type { NormalPosition } from './types' export const last = (items: T[] | readonly T[]) => items && items[items.length - 1] @@ -221,10 +215,3 @@ export const nextCharOffsetFactory = (text: string) => { } } } - -const workerPath = require.resolve('./worker') - -export const performSyncWork = createSyncFn(workerPath) as (( - options: Omit, -) => WorkerParseResult) & - ((options: WorkerOptions & { process: true }) => WorkerProcessResult) diff --git a/packages/eslint-mdx/src/index.ts b/packages/eslint-mdx/src/index.ts index af48b808..8e21863d 100644 --- a/packages/eslint-mdx/src/index.ts +++ b/packages/eslint-mdx/src/index.ts @@ -1,3 +1,4 @@ export * from './helpers' export * from './parser' +export * from './sync' export * from './types' diff --git a/packages/eslint-mdx/src/parser.ts b/packages/eslint-mdx/src/parser.ts index c52ed28a..4072eb3f 100644 --- a/packages/eslint-mdx/src/parser.ts +++ b/packages/eslint-mdx/src/parser.ts @@ -3,12 +3,8 @@ import path from 'node:path' import type { Linter } from 'eslint' import type { VFileMessage } from 'vfile-message' -import { - arrayify, - normalizePosition, - performSyncWork, - getPhysicalFilename, -} from './helpers' +import { arrayify, normalizePosition, getPhysicalFilename } from './helpers' +import { performSyncWork } from './sync' import type { ParserOptions, WorkerParseResult } from './types' export const DEFAULT_EXTENSIONS: readonly string[] = ['.mdx'] diff --git a/packages/eslint-mdx/src/sync.ts b/packages/eslint-mdx/src/sync.ts new file mode 100644 index 00000000..f301ac83 --- /dev/null +++ b/packages/eslint-mdx/src/sync.ts @@ -0,0 +1,14 @@ +import { createSyncFn } from 'synckit' + +import type { + WorkerOptions, + WorkerParseResult, + WorkerProcessResult, +} from './types' + +const workerPath = require.resolve('./worker') + +export const performSyncWork = createSyncFn(workerPath) as (( + options: Omit, +) => WorkerParseResult) & + ((options: WorkerOptions & { process: true }) => WorkerProcessResult)