diff --git a/packages/create-fes-app/templates/app/h5/tsconfig.json b/packages/create-fes-app/templates/app/h5/tsconfig.json index a258cd6b..edff9189 100644 --- a/packages/create-fes-app/templates/app/h5/tsconfig.json +++ b/packages/create-fes-app/templates/app/h5/tsconfig.json @@ -29,12 +29,9 @@ } }, "include": [ - "*.js", - ".fes*.js", "src/**/*", - "typings/**/*", - "config/**/*", - "src/.fes/configType.d.ts" + "*.js", + ".fes*.js" ], "exclude": [ "build", diff --git a/packages/create-fes-app/templates/app/pc/tsconfig.json b/packages/create-fes-app/templates/app/pc/tsconfig.json index a258cd6b..cf4fb0f0 100644 --- a/packages/create-fes-app/templates/app/pc/tsconfig.json +++ b/packages/create-fes-app/templates/app/pc/tsconfig.json @@ -33,8 +33,7 @@ ".fes*.js", "src/**/*", "typings/**/*", - "config/**/*", - "src/.fes/configType.d.ts" + "config/**/*" ], "exclude": [ "build", diff --git a/packages/fes-builder-webpack/package.json b/packages/fes-builder-webpack/package.json index 4405edc1..0a08d419 100644 --- a/packages/fes-builder-webpack/package.json +++ b/packages/fes-builder-webpack/package.json @@ -3,7 +3,7 @@ "version": "3.0.0-beta.6", "description": "@fesjs/builder-webpack", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "types.d.ts", "files": [ "lib", "types.d.ts" @@ -66,4 +66,4 @@ "@fesjs/fes": "^3.0.0-beta.0", "core-js": "^3.19.2" } -} +} \ No newline at end of file diff --git a/packages/fes-plugin-access/types.d.ts b/packages/fes-plugin-access/types.d.ts index d10c5c98..a692f670 100644 --- a/packages/fes-plugin-access/types.d.ts +++ b/packages/fes-plugin-access/types.d.ts @@ -1,6 +1,16 @@ import { Router, NavigationGuard } from 'vue-router'; import { Ref } from 'vue'; +export function access(): { + hasAccess(accessId: string | number): Promise; + isDataReady(): boolean; + setRole(roleId: string | Promise): void; + setAccess(accessIds: Array | Promise>): void; + getAccess(): string[]; +}; + +export function useAccess(accessId: Array): Ref; + declare module '@fesjs/fes' { interface PluginBuildConfig { access?: @@ -16,14 +26,4 @@ declare module '@fesjs/fes' { unAccessHandler: (param: { router: Router } & NavigationGuard) => void; }; } - - export function access(): { - hasAccess(accessId: string | number): Promise; - isDataReady(): boolean; - setRole(roleId: string | Promise): void; - setAccess(accessIds: Array | Promise>): void; - getAccess(): string[]; - }; - - export function useAccess(accessId: Array): Ref; } diff --git a/packages/fes-plugin-enums/types.d.ts b/packages/fes-plugin-enums/types.d.ts index d726c0b5..d847b163 100644 --- a/packages/fes-plugin-enums/types.d.ts +++ b/packages/fes-plugin-enums/types.d.ts @@ -14,12 +14,11 @@ interface EnumApi { convert(name: string, _enum?: [] | object, option?: { keyName: string; valueName: string }): any; } +export const enums: EnumApi; declare module '@fesjs/fes' { interface PluginBuildConfig { enums?: { [key: string]: [string | number, string | number][]; } | false; } - - export const enums: EnumApi; } diff --git a/packages/fes-plugin-layout/types.d.ts b/packages/fes-plugin-layout/types.d.ts index 166fa069..ad845495 100644 --- a/packages/fes-plugin-layout/types.d.ts +++ b/packages/fes-plugin-layout/types.d.ts @@ -10,6 +10,7 @@ interface Menu { children?: Menu[]; } +export const Page: Component; declare module '@fesjs/fes' { interface RouteMeta { 'keep-alive'?: boolean; @@ -61,5 +62,4 @@ declare module '@fesjs/fes' { }; } - export const Page: Component; } diff --git a/packages/fes-plugin-locale/types.d.ts b/packages/fes-plugin-locale/types.d.ts index e1f44a05..662e9938 100644 --- a/packages/fes-plugin-locale/types.d.ts +++ b/packages/fes-plugin-locale/types.d.ts @@ -1,5 +1,11 @@ import '@fesjs/fes'; +export const locale: { + setLocale({ locale }: { locale: string }): void; + addLocale({ locale, messages }: { locale: string; messages: object }): void; + getAllLocales(): string[]; + messages: Record; +}; declare module '@fesjs/fes' { interface PluginBuildConfig { locale?: @@ -11,13 +17,4 @@ declare module '@fesjs/fes' { } | false; } - - // export * from 'vue-i18n'; - - export const locale: { - setLocale({ locale }: { locale: string }): void; - addLocale({ locale, messages }: { locale: string; messages: object }): void; - getAllLocales(): string[]; - messages: Record; - }; } diff --git a/packages/fes-plugin-model/types.d.ts b/packages/fes-plugin-model/types.d.ts index 6742606e..ef95bebd 100644 --- a/packages/fes-plugin-model/types.d.ts +++ b/packages/fes-plugin-model/types.d.ts @@ -1,10 +1,9 @@ import '@fesjs/fes'; +export function useModel(moduleId: string): any; declare module '@fesjs/fes' { interface PluginBuildConfig { model?: {} | false; } - - export function useModel(moduleId: string): any; } diff --git a/packages/fes-plugin-monaco-editor/types.d.ts b/packages/fes-plugin-monaco-editor/types.d.ts index 077e14d2..8f7c4fa4 100644 --- a/packages/fes-plugin-monaco-editor/types.d.ts +++ b/packages/fes-plugin-monaco-editor/types.d.ts @@ -2,6 +2,7 @@ import type { Component } from 'vue'; import type { EditorLanguage } from 'monaco-editor-webpack-plugin/out/languages'; import type { EditorFeature } from 'monaco-editor-webpack-plugin/out/features'; +export const MonacoEditor: Component; declare module '@fesjs/fes' { interface PluginBuildConfig { monacoEditor?: { @@ -12,6 +13,4 @@ declare module '@fesjs/fes' { globalAPI: boolean; } | false; } - - export const MonacoEditor: Component; } diff --git a/packages/fes-plugin-pinia/src/index.js b/packages/fes-plugin-pinia/src/index.js index 3aefaa34..1401ce4a 100644 --- a/packages/fes-plugin-pinia/src/index.js +++ b/packages/fes-plugin-pinia/src/index.js @@ -2,6 +2,7 @@ import { readFileSync } from 'fs'; import { join } from 'path'; import { winPath } from '@fesjs/utils'; import { parseStore } from './helper'; +import { name } from '../package.json'; const namespace = 'plugin-pinia'; @@ -52,4 +53,8 @@ export default (api) => { ]); api.addRuntimePlugin(() => `@@/${absRuntimeFilePath}`); + + api.addConfigType(() => ({ + source: name, + })); }; diff --git a/packages/fes-plugin-pinia/types.d.ts b/packages/fes-plugin-pinia/types.d.ts index 2610282a..3350932b 100644 --- a/packages/fes-plugin-pinia/types.d.ts +++ b/packages/fes-plugin-pinia/types.d.ts @@ -1,9 +1,8 @@ import type { Pinia } from 'pinia'; +export const pinia: Pinia; declare module '@fesjs/fes' { interface PluginBuildConfig { pinia?: {} | false; } - - export const pinia: Pinia; } diff --git a/packages/fes-plugin-qiankun/types.d.ts b/packages/fes-plugin-qiankun/types.d.ts index 974ae510..95bd78cc 100644 --- a/packages/fes-plugin-qiankun/types.d.ts +++ b/packages/fes-plugin-qiankun/types.d.ts @@ -7,20 +7,18 @@ interface AppOption { props: Record; } -declare module '@fesjs/fes' { - interface PluginBuildConfig { - qiankun?: - | { - main?: { - apps: AppOption[]; - lifeCycles?: FrameworkLifeCycles; - [key: string]: any; - }; - micro?: {}; - } - | false; - } - - export const MicroApp: Component; - export const MicroAppWithMemoHistory: Component; +export interface PluginBuildConfig { + qiankun?: + | { + main?: { + apps: AppOption[]; + lifeCycles?: FrameworkLifeCycles; + [key: string]: any; + }; + micro?: {}; + } + | false; } + +export const MicroApp: Component; +export const MicroAppWithMemoHistory: Component; \ No newline at end of file diff --git a/packages/fes-plugin-request/types.d.ts b/packages/fes-plugin-request/types.d.ts index f9757c48..1d3c2526 100644 --- a/packages/fes-plugin-request/types.d.ts +++ b/packages/fes-plugin-request/types.d.ts @@ -13,6 +13,8 @@ interface RequestPluginOption { } } +export function request(url: string, data: null | Record, options: AxiosRequestConfig & RequestPluginOption ): Promise +export function useRequest(url: string, data: null | Record, options: AxiosRequestConfig & RequestPluginOption ): {loadingRef: Ref; errorRef: Ref; dataRef: Ref} declare module "@fesjs/fes" { interface PluginRuntimeConfig { request?: { @@ -22,6 +24,4 @@ declare module "@fesjs/fes" { responseInterceptors?: ResponseInterceptor[]; } & AxiosRequestConfig; } - export function request(url: string, data: null | Record, options: AxiosRequestConfig & RequestPluginOption ): Promise - export function useRequest(url: string, data: null | Record, options: AxiosRequestConfig & RequestPluginOption ): {loadingRef: Ref; errorRef: Ref; dataRef: Ref} } \ No newline at end of file diff --git a/packages/fes-plugin-sass/types.d.ts b/packages/fes-plugin-sass/types.d.ts index b8f33615..67018485 100644 --- a/packages/fes-plugin-sass/types.d.ts +++ b/packages/fes-plugin-sass/types.d.ts @@ -1,4 +1,4 @@ -import '@fesjs/fes'; + declare module '@fesjs/fes' { interface PluginBuildConfig { diff --git a/packages/fes-plugin-vuex/types.d.ts b/packages/fes-plugin-vuex/types.d.ts index b7023867..7fa2663f 100644 --- a/packages/fes-plugin-vuex/types.d.ts +++ b/packages/fes-plugin-vuex/types.d.ts @@ -1,4 +1,11 @@ -import '@fesjs/fes'; + +export const MUTATION_TYPES: object; + +export const ACTION_TYPES: object; + +export const GETTER_TYPES: object; + +export const store: object; declare module '@fesjs/fes' { interface PluginBuildConfig { vuex?: @@ -9,11 +16,4 @@ declare module '@fesjs/fes' { | false; } - export const MUTATION_TYPES: object; - - export const ACTION_TYPES: object; - - export const GETTER_TYPES: object; - - export const store: object; } \ No newline at end of file diff --git a/packages/fes-plugin-watermark/types.d.ts b/packages/fes-plugin-watermark/types.d.ts index 50757827..e5b81af0 100644 --- a/packages/fes-plugin-watermark/types.d.ts +++ b/packages/fes-plugin-watermark/types.d.ts @@ -14,6 +14,8 @@ interface WatermarkParam { zIndex: number; timestamp: string; } +export function createWatermark(param: WatermarkParam): void; +export function destroyWatermark(): void; declare module '@fesjs/fes' { interface PluginBuildConfig { @@ -21,7 +23,4 @@ declare module '@fesjs/fes' { disable: boolean; } | false; } - - export function createWatermark(param: WatermarkParam): void; - export function destroyWatermark(): void; } diff --git a/packages/fes-preset-built-in/src/plugins/generateFiles/genType.js b/packages/fes-preset-built-in/src/plugins/generateFiles/genType.js index 375ecdbc..b6076c06 100644 --- a/packages/fes-preset-built-in/src/plugins/generateFiles/genType.js +++ b/packages/fes-preset-built-in/src/plugins/generateFiles/genType.js @@ -1,7 +1,7 @@ function importsToStr(imports) { return imports.map((imp) => { const { source } = imp; - return `import '${source}';`; + return `export * from '${source}';`; }); } diff --git a/packages/fes-preset-built-in/types.d.ts b/packages/fes-preset-built-in/types.d.ts index 94172041..e71514d1 100644 --- a/packages/fes-preset-built-in/types.d.ts +++ b/packages/fes-preset-built-in/types.d.ts @@ -19,7 +19,22 @@ interface ClientRenderOption { type RenderFunc = () => Promise -declare module "@fesjs/fes" { + +export function getRouter(): Router; +export function getHistory(): RouterHistory; +export function destroyRouter(): void; + +declare module '@fesjs/fes' { + interface PluginRuntimeConfig { + beforeRender?: (option: BeforeRenderConfig) => BeforeRenderConfig; + patchRoutes?: ({ routes }: { routes: RouteRecordRaw[] }) => void; + modifyClientRenderOpts?: (option: ClientRenderOption) => ClientRenderOption; + rootContainer?: (component: DefineComponent, option: { routes: RouteRecordRaw[], plugin: Plugin }) => Component; + onAppCreated?: ({ app, routes }: { app: App, routes: RouteRecordRaw[] }) => void; + render?: (defaultRender: RenderFunc) => RenderFunc; + onRouterCreated?: ({ router }: { router: Router }) => void; + } + interface PluginBuildConfig { alias?: Record, autoprefixer?: { @@ -81,17 +96,5 @@ declare module "@fesjs/fes" { terserOptions?: object; title?: string; } - interface PluginRuntimeConfig { - beforeRender?: (option: BeforeRenderConfig) => BeforeRenderConfig; - patchRoutes?: ({ routes }: { routes: RouteRecordRaw[] }) => void; - modifyClientRenderOpts?: (option: ClientRenderOption) => ClientRenderOption; - rootContainer?: (component: DefineComponent, option: { routes: RouteRecordRaw[], plugin: Plugin }) => Component; - onAppCreated?: ({ app, routes }: { app: App, routes: RouteRecordRaw[] }) => void; - render?: (defaultRender: RenderFunc) => RenderFunc; - onRouterCreated?: ({ router }: { router: Router }) => void; - } - - export function getRouter(): Router; - export function getHistory(): RouterHistory; - export function destroyRouter(): void; + } diff --git a/packages/fes-template-h5/tsconfig.json b/packages/fes-template-h5/tsconfig.json index f8e8cc7a..64029f64 100644 --- a/packages/fes-template-h5/tsconfig.json +++ b/packages/fes-template-h5/tsconfig.json @@ -3,10 +3,7 @@ "outDir": "build/dist", "module": "esnext", "target": "esnext", - "lib": [ - "esnext", - "dom" - ], + "lib": ["esnext", "dom"], "sourceMap": true, "baseUrl": ".", "jsx": "preserve", @@ -17,31 +14,18 @@ "suppressImplicitAnyIndexErrors": true, "noUnusedLocals": true, "allowJs": true, + "skipLibCheck": true, "experimentalDecorators": true, "strict": true, "paths": { - "@/*": [ - "./src/*" - ], - "@@/*": [ - "./src/.fes/*" - ] + "@/*": ["./src/*"], + "@@/*": ["./src/.fes/*"] } }, "include": [ - "*.js", - ".fes.js", "src/**/*", - "typings/**/*", - "config/**/*", - "src/.fes/configType.d.ts" + ".fes.js", + ".fes.*.js" ], - "exclude": [ - "build", - "dist", - "scripts", - "webpack", - "jest", - "node_modules" - ] -} \ No newline at end of file + "exclude": ["node_modules", "build", "dist", "scripts", "src/.fes/*", "webpack", "jest"] +} diff --git a/packages/fes-template-vite/.fes.js b/packages/fes-template-vite/.fes.js index e1c741b0..5505e322 100644 --- a/packages/fes-template-vite/.fes.js +++ b/packages/fes-template-vite/.fes.js @@ -1,6 +1,6 @@ -// .fes.js 只负责管理编译时配置,只能使用plain Object +import { defineBuildConfig } from "@fesjs/fes"; -export default { +export default defineBuildConfig({ // exportStatic: {}, define: { __DEV__: false @@ -84,5 +84,5 @@ export default { dynamicImport: true, monacoEditor: { languages: ['javascript', 'typescript', 'html', 'json'] - } -}; + }, +}); diff --git a/packages/fes-template-vite/.fes.local.js b/packages/fes-template-vite/.fes.local.js index 62fab3c1..c79e932e 100644 --- a/packages/fes-template-vite/.fes.local.js +++ b/packages/fes-template-vite/.fes.local.js @@ -1,3 +1,5 @@ +import { defineBuildConfig } from "@fesjs/fes"; + export default { // define: { // __DEV__: true diff --git a/packages/fes-template-vite/.fes.prod.js b/packages/fes-template-vite/.fes.prod.js index 153393d8..7cf1c120 100644 --- a/packages/fes-template-vite/.fes.prod.js +++ b/packages/fes-template-vite/.fes.prod.js @@ -1,5 +1,4 @@ -// .fes.js 只负责管理编译时配置,只能使用plain Object - +import { defineBuildConfig } from "@fesjs/fes"; export default { publicPath: 'https://gw.alipayobjects.com/' diff --git a/packages/fes-template-vite/tsconfig.json b/packages/fes-template-vite/tsconfig.json index b7fce5b7..64029f64 100644 --- a/packages/fes-template-vite/tsconfig.json +++ b/packages/fes-template-vite/tsconfig.json @@ -24,15 +24,8 @@ }, "include": [ "src/**/*", - "tests/**/*", - "test/**/*", - "__test__/**/*", - "typings/**/*", - "config/**/*", - ".eslintrc.js", - ".stylelintrc.js", - ".prettierrc.js", - "src/.fes/configType.d.ts" + ".fes.js", + ".fes.*.js" ], "exclude": ["node_modules", "build", "dist", "scripts", "src/.fes/*", "webpack", "jest"] } diff --git a/packages/fes-template/tsconfig.json b/packages/fes-template/tsconfig.json index f8e8cc7a..64029f64 100644 --- a/packages/fes-template/tsconfig.json +++ b/packages/fes-template/tsconfig.json @@ -3,10 +3,7 @@ "outDir": "build/dist", "module": "esnext", "target": "esnext", - "lib": [ - "esnext", - "dom" - ], + "lib": ["esnext", "dom"], "sourceMap": true, "baseUrl": ".", "jsx": "preserve", @@ -17,31 +14,18 @@ "suppressImplicitAnyIndexErrors": true, "noUnusedLocals": true, "allowJs": true, + "skipLibCheck": true, "experimentalDecorators": true, "strict": true, "paths": { - "@/*": [ - "./src/*" - ], - "@@/*": [ - "./src/.fes/*" - ] + "@/*": ["./src/*"], + "@@/*": ["./src/.fes/*"] } }, "include": [ - "*.js", - ".fes.js", "src/**/*", - "typings/**/*", - "config/**/*", - "src/.fes/configType.d.ts" + ".fes.js", + ".fes.*.js" ], - "exclude": [ - "build", - "dist", - "scripts", - "webpack", - "jest", - "node_modules" - ] -} \ No newline at end of file + "exclude": ["node_modules", "build", "dist", "scripts", "src/.fes/*", "webpack", "jest"] +} diff --git a/packages/fes/package.json b/packages/fes/package.json index 9eee2134..6c83420e 100644 --- a/packages/fes/package.json +++ b/packages/fes/package.json @@ -50,4 +50,4 @@ "node": "^10.12.0 || ^12.0.0 || >= 14.0.0" }, "types": "types.d.ts" -} +} \ No newline at end of file diff --git a/packages/fes/types.d.ts b/packages/fes/types.d.ts index 1a657bb1..de0fe6e3 100644 --- a/packages/fes/types.d.ts +++ b/packages/fes/types.d.ts @@ -1,5 +1,4 @@ -// @ts-ignore -import '@@/configType'; +export * from '@@/configType' export * from '@fesjs/runtime';