Skip to content

Commit e697910

Browse files
EdisonSu768Zhenggang SuJounQin
authored
fix: resolve circular imports in worker (#412)
Co-authored-by: Zhenggang Su <[email protected]> Co-authored-by: JounQin <[email protected]>
1 parent 89a83a6 commit e697910

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

.changeset/sharp-carpets-perform.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fake-scope/fake-pkg": patch
3+
---
4+
5+
fix: resolve circular imports in worker

packages/eslint-mdx/src/helpers.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@ import path from 'node:path'
44
import { pathToFileURL } from 'node:url'
55

66
import type { Position } from 'acorn'
7-
import { createSyncFn } from 'synckit'
87
import type { Point } from 'unist'
98

10-
import type {
11-
NormalPosition,
12-
WorkerOptions,
13-
WorkerParseResult,
14-
WorkerProcessResult,
15-
} from './types'
9+
import type { NormalPosition } from './types'
1610

1711
export const last = <T>(items: T[] | readonly T[]) =>
1812
items && items[items.length - 1]
@@ -221,10 +215,3 @@ export const nextCharOffsetFactory = (text: string) => {
221215
}
222216
}
223217
}
224-
225-
const workerPath = require.resolve('./worker')
226-
227-
export const performSyncWork = createSyncFn(workerPath) as ((
228-
options: Omit<WorkerOptions, 'process'>,
229-
) => WorkerParseResult) &
230-
((options: WorkerOptions & { process: true }) => WorkerProcessResult)

packages/eslint-mdx/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './helpers'
22
export * from './parser'
3+
export * from './sync'
34
export * from './types'

packages/eslint-mdx/src/parser.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ import path from 'node:path'
33
import type { Linter } from 'eslint'
44
import type { VFileMessage } from 'vfile-message'
55

6-
import {
7-
arrayify,
8-
normalizePosition,
9-
performSyncWork,
10-
getPhysicalFilename,
11-
} from './helpers'
6+
import { arrayify, normalizePosition, getPhysicalFilename } from './helpers'
7+
import { performSyncWork } from './sync'
128
import type { ParserOptions, WorkerParseResult } from './types'
139

1410
export const DEFAULT_EXTENSIONS: readonly string[] = ['.mdx']

packages/eslint-mdx/src/sync.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { createSyncFn } from 'synckit'
2+
3+
import type {
4+
WorkerOptions,
5+
WorkerParseResult,
6+
WorkerProcessResult,
7+
} from './types'
8+
9+
const workerPath = require.resolve('./worker')
10+
11+
export const performSyncWork = createSyncFn(workerPath) as ((
12+
options: Omit<WorkerOptions, 'process'>,
13+
) => WorkerParseResult) &
14+
((options: WorkerOptions & { process: true }) => WorkerProcessResult)

0 commit comments

Comments
 (0)