Skip to content

Commit

Permalink
Merge branch 'umijs:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
liuwenzhuang authored Aug 27, 2024
2 parents 03dd36d + 8f95914 commit 4713cd2
Show file tree
Hide file tree
Showing 56 changed files with 391 additions and 200 deletions.
2 changes: 1 addition & 1 deletion did-you-know/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default (api: any) => {

const cacheDir = path.join(api.paths.absNodeModulesPath, '.cache');
if (!fs.existsSync(cacheDir)) {
fs.mkdirSync(cacheDir);
fs.mkdirSync(cacheDir, { recursive: true });
}
fs.writeFileSync(recordJSONPath, JSON.stringify(records), 'utf-8');
});
Expand Down
2 changes: 1 addition & 1 deletion docs/.dumi/components/Hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const Hero = () => {
<div className="left">
<div className="bigLogo" />
<div className="actions">
<Link to="/docs/tutorials/getting-started">
<Link to="/docs/guides/getting-started">
<div className="button">快速上手 →</div>
</Link>
<div className="githubStar">
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/blog/umi-4-rc.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ group:

以上是 Umi 4 目前的新功能。

除此之外,还有一些计划在正式版发布之前做的事情。包括 <span style={{color:'red'}}>api route、umi server and adapter、route loader、稳定的 lint、更多命令、组件研发 father 4、文档工具 dumi 2</span> 等,会在之后的 RC 版本中与大家见面。
除此之外,还有一些计划在正式版发布之前做的事情。包括 <span style="color:red;">api route、umi server and adapter、route loader、稳定的 lint、更多命令、组件研发 father 4、文档工具 dumi 2</span> 等,会在之后的 RC 版本中与大家见面。

欢迎大家尝鲜 Umi 4,官方文档有准备 ant-design-pro 从 Umi 3 到 4 的升级文档。同时 RC 阶段,还准备了一个<span style={{color:'red',fontWeight:'bold'}}>手把手升级的微信交流群</span>,欢迎 Umi 4 的先行者们加入,祝大家升级顺利,也提前祝大家新年快乐 🧨,🐯 年吉祥。
欢迎大家尝鲜 Umi 4,官方文档有准备 ant-design-pro 从 Umi 3 到 4 的升级文档。同时 RC 阶段,还准备了一个<span style="color:red;fontWeight:bold;">手把手升级的微信交流群</span>,欢迎 Umi 4 的先行者们加入,祝大家升级顺利,也提前祝大家新年快乐 🧨,🐯 年吉祥。

<p>
<img
src="https://img.alicdn.com/imgextra/i4/O1CN01QmMTeR1jd6l2cwHQh_!!6000000004570-0-tps-1170-1500.jpg"
width="300"
/>
</p>
</p>
10 changes: 9 additions & 1 deletion docs/docs/docs/api/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export async function clientLoader() {
- 类型:`{ jsStrategy: 'bigVendors' | 'depPerChunk' | 'granularChunks'; jsStrategyOptions: {} }`
- 默认值:`null`

提供 code splitting 的策略方案。
用于配置 code splitting 的策略方案,Umi 默认以路由为分界拆分 chunk,实现路由维度的 chunk 按需加载,如果在此之上希望继续提取公共 chunk,可以选择合适的策略进行配置,差异如下

bigVendors 是大 vendors 方案,会将 async chunk 里的 node_modules 下的文件打包到一起,可以避免重复。同时缺点是,1)单文件的尺寸过大,2)毫无缓存效率可言。

Expand Down Expand Up @@ -963,6 +963,14 @@ legacy: {}
links: [{ href: '/foo.css', rel: 'preload' }],
```

## mako <Badge>4.3.2+</Badge>

- 类型: `{ plugins?: Array<{ load?: ((...args: any[]) => unknown) | undefined; generateEnd?: ((...args: any[]) => unknown) | undefined; }> | undefined; px2rem?: { root?: number | undefined; propBlackList?: Array<string> | undefined; propWhiteList?: Array<string> | undefined; selectorBlackList?: Array<string> | undefined; selectorWhiteList?: Array<string> | undefined; selectorDoubleList?: Array<string> | undefined; } | undefined; experimental?: { webpackSyntaxValidate?: Array<string> | undefined; } | undefined; flexBugs?: boolean | undefined; moduleIdStrategy?: string | undefined; optimization?: { skipModules?: boolean | undefined; } | undefined; }`
- 默认值: `{}`

使用 [mako](https://makojs.dev/) 用于编译以显著提高构建速度。
通过配置以启用这个能力,配置将传递给mako。这里只提供了一些常用的配置,更多的配置可以在 `mako.config.json` 文件中设置。有关更多信息,请参阅[mako-config文档](https://makojs.dev/docs/config)

## manifest

- 类型:`{ fileName: string; basePath: string }`
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/docs/guides/boilerplate.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ translated_at: '2024-03-17T10:35:15.206Z'
Umi officially provides a scaffold, which allows you to easily and quickly create a project:

```bash
# Create a project in the current folder
# Input the path to the project directory when prompted by the wizard
pnpm create umi
# Create a project under the my-umi-app folder in the current directory
pnpm create umi my-umi-app
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/docs/guides/boilerplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toc: content
Umi 官方提供了一个脚手架 ,可以轻松快速创建一个项目:

