Skip to content

Commit 55873c4

Browse files
tried this and I think I need to move to app router on next13, then upgrade to 15, then enable the complier
1 parent dc08860 commit 55873c4

File tree

6 files changed

+1711
-258
lines changed

6 files changed

+1711
-258
lines changed

next.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ const nextConfig = {
1010
reactStrictMode: true,
1111
experimental: {
1212
// TODO: Remove after https://github.com/vercel/next.js/issues/49355 is fixed
13-
appDir: false,
13+
// appDir: false,
1414
scrollRestoration: true,
15-
legacyBrowsers: false,
15+
// legacyBrowsers: false,
16+
reactCompiler: true,
17+
staleTimes: {
18+
dynamic: 30,
19+
static: 180,
20+
},
1621
},
1722
env: {},
1823
webpack: (config, {dev, isServer, ...options}) => {

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@
2828
"@docsearch/react": "3.0.0-alpha.41",
2929
"@headlessui/react": "^1.7.0",
3030
"@radix-ui/react-context-menu": "^2.1.5",
31+
"babel-plugin-react-compiler": "^0.0.0-experimental-938cd9a-20240601",
3132
"body-scroll-lock": "^3.1.3",
3233
"classnames": "^2.2.6",
3334
"date-fns": "^2.16.1",
3435
"debounce": "^1.2.1",
3536
"github-slugger": "^1.3.0",
36-
"next": "^13.4.1",
37+
"next": "^15.0.0-rc.0",
3738
"next-remote-watch": "^1.0.0",
3839
"parse-numeric-range": "^1.2.0",
39-
"react": "^0.0.0-experimental-16d053d59-20230506",
40+
"react": "^19.0.0-rc-f994737d14-20240522",
4041
"react-collapsed": "4.0.4",
41-
"react-dom": "^0.0.0-experimental-16d053d59-20230506",
42+
"react-dom": "^19.0.0-rc-f994737d14-20240522",
4243
"remark-frontmatter": "^4.0.1",
4344
"remark-gfm": "^3.0.1"
4445
},
@@ -62,7 +63,7 @@
6263
"autoprefixer": "^10.4.2",
6364
"babel-eslint": "10.x",
6465
"eslint": "7.x",
65-
"eslint-config-next": "12.0.3",
66+
"eslint-config-next": "^15.0.0-rc.0",
6667
"eslint-config-react-app": "^5.2.1",
6768
"eslint-plugin-flowtype": "4.x",
6869
"eslint-plugin-import": "2.x",
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
diff --git a/node_modules/next/dist/server/render.js b/node_modules/next/dist/server/render.js
2-
index a1f8648..1b3d608 100644
2+
index 73cf44c..f3d9022 100644
33
--- a/node_modules/next/dist/server/render.js
44
+++ b/node_modules/next/dist/server/render.js
5-
@@ -758,9 +758,14 @@ async function renderToHTML(req, res, pathname, query, renderOpts) {
5+
@@ -815,9 +815,14 @@ async function renderToHTMLImpl(req, res, pathname, query, renderOpts, extra) {
66
// Always using react concurrent rendering mode with required react version 18.x
77
const renderShell = async (EnhancedApp, EnhancedComponent)=>{
88
const content = renderContent(EnhancedApp, EnhancedComponent);
9-
- return await (0, _nodewebstreamshelper.renderToInitialStream)({
9+
- return await (0, _nodewebstreamshelper.renderToInitialFizzStream)({
1010
- ReactDOMServer: _serverbrowser.default,
1111
- element: content
1212
+ return new Promise((resolve, reject) => {
@@ -19,4 +19,4 @@ index a1f8648..1b3d608 100644
1919
+ }).then(resolve, reject);
2020
});
2121
};
22-
const createBodyResult = (0, _tracer.getTracer)().wrap(_constants2.RenderSpan.createBodyResult, (initialStream, suffix)=>{
22+
const hasDocumentGetInitialProps = process.env.NEXT_RUNTIME !== 'edge' && !!Document.getInitialProps;

src/pages/[[...markdownPath]].js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import compileMDX from 'utils/compileMDX';
1515
import {generateRssFeed} from '../utils/rss';
1616

1717
export default function Layout({content, toc, meta, languages}) {
18+
console.log(content);
1819
const parsedContent = useMemo(
1920
() => JSON.parse(content, reviveNodeOnClient),
2021
[content]
@@ -72,11 +73,9 @@ function useActiveSection() {
7273

7374
// Deserialize a client React tree from JSON.
7475
function reviveNodeOnClient(key, val) {
75-
if (Array.isArray(val) && val[0] == '$r') {
76+
if (typeof val === 'object' && val !== null && 'type' in val) {
7677
// Assume it's a React element.
77-
let type = val[1];
78-
let key = val[2];
79-
let props = val[3];
78+
let {type, key, ref, props} = val;
8079
if (type === 'wrapper') {
8180
type = Fragment;
8281
props = {children: props.children};
@@ -92,7 +91,7 @@ function reviveNodeOnClient(key, val) {
9291
$$typeof: Symbol.for('react.element'),
9392
type: type,
9493
key: key,
95-
ref: null,
94+
ref: ref,
9695
props: props,
9796
_owner: null,
9897
};

src/pages/_document.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const MyDocument = () => {
142142
// An example of such content can be the keyboard shortcut displayed in the search bar
143143
document.documentElement.classList.add(
144144
window.navigator.platform.includes('Mac')
145-
? "platform-mac"
145+
? "platform-mac"
146146
: "platform-win"
147147
);
148148
})();

0 commit comments

Comments
 (0)