Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: import path of types and runtime #5981

Merged
merged 5 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changeset/forty-doors-hear.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion examples/csr-project/src/app.tsx
Original file line number Diff line number Diff line change
@@ -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__');
Expand Down
4 changes: 2 additions & 2 deletions examples/icestark-child/src/app.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -29,4 +29,4 @@ export default defineAppConfig(() => ({
router: {
basename,
},
}));
}));
4 changes: 2 additions & 2 deletions examples/icestark-layout/src/app.tsx
Original file line number Diff line number Diff line change
@@ -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(() => ({
Expand All @@ -21,4 +21,4 @@ export default defineAppConfig(() => ({
app: {
rootId: 'app',
},
}));
}));
4 changes: 2 additions & 2 deletions examples/with-antd-mobile/src/store.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -18,4 +18,4 @@ export const StoreProvider: ComponentWithChildren = ({ children }) => {

export {
useCounterContext,
};
};
2 changes: 1 addition & 1 deletion examples/with-auth/src/app.tsx
Original file line number Diff line number Diff line change
@@ -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(() => ({}));

Expand Down
2 changes: 1 addition & 1 deletion examples/with-pha/src/app.tsx
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 1 addition & 1 deletion examples/with-request/src/app.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/with-store/src/app.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"!esm/**/*.map",
"templates",
"openChrome.applescript",
"types.d.ts"
"*.d.ts"
],
"engines": {
"node": ">=14.19.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/ice/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/commands/test.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/config.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions packages/ice/src/createService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions packages/ice/src/esbuild/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -91,4 +91,4 @@ const createAssetsPlugin = (compilationInfo: CompilationInfo | (() => Compilatio
},
});

export default createAssetsPlugin;
export default createAssetsPlugin;
2 changes: 1 addition & 1 deletion packages/ice/src/getWatchEvents.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/middlewares/ssr/renderMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/middlewares/ssr/renderOnDemand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/plugins/web/task.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/service/ServerRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/service/preBundleDeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/ice/src/service/runtimeGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/service/serverCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/service/webpackCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/test/defineJestConfig.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
4 changes: 2 additions & 2 deletions packages/ice/src/types/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/types/userConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { DefineRouteFunction } 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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/utils/getRouterBasename.ts
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/ice/src/utils/mergeTaskConfig.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -24,4 +24,4 @@ function mergeTaskConfig(
});
}

export default mergeTaskConfig;
export default mergeTaskConfig;
2 changes: 1 addition & 1 deletion packages/ice/src/utils/runtimeEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion packages/ice/templates/core/types.ts.ejs
Original file line number Diff line number Diff line change
@@ -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(' & ') %><% } %>;
Expand All @@ -15,4 +15,5 @@ type PageConfigDefinition = (context: PageConfigDefinitionContext) => PageConfig
export type {
AppConfig,
PageConfig,
PageConfigDefinition,
};
Loading