Skip to content

Commit a295d29

Browse files
csr632cijiugechu
andcommitted
feat: v4 (#96)
* init search * refactor(theme-doc): share pageGroups analysis * search data with group info * improve name * improve code style * save work * upgrade deps * no loger need @types/react-router-dom * upgrade react-dom usage * update deps * keep rollup version align with vite * migrate to react-router v6 * fix ts error * dev mode works * tweak ssr * run types-react-codemod * fix ssr * fix types * simplify ssr config * migrate DemoMdxPlugin to mdx 2.x * TsInfoMdxPlugin works with mdx 2.x * FileTextMdxPlugin works with mdx 2.x * replace ImageMdxPlugin with remcohaszing/remark-mdx-images * add comment * fix routes and topBar links * disable search for now * remove theme-basic * don't need linkBins * chore: publish 4.0.0-alpha.0 * update create-project templates * chore: publish 4.0.0-alpha.1 * fix optimizeDeps * bump deps of templates * fix mdx code tag render * fix antd style * chore: publish alpha * works in node commonjs * fix ssr issue: commonjs interop * tweak test timout * update pnpm.lock * fix ci: taskkill error https://pipelines.actions.githubusercontent.com/serviceHosts/994468f0-9514-4a95-bb54-d52b4298100c/_apis/pipelines/1/runs/209/signedlogcontent/5?urlExpires=2022-11-24T15%3A31%3A48.5125848Z&urlSigningMethod=HMACV1&urlSignature=ijfBRodz0%2FlGqMcPz3vwUYkLYFkU8vHeE2Lp2boZ2gk%3D * prepare to analyze outline info (table of content) at buildtime * tweak windows test ci * improve test-setup * fix ssr on windows * fix typo * outline info render * chore: publish alpha * fix outline render * improve demo * chore: publish alpha * fix import error in cjs env * chore: publish alpha * simplify demos * upgrade antd to 5.x * tweak demo * chore: publish alpha * fix theme style * chore: publish alpha * fix test * improve search * fix anchor link when using hash router * chore: publish alpha * fix ts error * chore: publish alpha * fix build * chore: publish alpha * fix import allPagesOutlines * chore: publish alpha * fix build * fix ci * fix anchor link scroll * improve demos * chore: publish alpha * fix cleanStaticData * OutlineInfoModuleManager should skip update it outline info didn't changed * headings (outlines) update should trigger hmr hot update instead of full reload * chore: publish alpha * make hmr works with mdx files workaround this issue: vitejs/vite-plugin-react#38 * don't show loading state when: - User navigates back to a loaded page. - Hmr update during dev. * improve file names * fix path * fix hydration layout change * chore: publish alpha * better name * update jotai and remove local copy * bundle client modules to reduce browser request during dev and avoid conflict npm package with users * update pnpm lock * jotai provider-less mode * experiment * chore: publish alpha * don't need to build client with tsc; cleanup * update deps * fix ts error * adapt to vite-plugin-react 3.0 breaking change: no longer do jsx transform to .md files * upgrade playwright test * chore: publish alpha * fix warning of useLayoutEffect during ssr * fix react warning * publish alpha * cleanup setup for doc * cleanup * warn for old mdx plugin * update lock * make setupPlugins the default export * update setup * improve vite setup * improve vite setup * update docs * publish alpha * prevent search popup scroll with page * improve mdx setup * fix outline layout * improve search popup style on narrow screen * publish alpha * add an option to turn off search * publish alpha * cleanup deps * improve antd ssr * fix ssr hydrate style flash * publish alpha * react-pages should not couple on @ant-design/cssinjs * alpha * use a rollup plugin to add style import to output bundles * implement a SSR plugin system to decouple vite-pages ssr from antd ssr steps * publish alpha * vite-pages-theme-doc have "type": "module" * pub * support ssr plugin to let user hook into the ssr process * improve ssr plugin * improve ssr plugin system: no longer need vite plugin * improve ssr plugin * fix ssr plugin * fix outline style * cleanup * update deps * remove vite-plugin-mdx * fix cleanStaticData * fix demo * fix demos * publish alpha * update contributing guide * feat: minify html for ssg mode (#102) * feat: minify html for ssg * chore: format Co-authored-by: 阿良仔 <[email protected]>
1 parent ebda73c commit a295d29

File tree

169 files changed

+6637
-6823
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+6637
-6823
lines changed

.prettierignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ packages/**/dist
33
packages/**/lib
44
packages/playground-temp
55

6-
packages/react-pages/src/client/jotai/index.js
7-
packages/react-pages/src/client/jotai/utils.js
8-
96
doc-site/dist
107
doc-site/node_modules
118

.vscode/launch.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
{
8+
"name": "Launch via NPM",
9+
"request": "launch",
10+
"runtimeArgs": ["run-script", "dev"],
11+
"runtimeExecutable": "npm",
12+
"skipFiles": ["<node_internals>/**"],
13+
"type": "node",
14+
"cwd": "${fileDirname}"
15+
},
716
{
817
"type": "node",
918
"request": "attach",
1019
"name": "Attach",
1120
"port": 9229,
12-
"skipFiles": [
13-
"<node_internals>/**"
14-
]
21+
"skipFiles": ["<node_internals>/**"]
1522
}
1623
]
17-
}
24+
}

