Skip to content

Commit 39ce891

Browse files
committed
refactor: enable isolatedDeclarations
1 parent 0d56ced commit 39ce891

File tree

4 files changed

+35
-19
lines changed

4 files changed

+35
-19
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"release": "bumpp",
7373
"vite:build": "npm -C examples/vite run build",
7474
"vite:dev": "npm -C examples/vite run dev",
75+
"typecheck": "tsc --noEmit",
7576
"test": "vitest"
7677
},
7778
"dependencies": {

src/core/default-locale.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
import escapeStringRegexp from 'escape-string-regexp'
22
import { type Plugin } from 'esbuild'
3-
import { type Options } from '../types'
3+
import { type Options } from '../index'
44

5-
export const getLocaleRE = (options: Options) =>
6-
new RegExp(
5+
export function getLocaleRE(options: Options): RegExp {
6+
return new RegExp(
77
`${escapeStringRegexp(`${options.lib}/`)}(es|lib)${escapeStringRegexp(
88
'/hooks/use-locale/index'
99
)}`
1010
)
11+
}
1112

12-
export const transformDefaultLocale = (
13+
export function transformDefaultLocale(
1314
options: Options,
1415
source: string,
1516
id: string
16-
) => {
17+
): string | undefined {
1718
if (!id.match(getLocaleRE(options))) return
1819
return source.replace(
1920
'locale/lang/en',
2021
`locale/lang/${options.defaultLocale}`
2122
)
2223
}
2324

24-
export const getViteDepPlugin = (options: Options): Plugin => {
25+
export function getViteDepPlugin(options: Options): Plugin {
2526
const localeImporterRE = new RegExp(
2627
`${escapeStringRegexp(
2728
`node_modules/${options.lib}/`

src/core/style.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type ImportSpecifier, init, parse } from 'es-module-lexer'
22
import MagicString from 'magic-string'
3-
import { type Options } from '../types'
3+
import { type Options } from '../index'
44

55
type FormatType = 'cjs' | 'esm'
66

@@ -22,7 +22,7 @@ function stripeComments(code: string) {
2222
.replaceAll(singlelineCommentsRE, '')
2323
}
2424

25-
export const transformImportStyle = (
25+
export function transformImportStyle(
2626
specifier: ImportSpecifier,
2727
source: string,
2828
useSource = false,
@@ -32,7 +32,7 @@ export const transformImportStyle = (
3232
format: FormatType
3333
ignoreComponents: string[]
3434
}
35-
) => {
35+
): string | undefined {
3636
const { prefix, lib, format, ignoreComponents } = options
3737
const statement = stripeComments(source.slice(specifier.ss, specifier.se))
3838
const leftBracket = statement.indexOf('{')
@@ -66,7 +66,16 @@ export const transformImportStyle = (
6666
}
6767
}
6868

69-
export const transformStyle = async (source: string, options: Options) => {
69+
export async function transformStyle(
70+
source: string,
71+
options: Options
72+
): Promise<
73+
| {
74+
code: string
75+
readonly map: import('magic-string').SourceMap
76+
}
77+
| undefined
78+
> {
7079
const { useSource, lib, prefix, format, ignoreComponents } = options
7180

7281
if (!source) return

tsconfig.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
{
22
"compilerOptions": {
3-
"target": "es2022",
4-
"module": "esnext",
5-
"lib": ["es2022"],
3+
"target": "esnext",
4+
"lib": ["es2023"],
5+
"moduleDetection": "force",
6+
"module": "preserve",
7+
"moduleResolution": "bundler",
8+
"resolveJsonModule": true,
9+
"types": ["node"],
610
"strict": true,
7-
"esModuleInterop": true,
8-
"moduleResolution": "node",
9-
"skipLibCheck": true,
1011
"noUnusedLocals": true,
11-
"resolveJsonModule": true,
12-
"types": ["node"]
12+
"declaration": true,
13+
"isolatedDeclarations": true,
14+
"esModuleInterop": true,
15+
"isolatedModules": true,
16+
"verbatimModuleSyntax": true,
17+
"skipLibCheck": true
1318
},
14-
"include": ["src", "tests", "scripts"],
19+
"include": ["src", "tests"],
1520
"exclude": ["tests/fixtures"]
1621
}

0 commit comments

Comments
 (0)