Skip to content

Commit

Permalink
feat(docs): Merge branch 'master' into feature/docs-to-dumi
Browse files Browse the repository at this point in the history
  • Loading branch information
hualigushi committed Aug 9, 2023
2 parents 0cee4ee + dc8d296 commit e4d85d8
Show file tree
Hide file tree
Showing 63 changed files with 82,149 additions and 47,087 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ See [Contributing Guide](https://umijs.org/docs/introduce/contributing).

### Core Maintainers

Core Maintainres are community members who have contributed a significant amount of time and energy to the project through issues, bug fixes, implementing enhancements/features.
Core Maintainers are community members who have contributed significantly to the project through addressing issues, fixing bugs, and implementing enhancements/features.

* [sorrycc](https://github.com/sorrycc)
* [xiaohuoni](https://github.com/xiaohuoni)

### Maintainers

Maintainers are community members who have 10 or more PRs merged in umi, or have spend lot's of time on umi community or issues.
Maintainers are community members who have had 10 or more PRs merged in umi or have spent a lot of time contributing to the umi community or addressing issues.

* [PeachScript](https://github.com/PeachScript)
* [YdreamW](https://github.com/YdreamW)
Expand All @@ -42,7 +42,7 @@ Maintainers are community members who have 10 or more PRs merged in umi, or have

### Contributors

Contributors are community members who have 1 or more PR merged in umi. Contributors can contact me[[sorrycc](https://github.com/sorrycc)] to join the Contributor Group.
Contributors are community members who have had 1 or more PRs merged in umi. If you are a contributor, you can contact me [[sorrycc](https://github.com/sorrycc)] to join the Contributor Group.

<a href="https://github.com/umijs/umi/graphs/contributors"><img src="https://opencollective.com/umi/contributors.svg?width=890&button=false" /></a>

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/docs/api/runtime-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function patchRoutes({ routes, routeComponents }) {

### patchClientRoutes(\{ routes \})

修改被 react-router 渲染前的树状路由表,接收内容同 [useRoutes](https://reactrouter.com/docs/en/v6/hooks/use-routes)
修改被 react-router 渲染前的树状路由表,接收内容同 [useRoutes](https://reactrouter.com/en/main/hooks/use-routes)

比如在最前面添加一个 `/foo` 路由,

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/docs/guides/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export default (api: IApi) => {
enableBy: api.EnableBy.config
});
api.modifyConfig((memo)=>{
memo.favicon = api.userConfig.changeFavicon;
memo.favicons = api.userConfig.changeFavicon;
return memo;
});
};
```
这个插件的作用是根据用户配置的 changeFavicon 值来更改配置中的 favicon,(一个很简单且没有实际用途的例子XD)。可以看到插件其实就是一个接收了参数 api 的方法。在这个方法中,我们调用了 `api.modifyConfig` 注册了一个 hook: `(memo)=>{...}`。当你在配置中配置了 `changeFavicon` 之后, Umi 会注册该插件。在 Umi 收集配置的生命周期里,我们在插件里注册的 hook 将被执行,此时配置中的 `favicon` 就会被修改为用户配置中的 `changeFavicon`
这个插件的作用是根据用户配置的 changeFavicon 值来更改配置中的 favicons,(一个很简单且没有实际用途的例子XD)。可以看到插件其实就是一个接收了参数 api 的方法。在这个方法中,我们调用了 `api.modifyConfig` 注册了一个 hook: `(memo)=>{...}`。当你在配置中配置了 `changeFavicon` 之后, Umi 会注册该插件。在 Umi 收集配置的生命周期里,我们在插件里注册的 hook 将被执行,此时配置中的 `favicon` 就会被修改为用户配置中的 `changeFavicon`

### plugin 和 preset
preset 的作用是预设一些插件,它通常用来注册一批 presets 和 plugins。在 preset 中,上述提到的接受 api 的方法可以有返回值,该返回值是一个包含 plugins 和 presets 属性的对象,其作用就是注册相应的插件或者插件集。
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/docs/max/mf.mdd
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ import { safeMfImport } from '@umijs/max';
import React, { Suspense } from 'react';

const RemoteCounter = React.lazy(() => {
return safeMfImport('remoteCounter/Counter', { defualt: () => 'Fallback' });
return safeMfImport('remoteCounter/Counter', { default: () => 'Fallback' });
});

export default function Page() {
Expand Down Expand Up @@ -328,7 +328,7 @@ registerMfRemote({
});

const RemoteCounter = React.lazy(() => {
return safeMfImport('registered/Counter', { defualt: null });
return safeMfImport('registered/Counter', { default: null });
});
```

Expand Down
1 change: 1 addition & 0 deletions examples/qiankun-master/.umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
routes: [
{ path: '/', redirect: '/home' },
{ path: '/home', component: 'index' },
{ path: '/nav', component: 'never' },
{
path: '/slave/*',
microApp: 'slave',
Expand Down
20 changes: 20 additions & 0 deletions examples/qiankun-master/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export const qiankun = {
master: {
routes: [
{
path: '/nav',
microApp: 'slave',
mode: 'match',
},
{
path: '/count',
microApp: 'slave',
mode: 'match',
},
{
path: '/prefix',
microApp: 'slave',
},
],
},
};
8 changes: 5 additions & 3 deletions examples/qiankun-master/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useState } from 'react';
import React from 'react';
// @ts-ignore
import { Link, MicroAppWithMemoHistory } from '@umijs/max';
import { Link } from '@umijs/max';
// @ts-ignore
import { Drawer } from 'antd';

export default function HomePage() {
return (
Expand All @@ -13,6 +12,9 @@ export default function HomePage() {
<Link to="/slave/home">
<button>go-slave</button>
</Link>
<Link to="/nav">
<button>go-match-slave</button>
</Link>
</div>
</div>
);
Expand Down
5 changes: 5 additions & 0 deletions examples/qiankun-master/pages/never.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

export default function () {
return <div style={{ color: 'red' }}>never seen</div>;
}
19 changes: 18 additions & 1 deletion examples/qiankun-slave/cypress/e2e/example.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('QianKun Plugin', () => {
it('can navigate to slave', () => {
// contains https://docs.cypress.io/api/commands/contains
cy.visit('/home');
cy.get('a').click();
cy.get('a[href*="/slave/home"]').click();

cy.contains('Slave Home Page');
});
Expand Down Expand Up @@ -45,6 +45,23 @@ describe('QianKun Plugin', () => {
});
});

describe('microApp route first', () => {
it('not hit indexApp route', () => {
// contains https://docs.cypress.io/api/commands/contains
cy.visit('/nav');

cy.contains('never seen').should('not.exist');
});
});

describe('microApp route prepend ok', () => {
it('hit microApp route', () => {
cy.visit('/prefix/nav');

cy.contains('goto slave app2');
});
});

describe('MicroAppLink crossing multi apps', function () {
it('jump between slave and slave-app2', () => {
cy.visit('/slave/nav');
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.0.71",
"version": "4.0.74",
"workspaces": ["packages/*"]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"devDependencies": {
"@iconify-json/ant-design": "1",
"@iconify-json/fa": "1",
"@pnpm/lockfile-file": "^5.0.3",
"@pnpm/logger": "^4.0.0",
"@pnpm/lockfile-file": "^8.1.1",
"@pnpm/logger": "^5.0.0",
"@types/fs-extra": "^11.0.1",
"@types/jest": "^29.2.5",
"@types/node": "^18.11.18",
Expand Down
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.0.71",
"version": "4.0.74",
"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.0.71",
"version": "4.0.74",
"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.0.71",
"version": "4.0.74",
"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
26 changes: 20 additions & 6 deletions packages/bundler-utils/bundles/babel/bundle.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
// Babel >= 7.22.0 renamed packages
// https://babeljs.io/blog/2023/05/26/7.22.0
const babelTransformDeps = {
exportNamespaceFrom: () => require('@babel/plugin-transform-export-namespace-from'),
classProperties: () => require('@babel/plugin-transform-class-properties'),
privateMethods: () => require('@babel/plugin-transform-private-methods'),
privatePropertyInObject: () => require('@babel/plugin-transform-private-property-in-object')
}

module.exports = {
codeFrame: () => require('@babel/code-frame'),
core: () => require('@babel/core'),
Expand All @@ -11,8 +20,8 @@ module.exports = {
require('@babel/plugin-proposal-do-expressions'),
pluginProposalExportDefaultFrom: () =>
require('@babel/plugin-proposal-export-default-from'),
pluginProposalExportNamespaceFrom: () =>
require('@babel/plugin-proposal-export-namespace-from'),
pluginProposalExportNamespaceFrom: babelTransformDeps.exportNamespaceFrom,
pluginTransformExportNamespaceFrom: babelTransformDeps.exportNamespaceFrom,
pluginProposalFunctionBind: () =>
require('@babel/plugin-proposal-function-bind'),
pluginProposalPartialApplication: () =>
Expand All @@ -34,8 +43,13 @@ module.exports = {
traverse: () => require('@babel/traverse'),
types: () => require('@babel/types'),

// class 使用 loose 模式需要
pluginProposalClassProperties: () => require('@babel/plugin-proposal-class-properties'),
pluginProposalPrivateMethods: () => require('@babel/plugin-proposal-private-methods'),
pluginProposalPrivatePropertyInObject: () => require('@babel/plugin-proposal-private-property-in-object')
// class-properties: class 使用 loose 模式需要
pluginProposalClassProperties: babelTransformDeps.classProperties,
pluginTransformClassProperties: babelTransformDeps.classProperties,
// private-methods
pluginProposalPrivateMethods: babelTransformDeps.privateMethods,
pluginTransformPrivateMethods: babelTransformDeps.privateMethods,
// private-property-in-object
pluginProposalPrivatePropertyInObject: babelTransformDeps.privatePropertyInObject,
pluginTransformPrivatePropertyInObject: babelTransformDeps.privatePropertyInObject
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./').pluginProposalClassProperties();
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./').pluginProposalExportNamespaceFrom();
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./').pluginProposalPrivateMethods();
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./').pluginProposalPrivatePropertyInObject();
Loading

0 comments on commit e4d85d8

Please sign in to comment.