mirror of https://github.com/alibaba/ice.git
fix: import path of types and runtime (#5981)
* fix: import path of types and runtime * chore: package.json * chore: add changelog * fix: typings * fix: type declare
This commit is contained in:
parent
1c09e79e3f
commit
56fb406e8a
|
@ -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
|
|
@ -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__');
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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(() => ({
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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(() => ({}));
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
"!esm/**/*.map",
|
||||
"templates",
|
||||
"openChrome.applescript",
|
||||
"types.d.ts"
|
||||
"*.d.ts"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.19.0",
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -90,10 +90,11 @@ export function generateDeclaration(exportList: Array<TargetDeclarationData | De
|
|||
specifiers.forEach((specifierStr) => {
|
||||
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);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
export type { Config, webpack } from '@ice/webpack-config/types';
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<Config>, appConfig: AppConfig) => {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -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<string, 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<string, string>;
|
||||
}
|
||||
export * from './esm/types';
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/types';
|
|
@ -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 {
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/runtime';
|
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/types';
|
|
@ -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';
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
export * from './esm/runtime/child';
|
||||
export * from './esm/runtime/framework';
|
|
@ -1,4 +1,4 @@
|
|||
import type { Plugin } from '@ice/app/esm/types';
|
||||
import type { Plugin } from '@ice/app/types';
|
||||
|
||||
interface PluginOptions {
|
||||
type: 'child' | 'framework';
|
||||
|
|
|
@ -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<LifecycleOptions> = ({ setRender }, runtimeOptions) => {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/types';
|
|
@ -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);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { Plugin } from '@ice/app/esm/types';
|
||||
import type { Plugin } from '@ice/app/types';
|
||||
|
||||
interface PluginOptions {
|
||||
locales: string | string[];
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
"files": [
|
||||
"esm",
|
||||
"!esm/**/*.map",
|
||||
"template"
|
||||
"template",
|
||||
"*.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"watch": "tsc -w",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/runtime';
|
|
@ -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.
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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<PluginOptions> = (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.
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/types';
|
|
@ -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';
|
||||
|
|
|
@ -45,7 +45,8 @@
|
|||
"types": "./esm/index.d.ts",
|
||||
"files": [
|
||||
"esm",
|
||||
"!esm/**/*.map"
|
||||
"!esm/**/*.map",
|
||||
"*.d.ts"
|
||||
],
|
||||
"dependencies": {
|
||||
"ahooks": "^3.0.0",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/runtime';
|
|
@ -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<PluginRequestOptions | void> = () => ({
|
|||
type: false,
|
||||
});
|
||||
},
|
||||
runtime: `${PLUGIN_NAME}/esm/runtime`,
|
||||
runtime: `${PLUGIN_NAME}/runtime`,
|
||||
staticRuntime: true,
|
||||
keepExports: ['requestConfig'],
|
||||
});
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/types';
|
|
@ -35,7 +35,8 @@
|
|||
"types": "./esm/index.d.ts",
|
||||
"files": [
|
||||
"esm",
|
||||
"!esm/**/*.map"
|
||||
"!esm/**/*.map",
|
||||
"*.d.ts"
|
||||
],
|
||||
"dependencies": {
|
||||
"@ice/store": "^2.0.3",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/runtime';
|
|
@ -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> = (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] {
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/types';
|
|
@ -20,7 +20,8 @@
|
|||
"files": [
|
||||
"esm",
|
||||
"!esm/**/*.map",
|
||||
"templates"
|
||||
"templates",
|
||||
"*.d.ts"
|
||||
],
|
||||
"author": "ICE",
|
||||
"license": "MIT",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/router';
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/types';
|
|
@ -12,7 +12,8 @@
|
|||
},
|
||||
"files": [
|
||||
"esm",
|
||||
"!esm/**/*.map"
|
||||
"!esm/**/*.map",
|
||||
"*.d.ts"
|
||||
],
|
||||
"dependencies": {
|
||||
"@ice/bundles": "0.1.4",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from './esm/types';
|
|
@ -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 {
|
||||
|
|
|
@ -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(() => ({
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 () => {
|
||||
// 模拟请求后端数据
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
|
@ -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(() => ({
|
|||
<TabItem value="index.ts" label="src/index.ts">
|
||||
|
||||
```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;
|
|||
<TabItem value="runtime.tsx" label="src/runtime.tsx">
|
||||
|
||||
```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;
|
||||
|
|
Loading…
Reference in New Issue