Skip to content

Commit

Permalink
update refresh package
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWangJustToDo committed May 6, 2024
1 parent 91b1f25 commit c5d9fd3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 9 deletions.
18 changes: 18 additions & 0 deletions packages/myreact-refresh/src/RefreshBabelPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,24 @@ export default function (babel, opts: Record<string, any> = {}) {
case "React.useImperativeHandle":
case "useDebugValue":
case "React.useDebugValue":
case "useId":
case "React.useId":
case "useDeferredValue":
case "React.useDeferredValue":
case "useTransition":
case "React.useTransition":
case "useInsertionEffect":
case "React.useInsertionEffect":
case "useSyncExternalStore":
case "React.useSyncExternalStore":
case "useFormStatus":
case "React.useFormStatus":
case "useFormState":
case "React.useFormState":
case "useActionState":
case "React.useActionState":
case "useOptimistic":
case "React.useOptimistic":
return true;
default:
return false;
Expand Down
22 changes: 19 additions & 3 deletions ui/next-example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -15,7 +19,19 @@
"jsx": "preserve",
"baseUrl": ".",
"incremental": true,
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
9 changes: 7 additions & 2 deletions ui/ssr-example/build/scripts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import LoadablePlugin from "@loadable/webpack-plugin";
import RefreshWebpackPlugin from "@my-react/react-refresh-tools/RefreshWebpackPlugin";
import ReactRefreshPlugin from "@pmmmwh/react-refresh-webpack-plugin";
import { MANIFEST, definedWebpackConfig, WebpackNodeExternals } from "@site/webpack";
import dayjs from "dayjs";
import { resolve } from "path";
import { DefinePlugin, HotModuleReplacementPlugin } from "webpack";

require("dayjs/locale/zh-cn");

dayjs.locale("zh-cn");

export const getConfig = () => {
const multiConfig = definedWebpackConfig({
serverEntry: process.env.SERVER_ENTRY!,
Expand All @@ -26,7 +31,7 @@ export const getConfig = () => {
__BASENAME__: JSON.stringify(process.env.BASENAME || ""),
__BUNDLE_SCOPE__: JSON.stringify(BUNDLE_SCOPE),
__OUTPUT_SCOPE__: JSON.stringify(OUTPUT_SCOPE),
__BUILD_TIME__: JSON.stringify(new Date().toLocaleString()),
__BUILD_TIME__: JSON.stringify(dayjs().toString()),
}),
isDEV && (isReact ? new ReactRefreshPlugin() : new RefreshWebpackPlugin()),
isDEV && isMIDDLEWARE && new HotModuleReplacementPlugin(),
Expand Down Expand Up @@ -71,7 +76,7 @@ export const getConfig = () => {
__BASENAME__: JSON.stringify(process.env.BASENAME || ""),
__BUNDLE_SCOPE__: JSON.stringify(BUNDLE_SCOPE),
__OUTPUT_SCOPE__: JSON.stringify(OUTPUT_SCOPE),
__BUILD_TIME__: JSON.stringify(new Date().toLocaleString()),
__BUILD_TIME__: JSON.stringify(dayjs().toString()),
}),
isDEV && !isMIDDLEWARE && new HotModuleReplacementPlugin(),
].filter(Boolean);
Expand Down
4 changes: 2 additions & 2 deletions ui/ssr-example/src/client/container/Section/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { enableMockReact } = __my_react_shared__;
const tsxMd = `
\`\`\`tsx
import { useState, useCallback } from '@my-react/react';
import { render } from '@my-react/react-dom';
import { createRoot } from '@my-react/react-dom';
/**
* hello world
Expand All @@ -38,7 +38,7 @@ const App = () => {
</div>
}
render(<App />, document.querySelector('#root'));
createRoot(document.querySelector('#root')).render(<App />);
\`\`\`
`;

Expand Down
4 changes: 2 additions & 2 deletions ui/ssr-example/src/shared/template/Head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export const Head = ({ env = "{}", link = [], preLoad = [], preloadedState = "{}
<meta name="author" content="MrWangJustToDo" />
<meta
name="description"
content="@my-react is a React like package, it can be used to build a modern website just like this, feel free to use and fire a issue if you have! link: https://github.com/MrWangJustToDo/MyReact"
content="@my-react is a React like framework, it can be used to build a modern website just like this, feel free to use and fire a issue if you have! link: https://github.com/MrWangJustToDo/MyReact"
/>
<meta name="keywords" content="react, react-dom, ssr, csr, ssg" />
<meta name="keywords" content="react, react-dom, ssr, csr, ssg, @my-react, react like, react framework" />
<base href={noBase ? "/" : `/${__BASENAME__}/`} />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
Expand Down

0 comments on commit c5d9fd3

Please sign in to comment.