diff --git a/.changeset/forty-doors-hear.md b/.changeset/forty-doors-hear.md new file mode 100644 index 000000000..8b9f17c83 --- /dev/null +++ b/.changeset/forty-doors-hear.md @@ -0,0 +1,18 @@ +--- +'@ice/plugin-css-assets-local': patch +'@ice/plugin-moment-locales': patch +'@ice/plugin-rax-compat': patch +'@ice/plugin-icestark': patch +'@ice/plugin-jsx-plus': patch +'@ice/plugin-request': patch +'@ice/webpack-config': patch +'@ice/plugin-fusion': patch +'@ice/plugin-store': patch +'@ice/plugin-antd': patch +'@ice/plugin-auth': patch +'@ice/plugin-pha': patch +'@ice/runtime': patch +'@ice/app': patch +--- + +fix: support types definition without specify esm folder diff --git a/examples/csr-project/src/app.tsx b/examples/csr-project/src/app.tsx index 7d475cf8d..ca6376792 100644 --- a/examples/csr-project/src/app.tsx +++ b/examples/csr-project/src/app.tsx @@ -1,5 +1,5 @@ import { defineAppConfig } from 'ice'; -import { defineAuthConfig } from '@ice/plugin-auth/esm/types'; +import { defineAuthConfig } from '@ice/plugin-auth/types'; console.log('__LOG__'); console.warn('__WARN__'); diff --git a/examples/icestark-child/src/app.tsx b/examples/icestark-child/src/app.tsx index 4b52a1bc4..a5ce60b9f 100644 --- a/examples/icestark-child/src/app.tsx +++ b/examples/icestark-child/src/app.tsx @@ -1,5 +1,5 @@ import { defineAppConfig } from 'ice'; -import { defineChildConfig } from '@ice/plugin-icestark/esm/types'; +import { defineChildConfig } from '@ice/plugin-icestark/types'; export const icestark = defineChildConfig(() => { return { @@ -29,4 +29,4 @@ export default defineAppConfig(() => ({ router: { basename, }, -})); \ No newline at end of file +})); diff --git a/examples/icestark-layout/src/app.tsx b/examples/icestark-layout/src/app.tsx index 37fecf18f..d35684425 100644 --- a/examples/icestark-layout/src/app.tsx +++ b/examples/icestark-layout/src/app.tsx @@ -1,5 +1,5 @@ import { defineAppConfig } from 'ice'; -import { defineFrameworkConfig } from '@ice/plugin-icestark/esm/types'; +import { defineFrameworkConfig } from '@ice/plugin-icestark/types'; import FrameworkLayout from '@/components/FrameworkLayout'; export const icestark = defineFrameworkConfig(() => ({ @@ -21,4 +21,4 @@ export default defineAppConfig(() => ({ app: { rootId: 'app', }, -})); \ No newline at end of file +})); diff --git a/examples/with-antd-mobile/src/store.tsx b/examples/with-antd-mobile/src/store.tsx index de7812fdf..c2a334f6b 100644 --- a/examples/with-antd-mobile/src/store.tsx +++ b/examples/with-antd-mobile/src/store.tsx @@ -1,4 +1,4 @@ -import type { ComponentWithChildren } from '@ice/runtime/esm/types'; +import type { ComponentWithChildren } from '@ice/runtime/types'; import { useState } from 'react'; import constate from 'constate'; @@ -18,4 +18,4 @@ export const StoreProvider: ComponentWithChildren = ({ children }) => { export { useCounterContext, -}; \ No newline at end of file +}; diff --git a/examples/with-auth/src/app.tsx b/examples/with-auth/src/app.tsx index c52b1e097..0df3324bb 100644 --- a/examples/with-auth/src/app.tsx +++ b/examples/with-auth/src/app.tsx @@ -1,5 +1,5 @@ import { defineAppConfig, defineDataLoader, Link } from 'ice'; -import { defineAuthConfig } from '@ice/plugin-auth/esm/types'; +import { defineAuthConfig } from '@ice/plugin-auth/types'; export default defineAppConfig(() => ({})); diff --git a/examples/with-pha/src/app.tsx b/examples/with-pha/src/app.tsx index a5ed7a870..ddc79fcbf 100644 --- a/examples/with-pha/src/app.tsx +++ b/examples/with-pha/src/app.tsx @@ -1,4 +1,4 @@ -import type { Manifest } from '@ice/plugin-pha/esm/types'; +import type { Manifest } from '@ice/plugin-pha/types'; export const phaManifest: Manifest = { title: 'test', diff --git a/examples/with-request/src/app.tsx b/examples/with-request/src/app.tsx index 1ae162ee1..c95d85f2b 100644 --- a/examples/with-request/src/app.tsx +++ b/examples/with-request/src/app.tsx @@ -1,5 +1,5 @@ import { request as requestAPI, defineDataLoader } from 'ice'; -import { defineRequestConfig } from '@ice/plugin-request/esm/types'; +import { defineRequestConfig } from '@ice/plugin-request/types'; export const dataLader = defineDataLoader(async () => { try { diff --git a/examples/with-store/src/app.tsx b/examples/with-store/src/app.tsx index 09ff4ef4a..87805d7ca 100644 --- a/examples/with-store/src/app.tsx +++ b/examples/with-store/src/app.tsx @@ -1,5 +1,5 @@ import { defineAppConfig, defineDataLoader } from 'ice'; -import { defineStoreConfig } from '@ice/plugin-store/esm/types'; +import { defineStoreConfig } from '@ice/plugin-store/types'; export const storeConfig = defineStoreConfig(async (appData) => { return { diff --git a/packages/ice/package.json b/packages/ice/package.json index 0c196c7d6..10dea01d1 100644 --- a/packages/ice/package.json +++ b/packages/ice/package.json @@ -17,7 +17,7 @@ "!esm/**/*.map", "templates", "openChrome.applescript", - "types.d.ts" + "*.d.ts" ], "engines": { "node": ">=14.19.0", diff --git a/packages/ice/src/commands/build.ts b/packages/ice/src/commands/build.ts index 168ada1e6..e9a986d33 100644 --- a/packages/ice/src/commands/build.ts +++ b/packages/ice/src/commands/build.ts @@ -4,9 +4,9 @@ import { getWebpackConfig } from '@ice/webpack-config'; import type { Context, TaskConfig } from 'build-scripts'; import webpack from '@ice/bundles/compiled/webpack/index.js'; import type { StatsError, Stats } from 'webpack'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import type ora from '@ice/bundles/compiled/ora/index.js'; -import type { AppConfig } from '@ice/runtime/esm/types'; +import type { AppConfig } from '@ice/runtime/types'; import type { RenderMode } from '@ice/runtime'; import type { ServerCompiler, GetAppConfig, GetRoutesConfig, ExtendsPluginAPI, GetDataloaderConfig } from '../types/plugin.js'; import webpackCompiler from '../service/webpackCompiler.js'; diff --git a/packages/ice/src/commands/start.ts b/packages/ice/src/commands/start.ts index 448c0eba2..45b54871f 100644 --- a/packages/ice/src/commands/start.ts +++ b/packages/ice/src/commands/start.ts @@ -3,7 +3,7 @@ import detectPort from 'detect-port'; import type { Configuration as DevServerConfiguration } from 'webpack-dev-server'; import type { Context, TaskConfig } from 'build-scripts'; import type { StatsError, Compiler, Configuration } from 'webpack'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import type { AppConfig, RenderMode } from '@ice/runtime'; import type ora from '@ice/bundles/compiled/ora/index.js'; import WebpackDevServer from '@ice/bundles/compiled/webpack-dev-server/lib/Server.js'; diff --git a/packages/ice/src/commands/test.ts b/packages/ice/src/commands/test.ts index c73b9861a..2bf84c434 100644 --- a/packages/ice/src/commands/test.ts +++ b/packages/ice/src/commands/test.ts @@ -1,5 +1,5 @@ import type { Context, TaskConfig } from 'build-scripts'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import type ora from '@ice/bundles/compiled/ora/index.js'; function test( diff --git a/packages/ice/src/config.ts b/packages/ice/src/config.ts index e0c6bf066..7ab8d3025 100644 --- a/packages/ice/src/config.ts +++ b/packages/ice/src/config.ts @@ -1,7 +1,7 @@ import { createRequire } from 'module'; import trustCert from '@ice/bundles/compiled/trusted-cert/index.js'; import fse from 'fs-extra'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import type { UserConfigContext } from 'build-scripts'; import lodash from '@ice/bundles/compiled/lodash/index.js'; import type { UserConfig } from './types/userConfig.js'; diff --git a/packages/ice/src/createService.ts b/packages/ice/src/createService.ts index 9981c5af4..90a9d8721 100644 --- a/packages/ice/src/createService.ts +++ b/packages/ice/src/createService.ts @@ -3,8 +3,8 @@ import { fileURLToPath } from 'url'; import { createRequire } from 'module'; import { Context } from 'build-scripts'; import type { CommandArgs, CommandName } from 'build-scripts'; -import type { Config } from '@ice/webpack-config/esm/types'; -import type { AppConfig } from '@ice/runtime/esm/types'; +import type { Config } from '@ice/webpack-config/types'; +import type { AppConfig } from '@ice/runtime/types'; import webpack from '@ice/bundles/compiled/webpack/index.js'; import fg from 'fast-glob'; import type { DeclarationData, PluginData, ExtendsPluginAPI, TargetDeclarationData } from './types'; diff --git a/packages/ice/src/esbuild/assets.ts b/packages/ice/src/esbuild/assets.ts index 1d35514ce..1290eb8f2 100644 --- a/packages/ice/src/esbuild/assets.ts +++ b/packages/ice/src/esbuild/assets.ts @@ -2,7 +2,7 @@ import * as path from 'path'; import * as mrmime from 'mrmime'; import fs from 'fs-extra'; import type { PluginBuild } from 'esbuild'; -import type { AssetsManifest } from '@ice/runtime/esm/types'; +import type { AssetsManifest } from '@ice/runtime/types'; export const ASSET_TYPES = [ // images @@ -91,4 +91,4 @@ const createAssetsPlugin = (compilationInfo: CompilationInfo | (() => Compilatio }, }); -export default createAssetsPlugin; \ No newline at end of file +export default createAssetsPlugin; diff --git a/packages/ice/src/getWatchEvents.ts b/packages/ice/src/getWatchEvents.ts index e62f627ff..a5b3e3a4d 100644 --- a/packages/ice/src/getWatchEvents.ts +++ b/packages/ice/src/getWatchEvents.ts @@ -1,6 +1,6 @@ import * as path from 'path'; import type { Context } from 'build-scripts'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import type { WatchEvent } from './types/plugin.js'; import { generateRoutesInfo, getRoutesDefination } from './routes.js'; import type Generator from './service/runtimeGenerator'; diff --git a/packages/ice/src/middlewares/ssr/renderMiddleware.ts b/packages/ice/src/middlewares/ssr/renderMiddleware.ts index 4557d7d83..f8b057d70 100644 --- a/packages/ice/src/middlewares/ssr/renderMiddleware.ts +++ b/packages/ice/src/middlewares/ssr/renderMiddleware.ts @@ -4,7 +4,7 @@ import type { ServerContext, RenderMode } from '@ice/runtime'; // @ts-expect-error FIXME: esm type error import matchRoutes from '@ice/runtime/matchRoutes'; import type { TaskConfig } from 'build-scripts'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import type { ExtendsPluginAPI } from '../../types/plugin.js'; import getRouterBasename from '../../utils/getRouterBasename.js'; import dynamicImport from '../../utils/dynamicImport.js'; diff --git a/packages/ice/src/middlewares/ssr/renderOnDemand.ts b/packages/ice/src/middlewares/ssr/renderOnDemand.ts index dcf444484..90dfb7ea2 100644 --- a/packages/ice/src/middlewares/ssr/renderOnDemand.ts +++ b/packages/ice/src/middlewares/ssr/renderOnDemand.ts @@ -3,7 +3,7 @@ import type { ServerContext, RenderMode } from '@ice/runtime'; // @ts-expect-error FIXME: esm type error import matchRoutes from '@ice/runtime/matchRoutes'; import type { TaskConfig } from 'build-scripts'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import getRouterBasename from '../../utils/getRouterBasename.js'; import warnOnHashRouterEnabled from '../../utils/warnOnHashRouterEnabled.js'; import type { UserConfig } from '../../types/userConfig.js'; diff --git a/packages/ice/src/plugins/web/task.ts b/packages/ice/src/plugins/web/task.ts index 320488c8f..2853c5f88 100644 --- a/packages/ice/src/plugins/web/task.ts +++ b/packages/ice/src/plugins/web/task.ts @@ -1,6 +1,6 @@ import * as path from 'path'; import { createRequire } from 'module'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import { CACHE_DIR, RUNTIME_TMP_DIR } from '../../constant.js'; import { getRoutePathsFromCache } from '../../utils/getRoutePaths.js'; diff --git a/packages/ice/src/service/ServerRunner.ts b/packages/ice/src/service/ServerRunner.ts index 798601053..4831d4fab 100644 --- a/packages/ice/src/service/ServerRunner.ts +++ b/packages/ice/src/service/ServerRunner.ts @@ -5,7 +5,7 @@ import { getCompilerPlugins, getCSSModuleLocalIdent } from '@ice/webpack-config' import moduleLexer from '@ice/bundles/compiled/es-module-lexer/index.js'; import MagicString from '@ice/bundles/compiled/magic-string/index.js'; import type { TaskConfig } from 'build-scripts'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import type { PluginBuild, OnResolveOptions, Plugin, OnLoadResult, OnResolveResult } from 'esbuild'; import emptyCSSPlugin from '../esbuild/emptyCSS.js'; import ignorePlugin from '../esbuild/ignore.js'; diff --git a/packages/ice/src/service/preBundleDeps.ts b/packages/ice/src/service/preBundleDeps.ts index 077a7c6ae..253d64da9 100644 --- a/packages/ice/src/service/preBundleDeps.ts +++ b/packages/ice/src/service/preBundleDeps.ts @@ -5,7 +5,7 @@ import { esbuild } from '@ice/bundles'; import type { Plugin, BuildOptions } from 'esbuild'; import { resolve as resolveExports, legacy as resolveLegacy } from 'resolve.exports'; import moduleLexer from '@ice/bundles/compiled/es-module-lexer/index.js'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import type { TaskConfig } from 'build-scripts'; import { getCSSModuleLocalIdent } from '@ice/webpack-config'; import flattenId from '../utils/flattenId.js'; diff --git a/packages/ice/src/service/runtimeGenerator.ts b/packages/ice/src/service/runtimeGenerator.ts index 50d69ba5d..c82941c96 100644 --- a/packages/ice/src/service/runtimeGenerator.ts +++ b/packages/ice/src/service/runtimeGenerator.ts @@ -90,10 +90,11 @@ export function generateDeclaration(exportList: Array { if (alias && alias[specifierStr]) { exportDeclarations.push(`${alias[specifierStr]}: ${specifierStr}${symbol}`); + exportNames.push(alias[specifierStr]); } else { exportDeclarations.push(`${specifierStr}${symbol}`); + exportNames.push(specifierStr); } - exportNames.push(specifierStr); }); } }); diff --git a/packages/ice/src/service/serverCompiler.ts b/packages/ice/src/service/serverCompiler.ts index 8c22b6a6a..8c6cbe395 100644 --- a/packages/ice/src/service/serverCompiler.ts +++ b/packages/ice/src/service/serverCompiler.ts @@ -2,7 +2,7 @@ import * as path from 'path'; import { esbuild } from '@ice/bundles'; import fse from 'fs-extra'; import fg from 'fast-glob'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import lodash from '@ice/bundles/compiled/lodash/index.js'; import type { TaskConfig } from 'build-scripts'; import { getCompilerPlugins, getCSSModuleLocalIdent } from '@ice/webpack-config'; diff --git a/packages/ice/src/service/webpackCompiler.ts b/packages/ice/src/service/webpackCompiler.ts index 8cb149634..5dde9176f 100644 --- a/packages/ice/src/service/webpackCompiler.ts +++ b/packages/ice/src/service/webpackCompiler.ts @@ -2,7 +2,7 @@ import webpackBundler from '@ice/bundles/compiled/webpack/index.js'; import type ora from '@ice/bundles/compiled/ora/index.js'; import lodash from '@ice/bundles/compiled/lodash/index.js'; import type { TaskConfig, Context } from 'build-scripts'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import type webpack from 'webpack'; import type { Urls, ServerCompiler, GetAppConfig, GetRoutesConfig, ExtendsPluginAPI, GetDataloaderConfig } from '../types/plugin.js'; import formatWebpackMessages from '../utils/formatWebpackMessages.js'; diff --git a/packages/ice/src/test/defineJestConfig.ts b/packages/ice/src/test/defineJestConfig.ts index de7efcb7e..358db5502 100644 --- a/packages/ice/src/test/defineJestConfig.ts +++ b/packages/ice/src/test/defineJestConfig.ts @@ -1,7 +1,7 @@ import * as path from 'path'; import type { Config as JestConfig } from 'jest'; import fse from 'fs-extra'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import lodash from '@ice/bundles/compiled/lodash/index.js'; import getTaskConfig from './getTaskConfig.js'; diff --git a/packages/ice/src/types/index.ts b/packages/ice/src/types/index.ts index c329bdc2f..b24b6ed76 100644 --- a/packages/ice/src/types/index.ts +++ b/packages/ice/src/types/index.ts @@ -2,4 +2,4 @@ export * from './generator.js'; export * from './plugin.js'; export * from './userConfig.js'; // Export type webpack for same instance of webpack. -export type { Config, webpack } from '@ice/webpack-config/esm/types'; \ No newline at end of file +export type { Config, webpack } from '@ice/webpack-config/types'; diff --git a/packages/ice/src/types/plugin.ts b/packages/ice/src/types/plugin.ts index 2606bf96f..dac0032dc 100644 --- a/packages/ice/src/types/plugin.ts +++ b/packages/ice/src/types/plugin.ts @@ -3,8 +3,8 @@ import type { _Plugin, CommandArgs, TaskConfig } from 'build-scripts'; import type { Configuration, Stats, WebpackOptionsNormalized } from '@ice/bundles/compiled/webpack'; import type { esbuild } from '@ice/bundles'; import type { NestedRouteManifest } from '@ice/route-manifest'; -import type { Config } from '@ice/webpack-config/esm/types'; -import type { AppConfig, AssetsManifest } from '@ice/runtime/esm/types'; +import type { Config } from '@ice/webpack-config/types'; +import type { AppConfig, AssetsManifest } from '@ice/runtime/types'; import type ServerCompileTask from '../utils/ServerCompileTask.js'; import type { DeclarationData, TargetDeclarationData, AddRenderFile, AddTemplateFiles, ModifyRenderData, AddDataLoaderImport, Render } from './generator.js'; diff --git a/packages/ice/src/types/userConfig.ts b/packages/ice/src/types/userConfig.ts index 4740c1e86..53ed82b66 100644 --- a/packages/ice/src/types/userConfig.ts +++ b/packages/ice/src/types/userConfig.ts @@ -2,7 +2,7 @@ import type { DefineRouteFunction, RouteItem } from '@ice/route-manifest'; import type { PluginList } from 'build-scripts'; import type { UnpluginOptions } from '@ice/bundles/compiled/unplugin/index.js'; import type { ProcessOptions } from '@ice/bundles'; -import type { Config, ModifyWebpackConfig, MinimizerOptions } from '@ice/webpack-config/esm/types'; +import type { Config, ModifyWebpackConfig, MinimizerOptions } from '@ice/webpack-config/types'; import type { OverwritePluginAPI } from './plugin'; interface SyntaxFeatures { diff --git a/packages/ice/src/utils/getRouterBasename.ts b/packages/ice/src/utils/getRouterBasename.ts index 6d3024d56..c6feb7692 100644 --- a/packages/ice/src/utils/getRouterBasename.ts +++ b/packages/ice/src/utils/getRouterBasename.ts @@ -1,5 +1,5 @@ import type { AppConfig } from '@ice/runtime'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import type { TaskConfig } from 'build-scripts'; const getRouterBasename = (taskConfig: TaskConfig, appConfig: AppConfig) => { diff --git a/packages/ice/src/utils/mergeTaskConfig.ts b/packages/ice/src/utils/mergeTaskConfig.ts index e7ce124ec..b7782a704 100644 --- a/packages/ice/src/utils/mergeTaskConfig.ts +++ b/packages/ice/src/utils/mergeTaskConfig.ts @@ -1,5 +1,5 @@ import type { TaskConfig } from 'build-scripts'; -import type { Config } from '@ice/webpack-config/esm/types'; +import type { Config } from '@ice/webpack-config/types'; import lodash from '@ice/bundles/compiled/lodash/index.js'; const { mergeWith } = lodash; @@ -24,4 +24,4 @@ function mergeTaskConfig( }); } -export default mergeTaskConfig; \ No newline at end of file +export default mergeTaskConfig; diff --git a/packages/ice/src/utils/runtimeEnv.ts b/packages/ice/src/utils/runtimeEnv.ts index 972e85ea4..74f1eb337 100644 --- a/packages/ice/src/utils/runtimeEnv.ts +++ b/packages/ice/src/utils/runtimeEnv.ts @@ -3,7 +3,7 @@ import * as fs from 'fs'; import * as dotenv from 'dotenv'; import { expand as dotenvExpand } from 'dotenv-expand'; import type { CommandArgs } from 'build-scripts'; -import type { AppConfig } from '@ice/runtime/esm/types'; +import type { AppConfig } from '@ice/runtime/types'; export interface Envs { [key: string]: string; diff --git a/packages/ice/templates/core/types.ts.ejs b/packages/ice/templates/core/types.ts.ejs index f35bde06e..33a0cc6c6 100644 --- a/packages/ice/templates/core/types.ts.ejs +++ b/packages/ice/templates/core/types.ts.ejs @@ -1,5 +1,5 @@ -import type { AppConfig, RouteConfig as DefaultRouteConfig } from '@ice/runtime'; <%- routeConfigTypes.imports -%> +import type { AppConfig, RouteConfig as DefaultRouteConfig } from '@ice/runtime'; <% if (routeConfigTypes.imports) {-%> type ExtendsRouteConfig = <% if (routeConfigTypes.imports) { %><%- routeConfigTypes.exportNames.join(' & ') %><% } %>; @@ -15,4 +15,5 @@ type PageConfigDefinition = (context: PageConfigDefinitionContext) => PageConfig export type { AppConfig, PageConfig, + PageConfigDefinition, }; diff --git a/packages/ice/types.d.ts b/packages/ice/types.d.ts index 19f77d362..ae71c88fd 100644 --- a/packages/ice/types.d.ts +++ b/packages/ice/types.d.ts @@ -1,162 +1,166 @@ -// CSS modules -declare module '*.module.less' { - const classes: { [key: string]: string }; - export default classes; -} +declare global { + // CSS modules + declare module '*.module.less' { + const classes: { [key: string]: string }; + export default classes; + } -declare module '*.module.css' { - const classes: { [key: string]: string }; - export default classes; -} + declare module '*.module.css' { + const classes: { [key: string]: string }; + export default classes; + } -declare module '*.module.scss' { - const classes: { [key: string]: string }; - export default classes; -} + declare module '*.module.scss' { + const classes: { [key: string]: string }; + export default classes; + } -// images -declare module '*.jpg' { - const src: string; - export default src; -} -declare module '*.jpeg' { - const src: string; - export default src; -} -declare module '*.png' { - const src: string; - export default src; -} -declare module '*.gif' { - const src: string; - export default src; -} -declare module '*.svg' { - const src: string; - export default src; -} -declare module '*.ico' { - const src: string; - export default src; -} -declare module '*.webp' { - const src: string; - export default src; -} -declare module '*.avif' { - const src: string; - export default src; -} + // images + declare module '*.jpg' { + const src: string; + export default src; + } + declare module '*.jpeg' { + const src: string; + export default src; + } + declare module '*.png' { + const src: string; + export default src; + } + declare module '*.gif' { + const src: string; + export default src; + } + declare module '*.svg' { + const src: string; + export default src; + } + declare module '*.ico' { + const src: string; + export default src; + } + declare module '*.webp' { + const src: string; + export default src; + } + declare module '*.avif' { + const src: string; + export default src; + } -// media -declare module '*.mp4' { - const src: string; - export default src; -} -declare module '*.webm' { - const src: string; - export default src; -} -declare module '*.ogg' { - const src: string; - export default src; -} -declare module '*.mp3' { - const src: string; - export default src; -} -declare module '*.wav' { - const src: string; - export default src; -} -declare module '*.flac' { - const src: string; - export default src; -} -declare module '*.aac' { - const src: string; - export default src; -} + // media + declare module '*.mp4' { + const src: string; + export default src; + } + declare module '*.webm' { + const src: string; + export default src; + } + declare module '*.ogg' { + const src: string; + export default src; + } + declare module '*.mp3' { + const src: string; + export default src; + } + declare module '*.wav' { + const src: string; + export default src; + } + declare module '*.flac' { + const src: string; + export default src; + } + declare module '*.aac' { + const src: string; + export default src; + } -// fonts -declare module '*.woff' { - const src: string; - export default src; -} -declare module '*.woff2' { - const src: string; - export default src; -} -declare module '*.eot' { - const src: string; - export default src; -} -declare module '*.ttf' { - const src: string; - export default src; -} -declare module '*.otf' { - const src: string; - export default src; -} + // fonts + declare module '*.woff' { + const src: string; + export default src; + } + declare module '*.woff2' { + const src: string; + export default src; + } + declare module '*.eot' { + const src: string; + export default src; + } + declare module '*.ttf' { + const src: string; + export default src; + } + declare module '*.otf' { + const src: string; + export default src; + } -// web worker -declare module '*?worker' { - const workerConstructor: { - new(): Worker; - }; - export default workerConstructor; -} -declare module '*?worker&inline' { - const workerConstructor: { - new(): Worker; - }; - export default workerConstructor; -} -declare module '*?sharedworker' { - const sharedWorkerConstructor: { - new(): SharedWorker; - }; - export default sharedWorkerConstructor; -} + // web worker + declare module '*?worker' { + const workerConstructor: { + new(): Worker; + }; + export default workerConstructor; + } + declare module '*?worker&inline' { + const workerConstructor: { + new(): Worker; + }; + export default workerConstructor; + } + declare module '*?sharedworker' { + const sharedWorkerConstructor: { + new(): SharedWorker; + }; + export default sharedWorkerConstructor; + } -// other -declare module '*.pdf' { - const src: string; - export default src; -} -declare module '*.txt' { - const src: string; - export default src; -} -declare module '*?url' { - const src: string; - export default src; -} -declare module '*?raw' { - const src: string; - export default src; -} + // other + declare module '*.pdf' { + const src: string; + export default src; + } + declare module '*.txt' { + const src: string; + export default src; + } + declare module '*?url' { + const src: string; + export default src; + } + declare module '*?raw' { + const src: string; + export default src; + } -declare namespace NodeJS { - export interface ProcessEnv { - ICE_CORE_NODE_ENV: 'development' | 'production'; - ICE_CORE_MODE: string; - ICE_CORE_ROUTER: 'true' | 'false'; - ICE_CORE_ERROR_BOUNDARY: 'true' | 'false'; - ICE_CORE_INITIAL_DATA: 'true' | 'false'; - ICE_CORE_DEV_PORT: number; + declare namespace NodeJS { + export interface ProcessEnv { + ICE_CORE_NODE_ENV: 'development' | 'production'; + ICE_CORE_MODE: string; + ICE_CORE_ROUTER: 'true' | 'false'; + ICE_CORE_ERROR_BOUNDARY: 'true' | 'false'; + ICE_CORE_INITIAL_DATA: 'true' | 'false'; + ICE_CORE_DEV_PORT: string; + } + } + + interface ImportMeta { + // The build target for ice.js + // Usually `web` or `node` or `weex` + target: string; + + // The renderer for ice.js + renderer: 'client' | 'server'; + + // ice.js defined env variables + env: Record; } } -interface ImportMeta { - // The build target for ice.js - // Usually `web` or `node` or `weex` - target: string; - - // The renderer for ice.js - renderer: 'client' | 'server'; - - // ice.js defined env variables - env: Record; -} +export * from './esm/types'; diff --git a/packages/ice/typings.d.ts b/packages/ice/typings.d.ts new file mode 100644 index 000000000..8554e6cd4 --- /dev/null +++ b/packages/ice/typings.d.ts @@ -0,0 +1 @@ +export * from './esm/types'; diff --git a/packages/plugin-antd/src/index.ts b/packages/plugin-antd/src/index.ts index 38f1a850f..b9a5ddf48 100644 --- a/packages/plugin-antd/src/index.ts +++ b/packages/plugin-antd/src/index.ts @@ -1,5 +1,5 @@ import { createRequire } from 'module'; -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; import styleImportPlugin from '@ice/style-import'; interface PluginOptions { @@ -72,4 +72,4 @@ const plugin: Plugin = ({ theme, dark, compact, importStyle }) => }, }); -export default plugin; \ No newline at end of file +export default plugin; diff --git a/packages/plugin-auth/package.json b/packages/plugin-auth/package.json index 7235ac199..a4c229bc9 100644 --- a/packages/plugin-auth/package.json +++ b/packages/plugin-auth/package.json @@ -35,7 +35,8 @@ "types": "./esm/index.d.ts", "files": [ "esm", - "!esm/**/*.map" + "!esm/**/*.map", + "*.d.ts" ], "devDependencies": { "@ice/app": "^3.1.1-beta.9", diff --git a/packages/plugin-auth/runtime.d.ts b/packages/plugin-auth/runtime.d.ts new file mode 100644 index 000000000..72417e24d --- /dev/null +++ b/packages/plugin-auth/runtime.d.ts @@ -0,0 +1 @@ +export * from './esm/runtime'; diff --git a/packages/plugin-auth/src/index.ts b/packages/plugin-auth/src/index.ts index 08bc1751a..33b48609a 100644 --- a/packages/plugin-auth/src/index.ts +++ b/packages/plugin-auth/src/index.ts @@ -1,4 +1,4 @@ -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; const PLUGIN_NAME = '@ice/plugin-auth'; @@ -8,16 +8,16 @@ const plugin: Plugin = () => ({ // Register API: `import { useAuth, withAuth } from 'ice';` generator.addExport({ specifier: ['withAuth', 'useAuth'], - source: '@ice/plugin-auth/esm/runtime', + source: '@ice/plugin-auth/runtime', }); generator.addRouteTypes({ specifier: ['ConfigAuth'], type: true, - source: '@ice/plugin-auth/esm/types', + source: '@ice/plugin-auth/types', }); }, - runtime: `${PLUGIN_NAME}/esm/runtime`, + runtime: `${PLUGIN_NAME}/runtime`, }); export default plugin; diff --git a/packages/plugin-auth/src/runtime/index.tsx b/packages/plugin-auth/src/runtime/index.tsx index 70c8c85d9..cf0fda848 100644 --- a/packages/plugin-auth/src/runtime/index.tsx +++ b/packages/plugin-auth/src/runtime/index.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import type { RuntimePlugin, AppProvider, RouteWrapper } from '@ice/runtime/esm/types'; +import type { RuntimePlugin, AppProvider, RouteWrapper } from '@ice/runtime/types'; import type { AuthConfig, AuthType, Auth } from '../types.js'; import { AuthProvider, useAuth, withAuth } from './Auth.js'; import type { InjectProps } from './Auth.js'; diff --git a/packages/plugin-auth/src/types.ts b/packages/plugin-auth/src/types.ts index dd5d8727e..318a0a670 100644 --- a/packages/plugin-auth/src/types.ts +++ b/packages/plugin-auth/src/types.ts @@ -1,5 +1,5 @@ import type * as React from 'react'; -import type { RouteConfig } from '@ice/runtime/esm/types'; +import type { RouteConfig } from '@ice/runtime/types'; export interface AuthConfig { initialAuth: { diff --git a/packages/plugin-auth/types.d.ts b/packages/plugin-auth/types.d.ts new file mode 100644 index 000000000..8554e6cd4 --- /dev/null +++ b/packages/plugin-auth/types.d.ts @@ -0,0 +1 @@ +export * from './esm/types'; diff --git a/packages/plugin-css-assets-local/src/index.ts b/packages/plugin-css-assets-local/src/index.ts index 4b810451d..a07247269 100644 --- a/packages/plugin-css-assets-local/src/index.ts +++ b/packages/plugin-css-assets-local/src/index.ts @@ -1,4 +1,4 @@ -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; // @ts-expect-error cjs module error import ExtractCssAssetsWebpackPlugin from 'extract-css-assets-webpack-plugin'; import consola from 'consola'; diff --git a/packages/plugin-fusion/src/index.ts b/packages/plugin-fusion/src/index.ts index 08a8432a3..ce1610274 100644 --- a/packages/plugin-fusion/src/index.ts +++ b/packages/plugin-fusion/src/index.ts @@ -1,5 +1,5 @@ import { createRequire } from 'module'; -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; import styleImportPlugin from '@ice/style-import'; interface PluginOptions { diff --git a/packages/plugin-icestark/package.json b/packages/plugin-icestark/package.json index c65a5d804..6323a2244 100644 --- a/packages/plugin-icestark/package.json +++ b/packages/plugin-icestark/package.json @@ -9,7 +9,8 @@ "type": "module", "files": [ "esm", - "!esm/**/*.map" + "!esm/**/*.map", + "*.d.ts" ], "exports": { ".": { @@ -27,6 +28,11 @@ "import": "./esm/runtime/framework.js", "default": "./esm/runtime/framework.js" }, + "./types": { + "types": "./esm/types.d.ts", + "import": "./esm/types.js", + "default": "./esm/types.js" + }, "./esm/types": { "types": "./esm/types.d.ts", "import": "./esm/types.js", @@ -54,4 +60,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} diff --git a/packages/plugin-icestark/runtime.d.ts b/packages/plugin-icestark/runtime.d.ts new file mode 100644 index 000000000..c490c5c81 --- /dev/null +++ b/packages/plugin-icestark/runtime.d.ts @@ -0,0 +1,2 @@ +export * from './esm/runtime/child'; +export * from './esm/runtime/framework'; diff --git a/packages/plugin-icestark/src/index.ts b/packages/plugin-icestark/src/index.ts index 5a270c651..e8c14cf32 100644 --- a/packages/plugin-icestark/src/index.ts +++ b/packages/plugin-icestark/src/index.ts @@ -1,4 +1,4 @@ -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; interface PluginOptions { type: 'child' | 'framework'; diff --git a/packages/plugin-icestark/src/runtime/child.tsx b/packages/plugin-icestark/src/runtime/child.tsx index 94bc8d816..11dc16936 100644 --- a/packages/plugin-icestark/src/runtime/child.tsx +++ b/packages/plugin-icestark/src/runtime/child.tsx @@ -1,5 +1,5 @@ import * as ReactDOM from 'react-dom/client'; -import type { RuntimePlugin } from '@ice/runtime/esm/types'; +import type { RuntimePlugin } from '@ice/runtime/types'; import type { LifecycleOptions } from '../types'; const runtime: RuntimePlugin = ({ setRender }, runtimeOptions) => { @@ -13,4 +13,4 @@ const runtime: RuntimePlugin = ({ setRender }, runtimeOptions) } }; -export default runtime; \ No newline at end of file +export default runtime; diff --git a/packages/plugin-icestark/src/runtime/framework.tsx b/packages/plugin-icestark/src/runtime/framework.tsx index 4cc706ee8..c801e1bf6 100644 --- a/packages/plugin-icestark/src/runtime/framework.tsx +++ b/packages/plugin-icestark/src/runtime/framework.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { AppRouter, AppRoute } from '@ice/stark'; -import type { RuntimePlugin, AppRouterProps } from '@ice/runtime/esm/types'; +import type { RuntimePlugin, AppRouterProps } from '@ice/runtime/types'; import type { RouteInfo, AppConfig } from '../types'; const { useState, useEffect } = React; @@ -79,4 +79,4 @@ const runtime: RuntimePlugin = ({ getAppRouter, setAppRouter, appContext }) => { } }; -export default runtime; \ No newline at end of file +export default runtime; diff --git a/packages/plugin-icestark/types.d.ts b/packages/plugin-icestark/types.d.ts new file mode 100644 index 000000000..8554e6cd4 --- /dev/null +++ b/packages/plugin-icestark/types.d.ts @@ -0,0 +1 @@ +export * from './esm/types'; diff --git a/packages/plugin-jsx-plus/src/index.ts b/packages/plugin-jsx-plus/src/index.ts index 7406a93fc..735e7e370 100644 --- a/packages/plugin-jsx-plus/src/index.ts +++ b/packages/plugin-jsx-plus/src/index.ts @@ -1,6 +1,6 @@ import path from 'path'; import { createRequire } from 'module'; -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; import { transformSync } from '@babel/core'; const require = createRequire(import.meta.url); diff --git a/packages/plugin-moment-locales/src/index.ts b/packages/plugin-moment-locales/src/index.ts index 4625a6de3..e3cb1bdd1 100644 --- a/packages/plugin-moment-locales/src/index.ts +++ b/packages/plugin-moment-locales/src/index.ts @@ -1,4 +1,4 @@ -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; interface PluginOptions { locales: string | string[]; diff --git a/packages/plugin-pha/package.json b/packages/plugin-pha/package.json index 994e129b8..0649ba90d 100644 --- a/packages/plugin-pha/package.json +++ b/packages/plugin-pha/package.json @@ -9,7 +9,8 @@ "files": [ "esm", "!esm/**/*.map", - "template" + "template", + "*.d.ts" ], "scripts": { "watch": "tsc -w", diff --git a/packages/plugin-pha/runtime.d.ts b/packages/plugin-pha/runtime.d.ts new file mode 100644 index 000000000..72417e24d --- /dev/null +++ b/packages/plugin-pha/runtime.d.ts @@ -0,0 +1 @@ +export * from './esm/runtime'; diff --git a/packages/plugin-pha/src/constants.ts b/packages/plugin-pha/src/constants.ts index ad9b5b5b8..a6a2c17a8 100644 --- a/packages/plugin-pha/src/constants.ts +++ b/packages/plugin-pha/src/constants.ts @@ -1,4 +1,4 @@ -import type { PluginData } from '@ice/app/esm/types'; +import type { PluginData } from '@ice/app/types'; import type { Context } from 'build-scripts'; // Keys of appConfig need transform to manifest. diff --git a/packages/plugin-pha/src/generateManifest.ts b/packages/plugin-pha/src/generateManifest.ts index 505d44e08..9e131c87d 100644 --- a/packages/plugin-pha/src/generateManifest.ts +++ b/packages/plugin-pha/src/generateManifest.ts @@ -1,6 +1,6 @@ import * as path from 'path'; import * as fs from 'fs'; -import type { GetAppConfig, GetDataloaderConfig, GetRoutesConfig, ServerCompiler } from '@ice/app/esm/types'; +import type { GetAppConfig, GetDataloaderConfig, GetRoutesConfig, ServerCompiler } from '@ice/app/types'; import type { Context } from 'build-scripts'; import { parseManifest, rewriteAppWorker, getAppWorkerUrl, getMultipleManifest, type ParseOptions } from './manifestHelpers.js'; import { getCompilerConfig } from './constants.js'; diff --git a/packages/plugin-pha/src/index.ts b/packages/plugin-pha/src/index.ts index 99e47b604..e278f1e72 100644 --- a/packages/plugin-pha/src/index.ts +++ b/packages/plugin-pha/src/index.ts @@ -2,7 +2,7 @@ import * as path from 'path'; import { fileURLToPath } from 'url'; import consola from 'consola'; import chalk from 'chalk'; -import type { Plugin, GetAppConfig, GetRoutesConfig, GetDataloaderConfig, ServerCompiler } from '@ice/app/esm/types'; +import type { Plugin, GetAppConfig, GetRoutesConfig, GetDataloaderConfig, ServerCompiler } from '@ice/app/types'; import generateManifest, { getAppWorkerPath } from './generateManifest.js'; import createPHAMiddleware from './phaMiddleware.js'; @@ -42,8 +42,9 @@ const plugin: Plugin = (options) => ({ generator.addRouteTypes({ specifier: ['PageConfig'], + alias: { PageConfig: 'PHAPageConfig' }, type: true, - source: '@ice/plugin-pha/esm/types', + source: '@ice/plugin-pha/types', }); // TODO: get route manifest by API. diff --git a/packages/plugin-pha/types.d.ts b/packages/plugin-pha/types.d.ts new file mode 100644 index 000000000..8554e6cd4 --- /dev/null +++ b/packages/plugin-pha/types.d.ts @@ -0,0 +1 @@ +export * from './esm/types'; diff --git a/packages/plugin-rax-compat/src/index.ts b/packages/plugin-rax-compat/src/index.ts index 624ebb7d9..d4571e4f3 100644 --- a/packages/plugin-rax-compat/src/index.ts +++ b/packages/plugin-rax-compat/src/index.ts @@ -1,6 +1,6 @@ import fs from 'fs'; import { createRequire } from 'module'; -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; import type { RuleSetRule } from 'webpack'; import consola from 'consola'; import merge from 'lodash.merge'; diff --git a/packages/plugin-request/package.json b/packages/plugin-request/package.json index b112869ec..9d4356c97 100644 --- a/packages/plugin-request/package.json +++ b/packages/plugin-request/package.json @@ -45,7 +45,8 @@ "types": "./esm/index.d.ts", "files": [ "esm", - "!esm/**/*.map" + "!esm/**/*.map", + "*.d.ts" ], "dependencies": { "ahooks": "^3.0.0", diff --git a/packages/plugin-request/runtime.d.ts b/packages/plugin-request/runtime.d.ts new file mode 100644 index 000000000..72417e24d --- /dev/null +++ b/packages/plugin-request/runtime.d.ts @@ -0,0 +1 @@ +export * from './esm/runtime'; diff --git a/packages/plugin-request/src/index.ts b/packages/plugin-request/src/index.ts index b06820f4b..bf7c80ce4 100644 --- a/packages/plugin-request/src/index.ts +++ b/packages/plugin-request/src/index.ts @@ -1,4 +1,4 @@ -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; import type { Request, Interceptors, InterceptorRequest, InterceptorResponse } from './types'; // @ts-ignore @@ -24,7 +24,7 @@ const plugin: Plugin = () => ({ type: false, }); }, - runtime: `${PLUGIN_NAME}/esm/runtime`, + runtime: `${PLUGIN_NAME}/runtime`, staticRuntime: true, keepExports: ['requestConfig'], }); diff --git a/packages/plugin-request/src/runtime.ts b/packages/plugin-request/src/runtime.ts index 2bd703aa7..5c4c8800f 100644 --- a/packages/plugin-request/src/runtime.ts +++ b/packages/plugin-request/src/runtime.ts @@ -1,4 +1,4 @@ -import type { StaticRuntimePlugin } from '@ice/runtime/esm/types'; +import type { StaticRuntimePlugin } from '@ice/runtime/types'; import { createAxiosInstance, setAxiosInstance } from './request.js'; import type { RequestConfig } from './types'; diff --git a/packages/plugin-request/types.d.ts b/packages/plugin-request/types.d.ts new file mode 100644 index 000000000..8554e6cd4 --- /dev/null +++ b/packages/plugin-request/types.d.ts @@ -0,0 +1 @@ +export * from './esm/types'; diff --git a/packages/plugin-store/package.json b/packages/plugin-store/package.json index 1116bab3f..605aeb3e6 100644 --- a/packages/plugin-store/package.json +++ b/packages/plugin-store/package.json @@ -35,7 +35,8 @@ "types": "./esm/index.d.ts", "files": [ "esm", - "!esm/**/*.map" + "!esm/**/*.map", + "*.d.ts" ], "dependencies": { "@ice/store": "^2.0.3", diff --git a/packages/plugin-store/runtime.d.ts b/packages/plugin-store/runtime.d.ts new file mode 100644 index 000000000..72417e24d --- /dev/null +++ b/packages/plugin-store/runtime.d.ts @@ -0,0 +1 @@ +export * from './esm/runtime'; diff --git a/packages/plugin-store/src/index.ts b/packages/plugin-store/src/index.ts index e53116d93..67d899c50 100644 --- a/packages/plugin-store/src/index.ts +++ b/packages/plugin-store/src/index.ts @@ -1,5 +1,5 @@ import * as path from 'path'; -import type { Config, Plugin } from '@ice/app/esm/types'; +import type { Config, Plugin } from '@ice/app/types'; import micromatch from 'micromatch'; import fg from 'fast-glob'; import { PAGE_STORE_MODULE, PAGE_STORE_PROVIDER, PAGE_STORE_INITIAL_STATES } from './constants.js'; @@ -60,11 +60,11 @@ const plugin: Plugin = (options) => ({ // Export store api: createStore, createModel from `.ice/index.ts`. generator.addExport({ specifier: ['createStore', 'createModel'], - source: '@ice/plugin-store/esm/runtime', + source: '@ice/plugin-store/runtime', type: false, }); }, - runtime: `${PLUGIN_NAME}/esm/runtime`, + runtime: `${PLUGIN_NAME}/runtime`, }); const formatId = (id: string) => id.split(path.sep).join('/'); function exportStoreProviderPlugin({ pageDir, resetPageState }: { pageDir: string; resetPageState: boolean }): Config['transformPlugins'][0] { diff --git a/packages/plugin-store/src/runtime.tsx b/packages/plugin-store/src/runtime.tsx index ef521f99c..e37571282 100644 --- a/packages/plugin-store/src/runtime.tsx +++ b/packages/plugin-store/src/runtime.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import type { RuntimePlugin, AppProvider, RouteWrapper } from '@ice/runtime/esm/types'; +import type { RuntimePlugin, AppProvider, RouteWrapper } from '@ice/runtime/types'; import { PAGE_STORE_INITIAL_STATES, PAGE_STORE_PROVIDER } from './constants.js'; import type { StoreConfig } from './types.js'; diff --git a/packages/plugin-store/types.d.ts b/packages/plugin-store/types.d.ts new file mode 100644 index 000000000..8554e6cd4 --- /dev/null +++ b/packages/plugin-store/types.d.ts @@ -0,0 +1 @@ +export * from './esm/types'; diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 0787e0cf4..5ca2e6993 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -20,7 +20,8 @@ "files": [ "esm", "!esm/**/*.map", - "templates" + "templates", + "*.d.ts" ], "author": "ICE", "license": "MIT", diff --git a/packages/runtime/router.d.ts b/packages/runtime/router.d.ts new file mode 100644 index 000000000..89acae640 --- /dev/null +++ b/packages/runtime/router.d.ts @@ -0,0 +1 @@ +export * from './esm/router'; diff --git a/packages/runtime/types.d.ts b/packages/runtime/types.d.ts new file mode 100644 index 000000000..8554e6cd4 --- /dev/null +++ b/packages/runtime/types.d.ts @@ -0,0 +1 @@ +export * from './esm/types'; diff --git a/packages/webpack-config/package.json b/packages/webpack-config/package.json index ed861551f..9bc8f4fcb 100644 --- a/packages/webpack-config/package.json +++ b/packages/webpack-config/package.json @@ -12,7 +12,8 @@ }, "files": [ "esm", - "!esm/**/*.map" + "!esm/**/*.map", + "*.d.ts" ], "dependencies": { "@ice/bundles": "0.1.4", diff --git a/packages/webpack-config/types.d.ts b/packages/webpack-config/types.d.ts new file mode 100644 index 000000000..8554e6cd4 --- /dev/null +++ b/packages/webpack-config/types.d.ts @@ -0,0 +1 @@ +export * from './esm/types'; diff --git a/website/docs/guide/advanced/auth.md b/website/docs/guide/advanced/auth.md index 1b1730b70..cb27dcaf8 100644 --- a/website/docs/guide/advanced/auth.md +++ b/website/docs/guide/advanced/auth.md @@ -53,7 +53,7 @@ export default defineConfig(() => ({ 大多数情况下权限管理通常需要从服务端获取权限数据,然后在前端通过权限对比以此控制页面、操作等等权限行为。约定在 `src/app.ts` 中导出 `auth` 对象,该对象包含从服务端异步获取初始化的权限数据,并且约定最终返回格式为 `{ initialAuth: { [key: string]: boolean } }`。 ```ts title="src/app.ts" -import { defineAuthConfig } from '@ice/plugin-auth/esm/types'; +import { defineAuthConfig } from '@ice/plugin-auth/types'; export const authConfig = defineAuthConfig(async () => { // 模拟请求权限数据 @@ -196,7 +196,7 @@ function Foo() { 支持自定义无权限时的展示组件,默认为 `<>No Auth` ```diff title="src/app.tsx" -import { defineAuthConfig } from '@ice/plugin-auth/esm/types'; +import { defineAuthConfig } from '@ice/plugin-auth/types'; export const authConfig = defineAuthConfig(async () => { return { diff --git a/website/docs/guide/advanced/icestark.md b/website/docs/guide/advanced/icestark.md index fa1b76ba2..934f1b997 100644 --- a/website/docs/guide/advanced/icestark.md +++ b/website/docs/guide/advanced/icestark.md @@ -58,7 +58,7 @@ export default defineConfig(() => ({ 应用入口配置微应用相关信息: ```ts title="src/app.ts" -import { defineFrameworkConfig } from '@ice/plugin-icestark/esm/types'; +import { defineFrameworkConfig } from '@ice/plugin-icestark/types'; import FrameworkLayout from '@/components/FrameworkLayout'; export const icestark = defineFrameworkConfig(() => ({ @@ -98,7 +98,7 @@ export default defineConfig(() => ({ 应用入口可以配置相关生命周期执行行为(可选): ```ts title="ice.config.mts" -import { defineChildConfig } from '@ice/plugin-icestark/esm/types'; +import { defineChildConfig } from '@ice/plugin-icestark/types'; export const icestark = defineChildConfig(() => ({ mount: () => { @@ -144,7 +144,7 @@ export default function FrameworkLayout({ children }) { ```ts title="src/app.ts" -import { defineFrameworkConfig } from '@ice/plugin-icestark/esm/types'; +import { defineFrameworkConfig } from '@ice/plugin-icestark/types'; import FrameworkLayout from '@/components/FrameworkLayout'; export const icestark = defineFrameworkConfig(() => ({ diff --git a/website/docs/guide/advanced/request.md b/website/docs/guide/advanced/request.md index b11b093ea..88aa63eee 100644 --- a/website/docs/guide/advanced/request.md +++ b/website/docs/guide/advanced/request.md @@ -365,7 +365,7 @@ const { data, error, loading, request } = useRequest((id) => ({ 在实际项目中通常需要对请求进行全局统一的封装,例如配置请求的 baseURL、统一 header、拦截请求和响应等等,这时只需要在应用的的 appConfig 中进行配置即可。 ```ts title="src/app.tsx" -import { defineRequestConfig } from '@ice/plugin-request/esm/types'; +import { defineRequestConfig } from '@ice/plugin-request/types'; export const requestConfig = defineRequestConfig({ // 可选的,全局设置 request 是否返回 response 对象,默认为 false @@ -412,7 +412,7 @@ export const requestConfig = defineRequestConfig({ 在某些复杂场景的应用中,我们也可以配置多个请求,每个配置请求都是单一的实例对象。 ```ts title="src/app.tsx" -import { defineRequestConfig } from '@ice/plugin-request/esm/types'; +import { defineRequestConfig } from '@ice/plugin-request/types'; export const requestConfig = defineRequestConfig([ { @@ -492,7 +492,7 @@ const error = { 大部分情况下,前端代码里用到的后端接口写的都是相对路径如 `/api/getFoo.json`,然后访问不同环境时浏览器会根据当前域名发起对应的请求。如果域名跟实际请求的接口地址不一致,则需要通过 `request.baseURL` 来配置: ```ts title="src/app.tsx" -import { defineRequestConfig } from '@ice/plugin-request/esm/types'; +import { defineRequestConfig } from '@ice/plugin-request/types'; export const requestConfig = defineRequestConfig({ baseURL: '//service.example.com/api', @@ -513,7 +513,7 @@ BASEURL=https://example.com/api 在 `src/app.tsx` 中配置 `request.baseURL`: ```ts title="src/app.tsx" -import { defineRequestConfig } from '@ice/plugin-request/esm/types'; +import { defineRequestConfig } from '@ice/plugin-request/types'; export const requestConfig = defineRequestConfig({ baseURL: process.env.BASEURL, diff --git a/website/docs/guide/advanced/store.md b/website/docs/guide/advanced/store.md index dfd682155..638e1fb40 100644 --- a/website/docs/guide/advanced/store.md +++ b/website/docs/guide/advanced/store.md @@ -251,7 +251,7 @@ export default createModel({ 我们可以在 `src/app.ts` 中设置两个 Model 初始状态: ```ts title="src/app.ts" -import { defineStoreConfig } from '@ice/plugin-store/esm/types'; +import { defineStoreConfig } from '@ice/plugin-store/types'; export const storeConfig = defineStoreConfig(async () => { // 模拟请求后端数据 diff --git a/website/docs/guide/basic/app.md b/website/docs/guide/basic/app.md index fe3cb8d33..017b7ce00 100644 --- a/website/docs/guide/basic/app.md +++ b/website/docs/guide/basic/app.md @@ -103,7 +103,7 @@ export default defineAppConfig(() => ({ ```js import { defineAppConfig } from 'ice'; -import { defineAuthConfig } from '@ice/plugin-auth/esm/types'; +import { defineAuthConfig } from '@ice/plugin-auth/types'; // 导出 auth 相关的能力,该能力由 @ice/plugin-auth 插件提供 export const authConfig = defineAuthConfig(() => { diff --git a/website/docs/guide/plugins/plugin-dev.md b/website/docs/guide/plugins/plugin-dev.md index e5c6259f0..6cc8b1766 100644 --- a/website/docs/guide/plugins/plugin-dev.md +++ b/website/docs/guide/plugins/plugin-dev.md @@ -17,7 +17,7 @@ ice.js 提供了插件机制,在提供丰富的框架能力的基础上也可 ice.js 插件本质是一个 JS 模块,官方推荐以 TS 进行开发以获得良好的类型提示: ```ts -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; interface PluginOptions { id: string; @@ -40,7 +40,7 @@ export default plugin; 假设在项目根目录下有一个自定义插件 `my-plugin`: ```ts title="my-plugin.ts" -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; const plugin: Plugin = () => ({ name: 'my-plugin', @@ -112,7 +112,7 @@ export default defineConfig(() => ({ ```ts -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; const plugin: Plugin = () => ({ name: '@ice/my-plugin', @@ -129,7 +129,7 @@ export default plugin; ```tsx -import type { RuntimePlugin } from '@ice/runtime/esm/types'; +import type { RuntimePlugin } from '@ice/runtime/types'; const runtime: RuntimePlugin = async ({ appContext }) => { console.log(appContext); @@ -470,7 +470,7 @@ export default () => ({ 插件运行时可以定制框架的运行时能力: ```ts -import type { Plugin } from '@ice/app/esm/types'; +import type { Plugin } from '@ice/app/types'; const plugin: Plugin = () => ({ name: 'plugin-name' runtime: '/absolute/path/to/runtime', @@ -482,7 +482,7 @@ export default plugin; 框架运行时指向的文件地址为一个 JS 模块,源码阶段推荐用 TS 进行开发: ```ts -import type { RuntimePlugin } from '@ice/runtime/esm/types'; +import type { RuntimePlugin } from '@ice/runtime/types'; const runtime: RuntimePlugin = () => {}; export default runtime;