TODO.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,4 @@ DATA node, graph, lazy/eager node
2929
- file 2.3
3030
- file 2.4 (lazy)
3131

32-
- [upgrade to mdx v2](https://github.com/brillout/vite-plugin-mdx#vite-plugin-mdx)
33-
- upgrade to React 18 and react-router-dom 6.x
34-
3532
bug: routePath don't change when route from a 404 page to another 404 page

doc-site/declare.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc-site/package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"private": true,
44
"version": "1.0.0",
55
"description": "",
6+
"type": "module",
67
"scripts": {
78
"dev": "vite serve",
89
"debug": "node --inspect ./node_modules/vite/bin/vite serve",
@@ -15,20 +16,18 @@
1516
"author": "",
1617
"license": "ISC",
1718
"dependencies": {
18-
"react": "^17.0.1",
19-
"react-dom": "^17.0.1",
20-
"react-router-dom": "^5.2.0"
19+
"react": "^18.2.0",
20+
"react-dom": "^18.2.0",
21+
"react-router-dom": "^6.5.0"
2122
},
2223
"devDependencies": {
23-
"@types/react": "^17.0.3",
24-
"@types/react-router-dom": "^5.1.7",
25-
"@vitejs/plugin-react": "^2.1.0",
24+
"@types/react": "^18.0.26",
25+
"@vitejs/plugin-react": "^3.0.0",
2626
"gh-pages": "^4.0.0",
2727
"rimraf": "^3.0.2",
28-
"serve": "^14.0.1",
29-
"vite": "^3.1.0",
28+
"serve": "^14.1.2",
29+
"vite": "^4.0.1",
3030
"vite-pages-theme-doc": "workspace:*",
31-
"vite-plugin-mdx": "^3.5.11",
3231
"vite-plugin-react-pages": "workspace:*"
3332
}
3433
}

doc-site/pages/404.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react'
2-
import { Redirect } from 'react-router-dom'
2+
import { Navigate } from 'react-router-dom'
33

44
const Component404 = () => {
5-
return <Redirect to="/" />
5+
return <Navigate to="/" replace />
66
}
77

88
export default Component404
155 KB
Loading

doc-site/pages/page-data$.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ As stated in [the theme customization doc](/theme-customization), a theme is a R
8282

8383
Here is the interface of a theme:
8484

85-
<FileText src="../../packages/react-pages/theme.doc.d.ts" syntax="ts">
85+
<FileText src="../../packages/react-pages/theme.doc.d.ts" syntax="ts" />
8686

8787
> Here is an example implementation of vite-pages theme: [vite-pages-theme-doc](https://github.com/vitejs/vite-plugin-react-pages/blob/main/packages/theme-doc/src/index.tsx). [This fixture](https://github.com/vitejs/vite-plugin-react-pages/blob/main/packages/playground/use-theme-doc/pages/_theme.tsx) demonstrate how to use it.
8888

doc-site/pages/upgrade-from-v2$.mdx renamed to doc-site/pages/upgrade-from-v2-to-v3$.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: Upgrade from v2
3-
order: 6
2+
title: Upgrade from v2 to v3
3+
order: 2
44
subGroup: upgrade-guides
55
---
66

7-
# Upgrade from vite-plugin-react-pages v2
7+
# Upgrade from v2 to v3
88

99
## Upgrade package versions
1010

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: Upgrade from v3 to v4
3+
order: 1
4+
subGroup: upgrade-guides
5+
---
6+
7+
# Upgrade from v3 to v4
8+
9+
vite-pages v4 is released with following improvements:
10+
11+
- Support [Vite v4](https://vitejs.dev/guide/migration.html).
12+
- Upgrade React to [18.x](https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html).
13+
- Upgrade react-router to [6.x](https://reactrouter.com/en/main/upgrading/v5).
14+
- Upgrade mdx to [2.x](https://mdxjs.com/migrating/v2/).
15+
- Upgrade antd to [5.x](https://ant.design/docs/react/migration-v5) (for vite-pages-theme-doc).
16+
- Support [Node.js ECMAScript modules](https://nodejs.org/api/esm.html).
17+
- Support markdown outline (table of content).
18+
- Support search.
19+
20+
![outline-and-search](./_assets/outline-and-search.jpg)
21+
22+
The following article will show you the migrate instructions. If you encounter problems, open an issue in the repo. Or checkout the [getting-stated templates](https://vitejs.github.io/vite-plugin-react-pages/#getting-stated) for reference.
23+
24+
## Upstream libraries migration
25+
26+
Most upgrade work for upstream libraries is already done inside `vite-plugin-react-pages` and `vite-pages-theme-doc`. But some migration need to be done in userland, if you are using some old APIs that are dropped by these upstream libraries. For example, you can no longer use `<Switch>` of `react-router`. Checkout the links above for the migration guides of upstream libraries.
27+
28+
We expect upstream libraries migration to be very easy for framwork users, unless you used many `react-router` v5-only APIs.
29+
30+
## Remove vite-plugin-mdx
31+
32+
Since `vite-plugin-mdx` doesn't support mdx v2, vite-pages now includes a builtin mdx plugin. So you should remove the `vite-plugin-mdx` in vite-pages v5.
33+
34+
Update `vite.config.ts`:
35+
36+
```diff
37+
import { defineConfig } from 'vite'
38+
import react from '@vitejs/plugin-react'
39+
- import mdx from 'vite-plugin-mdx'
40+
import pages from 'vite-plugin-react-pages'
41+
42+
export default defineConfig({
43+
plugins: [
44+
react(),
45+
- mdx(),
46+
pages()
47+
],
48+
})
49+
```
50+
51+
Notice that `pages()` now return an array of vite plugins(instead of return a plugin). But vite can understand that and apply every plugin in that array. So the invoke pattern of `vite-plugin-react-pages` looks exactly the same as before! You don't need to apply the new builtin mdx plugin manually.
52+
53+
Update `package.json`:
54+
55+
- Remove `vite-plugin-mdx` and `@mdx-js/mdx`.
56+
- You should upgrade `@mdx-js/react` to `^2.1.5`. It is a peerDependencies of mdx, so it should be installed by your vite project.
57+
58+
```diff
59+
{
60+
"devDependencies": {
61+
- "@mdx-js/mdx": "^1.6.22",
62+
- "vite-plugin-mdx": "^3.5.11",
63+
- "@mdx-js/react": "^1.6.22",
64+
+ "@mdx-js/react": "^2.1.5",
65+
}
66+
}
67+
```
68+
69+
## Use Node.js ECMAScript modules
70+
71+
The Node.js community is quickly migrating from CommonJS to ECMAScript modules (esm). And we encourage you to run vite on the esm mode of Node.js.
72+
73+
How to enable esm for Node.js? Just add a `"type": "module"` field to the `package.json` of your vite project!
74+
75+
> It is encouraged to have a dedicated `package.json` for your vite project. Your vite project should not share a `package.json` with the npm package that you are publishing (or the worspace package in the project root directory, if you are using monorepo).

0 commit comments

Comments
 (0)