Skip to content

Commit e924d4b

Browse files
authored
feat(twoslash)!: make default moduleResolution to bundler (#936)
1 parent 55c1554 commit e924d4b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/twoslash/src/core.ts

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { ShikiTransformer, ShikiTransformerContextMeta } from '@shikijs/typ
66
import type { Element, ElementContent, Text } from 'hast'
77
import type { TwoslashExecuteOptions, TwoslashGenericFunction } from 'twoslash'
88

9+
import type { ModuleResolutionKind } from 'typescript'
910
import type { TransformerTwoslashOptions, TwoslashRenderer, TwoslashShikiFunction, TwoslashShikiReturn } from './types'
1011
import { splitTokens } from '@shikijs/core'
1112
import { ShikiTwoslashError } from './error'
@@ -20,6 +21,9 @@ export * from './types'
2021
export function defaultTwoslashOptions(): TwoslashExecuteOptions {
2122
return {
2223
customTags: ['annotate', 'log', 'warn', 'error'],
24+
compilerOptions: {
25+
moduleResolution: 100 satisfies ModuleResolutionKind.Bundler,
26+
},
2327
}
2428
}
2529

packages/twoslash/src/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ShikiTransformer } from '@shikijs/types'
22
import type { CreateTwoslashOptions } from 'twoslash'
3+
import type { ModuleResolutionKind } from 'typescript'
34
import type { RendererRichOptions, TransformerTwoslashOptions } from './core'
45
import { createTwoslasher } from 'twoslash'
56
import { createTransformerFactory, rendererRich } from './core'
@@ -20,7 +21,12 @@ export interface TransformerTwoslashIndexOptions extends TransformerTwoslashOpti
2021
*/
2122
export function transformerTwoslash(options: TransformerTwoslashIndexOptions = {}): ShikiTransformer {
2223
return createTransformerFactory(
23-
createTwoslasher({ cache: options?.cache }),
24+
createTwoslasher({
25+
cache: options?.cache,
26+
compilerOptions: {
27+
moduleResolution: 100 satisfies ModuleResolutionKind.Bundler,
28+
},
29+
}),
2430
rendererRich(options.rendererRich),
2531
)(options)
2632
}

0 commit comments

Comments
 (0)