From 6119a3c6c65aee9b8635ab675d45f5405db6eb7e Mon Sep 17 00:00:00 2001 From: indooorsman Date: Mon, 12 Jun 2023 18:16:34 +0800 Subject: [PATCH] refine index.d.ts --- index.d.ts | 36 +++++++++++++++++++++--------------- tsconfig.json | 8 ++++---- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/index.d.ts b/index.d.ts index 1f6e4ef..52b3885 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,6 @@ import type { Plugin, PluginBuild } from 'esbuild'; -export interface Options { +declare interface BuildOptions { /** force to build modules-css files even if `bundle` is disabled in esbuild, default is `false` */ force?: boolean; /** inline images imported in css as data url even if `bundle` is false */ @@ -49,21 +49,27 @@ export interface Options { }; } -interface BuildContext { - options: Options; - buildId: string; - buildRoot: string; - packageName: string; - packageVersion: string; - log: (...args: any[]) => void; - relative: (to: string) => string; - normalizedEntries: string[]; -} +declare function CssModulesPlugin(options?: BuildOptions): Plugin; -declare function CssModulesPlugin(options?: Options): Plugin; +declare namespace CssModulesPlugin { + export interface Options extends BuildOptions {}; + + export interface BuildContext { + options: Options; + buildId: string; + buildRoot: string; + packageName: string; + packageVersion: string; + log: (...args: any[]) => void; + relative: (to: string) => string; + normalizedEntries: string[]; + } -export type setup = (build: PluginBuild, options: Options) => void; + export type setup = (build: PluginBuild, options: Options) => void; -export interface Build extends PluginBuild { - context: BuildContext; + export interface Build extends PluginBuild { + context: BuildContext; + } } + +export = CssModulesPlugin; diff --git a/tsconfig.json b/tsconfig.json index ba4ce78..28b9717 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,13 +7,13 @@ "checkJs": true, "strict": true, "lib": [ - "ES2022" + "ESNext" ], "skipDefaultLibCheck": true, "skipLibCheck": true, - "module": "NodeNext", - "target": "ES2022", - "moduleResolution": "nodenext", + "module": "ESNext", + "target": "ESNext", + "moduleResolution": "bundler", "allowSyntheticDefaultImports": true, "esModuleInterop": true },