```bash
# 在当前文件夹下创建项目
# 在向导中输入文件夹名称
pnpm create umi
# 在当前目录的 my-umi-app 文件夹下创建项目
pnpm create umi my-umi-app
Expand Down
6 changes: 0 additions & 6 deletions docs/docs/docs/guides/getting-started.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ $ pnpm -v

## Create a Project

First, find a place to create a new empty directory.

```bash
$ mkdir myapp && cd myapp
```

Create a project using the official tool,

PNPM
Expand Down
5 changes: 0 additions & 5 deletions docs/docs/docs/guides/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ $ pnpm -v

## 创建项目

先找个地方建个空目录。

```bash
$ mkdir myapp && cd myapp
```

通过官方工具创建项目,

Expand Down
2 changes: 2 additions & 0 deletions docs/docs/docs/max/layout-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ icon: 'HomeFilled';
icon: 'HomeTwoTone';
```

兼容[icons](../../docs/api/config#icons)功能,打开icons功能后,可以使用图标集或者本地的图标。具体请参考icons功能的相关配置和使用方法。

#### access

- Type: `string`
Expand Down
5 changes: 3 additions & 2 deletions examples/ant-design-pro/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default defineConfig({
// TODO: vite mode don't support ie 11
// ie: 11,
},
// umi routes: https://umijs.org/docs/routing
// umi routes: https://umijs.org/docs/guides/routes
routes: [
{
path: '/user',
Expand Down Expand Up @@ -338,5 +338,6 @@ export default defineConfig({
codeSplitting: {
jsStrategy: 'granularChunks',
},
ui: {},
// ui: {},
mako: {},
});
58 changes: 0 additions & 58 deletions examples/ant-design-pro/config/routes.ts

This file was deleted.

6 changes: 0 additions & 6 deletions examples/ant-design-pro/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import { currentUser as queryCurrentUser } from './services/ant-design-pro/api';
const isDev = process.env.NODE_ENV === 'development';
const loginPath = '/user/login';

// TODO: 不知道这是啥?
/** 获取用户信息比较慢的时候会展示一个 loading */
// export const initialStateConfig = {
// loading: <PageLoading />,
// };

/**
* @see https://umijs.org/zh-CN/plugins/plugin-initial-state
* */
Expand Down
5 changes: 5 additions & 0 deletions examples/ant-design-pro/src/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { PageLoading } from '@ant-design/pro-components';
const Loading = () => {
return <PageLoading />;
};
export default Loading;
5 changes: 3 additions & 2 deletions examples/max/.umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export default defineConfig({
{
title: 'site.title',
path: '/',
icon: 'PlaySquareFilled',
icon: 'ic:baseline-14mp',
component: 'index',
name: 'index',
},
{
path: '/users',
icon: 'SmileFilled',
icon: 'local:rice',
component: 'users',
name: 'users',
wrappers: ['@/wrappers/foo', '@/wrappers/bar'],
Expand Down Expand Up @@ -105,6 +105,7 @@ export default defineConfig({
jsStrategy: 'granularChunks',
},
icons: {
autoInstall: {},
include: ['local:rice', 'local:logo/umi', 'ant-design:fire-twotone'],
},
});
2 changes: 2 additions & 0 deletions examples/max/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"react-dom": "18.3.1"
},
"devDependencies": {
"@iconify-json/ic": "1.1.17",
"@iconify-json/solar": "1.1.9",
"cross-env": "^7.0.3",
"cypress": "^12.0.0",
"start-server-and-test": "^1.15.2",
Expand Down
7 changes: 6 additions & 1 deletion examples/max/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ export default function HomePage() {
tailwindcss
</h2>

<h2> Icons</h2>
<h2>Icon library icons</h2>
<Icon icon="ic:baseline-14mp" />
<Icon icon="ic:baseline-3p" />
<Icon icon="solar:4k-bold" />

<h2>Local Icons</h2>
<div>
{includedIcons.map((i) => {
return <Icon spin icon={i} className={i} key={i} />;
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "4.3.1",
"version": "4.3.17",
"workspaces": ["packages/*"]
}
2 changes: 1 addition & 1 deletion packages/ast/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@umijs/ast",
"version": "4.3.1",
"version": "4.3.17",
"description": "@umijs/ast",
"homepage": "https://github.com/umijs/umi/tree/master/packages/ast#readme",
"bugs": "https://github.com/umijs/umi/issues",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-umi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@umijs/babel-preset-umi",
"version": "4.3.1",
"version": "4.3.17",
"description": "Official babel preset for umi.",
"homepage": "https://github.com/umijs/umi/tree/master/packages/babel-preset-umi#readme",
"bugs": "https://github.com/umijs/umi/issues",
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-esbuild/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@umijs/bundler-esbuild",
"version": "4.3.1",
"version": "4.3.17",
"description": "@umijs/bundler-esbuild",
"homepage": "https://github.com/umijs/umi/tree/master/packages/bundler-esbuild#readme",
"bugs": "https://github.com/umijs/umi/issues",
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@umijs/bundler-utils",
"version": "4.3.1",
"version": "4.3.17",
"homepage": "https://github.com/umijs/umi/tree/master/packages/bundler-utils#readme",
"bugs": "https://github.com/umijs/umi/issues",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@umijs/bundler-vite",
"version": "4.3.1",
"version": "4.3.17",
"description": "@umijs/bundler-vite",
"homepage": "https://github.com/umijs/umi/tree/master/packages/bundler-vite#readme",
"bugs": "https://github.com/umijs/umi/issues",
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-vite/src/config/transformer/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default (function target(userConfig) {
return false;
}

const isLegacy = isLegacyBrowser(userConfig.targets);
const isLegacy = isLegacyBrowser(userConfig.targets || {});

// convert { ie: 11 } to ['ie11']
// 低版本浏览器需要使用 legacy 插件 同时设置会有 warning
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@umijs/bundler-webpack",
"version": "4.3.1",
"version": "4.3.17",
"description": "@umijs/bundler-webpack",
"homepage": "https://github.com/umijs/umi/tree/master/packages/bundler-webpack#readme",
"bugs": "https://github.com/umijs/umi/issues",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@umijs/core",
"version": "4.3.1",
"version": "4.3.17",
"homepage": "https://github.com/umijs/umi/tree/master/packages/core#readme",
"bugs": "https://github.com/umijs/umi/issues",
"repository": {
Expand Down
26 changes: 16 additions & 10 deletions packages/core/src/route/routesConvention.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { winPath } from '@umijs/utils';
import { existsSync, lstatSync, readdirSync, statSync } from 'fs';
import { extname, relative, resolve } from 'path';
import { defineRoutes } from './defineRoutes';
import {
byLongestFirst,
createRouteId,
findParentRouteId,
isRouteModuleFile,
} from './utils';
import { byLongestFirst, createRouteId, isRouteModuleFile } from './utils';

// opts.base: path of pages
export function getConventionRoutes(opts: {
Expand All @@ -30,11 +25,22 @@ export function getConventionRoutes(opts: {
});

const routeIds = Object.keys(files).sort(byLongestFirst);

const parentToChildrenMap = new Map();
routeIds.forEach((id) => {
const prefix = `${id}/`;
routeIds
.filter((childId) => childId.startsWith(prefix) && childId !== id)
.forEach((childId) => {
if (!parentToChildrenMap.has(id)) {
parentToChildrenMap.set(id, []);
}
parentToChildrenMap.get(id).push(childId);
});
});
function defineNestedRoutes(defineRoute: any, parentId?: string) {
const childRouteIds = routeIds.filter(
(id) => findParentRouteId(routeIds, id) === parentId,
);
const childRouteIds = parentId
? parentToChildrenMap.get(parentId) || []
: routeIds;
for (let routeId of childRouteIds) {
let routePath = createRoutePath(
parentId ? routeId.slice(parentId.length + 1) : routeId,
Expand Down
7 changes: 0 additions & 7 deletions packages/core/src/route/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ export function byLongestFirst(a: string, b: string): number {
return b.length - a.length;
}

export function findParentRouteId(
routeIds: string[],
childRouteId: string,
): string | undefined {
return routeIds.find((id) => childRouteId.startsWith(`${id}/`));
}

const routeModuleExts = ['.js', '.jsx', '.ts', '.tsx', '.md', '.mdx', '.vue'];
export function isRouteModuleFile(opts: { file: string; exclude?: RegExp[] }) {
// TODO: add cache strategy
Expand Down
2 changes: 1 addition & 1 deletion packages/create-umi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-umi",
"version": "4.3.1",
"version": "4.3.17",
"description": "create-umi",
"homepage": "https://github.com/umijs/umi/tree/master/packages/create-umi#readme",
"bugs": "https://github.com/umijs/umi/issues",
Expand Down
Loading

0 comments on commit 4713cd2

Please sign in to comment.