-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: encode the lazy compile path (#1276)
* fix: serialize the lazy-loaded path. * chore: add changeset * fix: deps * fix: error --------- Co-authored-by: brightwu <[email protected]>
- Loading branch information
Showing
19 changed files
with
375 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@farmfe/core': patch | ||
--- | ||
|
||
fix: encode the lazy compile path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
registry = "https://registry.npmjs.org/" | ||
auto-install-peers = false | ||
auto-install-peers = false | ||
electron-mirror="https://npmmirror.com/mirrors/electron/" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# adapter vite-plugin-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineConfig } from '@farmfe/core'; | ||
import Pages from 'vite-plugin-pages'; | ||
|
||
export default defineConfig({ | ||
plugins: ['@farmfe/plugin-react'], | ||
compilation:{ | ||
persistentCache:false, | ||
}, | ||
vitePlugins:[ | ||
Pages({ | ||
resolver:'react' | ||
}), | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script src="./src/index.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "@farmfe-examples/react-query", | ||
"version": "1.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"core-js": "^3.36.1", | ||
"react": "18", | ||
"react-dom": "18", | ||
"react-router": "^6.22.3", | ||
"react-router-dom": "^6.22.3", | ||
"@tanstack/react-query": "^5.32.0" | ||
}, | ||
"devDependencies": { | ||
"@farmfe/cli": "workspace:*", | ||
"@farmfe/core": "workspace:*", | ||
"@farmfe/plugin-react": "^1.0.1", | ||
"@types/react": "18", | ||
"@types/react-dom": "18", | ||
"react-refresh": "^0.14.0", | ||
"vite-plugin-pages": "^0.32.0", | ||
"@tanstack/react-query-devtools": "^5.32.0" | ||
}, | ||
"scripts": { | ||
"dev": "farm start", | ||
"start": "farm start", | ||
"build": "farm build", | ||
"preview": "farm preview" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
:root { | ||
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; | ||
line-height: 1.5; | ||
font-weight: 400; | ||
|
||
color-scheme: light dark; | ||
color: rgba(255, 255, 255, 0.87); | ||
background-color: #242424; | ||
|
||
font-synthesis: none; | ||
text-rendering: optimizeLegibility; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
-webkit-text-size-adjust: 100%; | ||
} | ||
|
||
a { | ||
font-weight: 500; | ||
color: #9f1a8f; | ||
text-decoration: inherit; | ||
} | ||
a:hover { | ||
color: #9f1a8f; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
display: flex; | ||
place-items: center; | ||
min-width: 320px; | ||
min-height: 100vh; | ||
} | ||
|
||
h1 { | ||
font-size: 3.2em; | ||
line-height: 1.1; | ||
} | ||
|
||
button { | ||
border-radius: 8px; | ||
border: 1px solid transparent; | ||
padding: 0.6em 1.2em; | ||
font-size: 1em; | ||
font-weight: 500; | ||
font-family: inherit; | ||
background-color: #1a1a1a; | ||
cursor: pointer; | ||
transition: border-color 0.25s; | ||
} | ||
button:hover { | ||
border-color: #9f1a8f; | ||
} | ||
button:focus, | ||
button:focus-visible { | ||
outline: 4px auto -webkit-focus-ring-color; | ||
} | ||
|
||
@media (prefers-color-scheme: light) { | ||
:root { | ||
color: #213547; | ||
background-color: #ffffff; | ||
} | ||
a:hover { | ||
color: #9F1A8F; | ||
} | ||
button { | ||
background-color: #f9f9f9; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { Suspense } from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import { BrowserRouter as Router, useRoutes } from 'react-router-dom'; | ||
import './index.css'; | ||
import routes from '~react-pages'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
const container = document.querySelector('#root'); | ||
const root = createRoot(container); | ||
|
||
function App() { | ||
return <Suspense fallback={<p>Loading...</p>}>{useRoutes(routes)}</Suspense>; | ||
} | ||
|
||
root.render( | ||
<QueryClientProvider client={queryClient}> | ||
{/* <ReactQueryDevtools initialIsOpen={true} /> */} | ||
<Router> | ||
<App /> | ||
</Router> | ||
</QueryClientProvider> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
const Main = () => { | ||
return <div> | ||
this is about page | ||
</div>; | ||
}; | ||
|
||
export default Main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import FarmLogo from '../assets/logo.png'; | ||
import reactLogo from '../assets/react.svg'; | ||
import './main.css'; | ||
|
||
export default function () { | ||
const [count, setCount] = useState(0); | ||
const go = useNavigate(); | ||
|
||
return ( | ||
<> | ||
<div> | ||
<a href="https://farmfe.org/" target="_blank" rel="noreferrer"> | ||
<img src={FarmLogo} className="logo" alt="Farm logo" /> | ||
</a> | ||
<a href="https://react.dev" target="_blank" rel="noreferrer"> | ||
<img src={reactLogo} className="logo react" alt="React logo" /> | ||
</a> | ||
</div> | ||
<h1>Farm + React</h1> | ||
<div className="card"> | ||
<button onClick={() => setCount((count) => count + 1)}>count is {count}</button> | ||
<p> | ||
Edit <code>src/main.tsx</code> and save to test HMR | ||
</p> | ||
</div> | ||
<p className="read-the-docs" onClick={() => go('/about')}> | ||
Go to about page | ||
</p> | ||
</> | ||
); | ||
} | ||
// export default Index; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#root { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
|
||
.logo { | ||
height: 6em; | ||
padding: 1.5em; | ||
will-change: filter; | ||
transition: filter 300ms; | ||
} | ||
.logo:hover { | ||
filter: drop-shadow(0 0 2em #9F1A8Faa); | ||
} | ||
.logo.react:hover { | ||
filter: drop-shadow(0 0 2em #61dafbaa); | ||
} | ||
|
||
@keyframes logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
a:nth-of-type(2) .logo { | ||
animation: logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.card { | ||
padding: 2em; | ||
} | ||
|
||
.read-the-docs { | ||
color: #888; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
declare module '*.svg'; | ||
declare module '*.png'; | ||
declare module '*.css'; | ||
declare module '~react-pages' { | ||
import type { RouteObject } from 'react-router' | ||
|
||
const routes: RouteObject[] | ||
export default routes | ||
} | ||
|
||
declare module 'virtual:generated-pages-react' { | ||
import type { RouteObject } from 'react-router' | ||
|
||
const routes: RouteObject[] | ||
export default routes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["DOM", "ES2017"], | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"jsx": "react", | ||
"skipDefaultLibCheck": true, | ||
"skipLibCheck": true | ||
}, | ||
"include": ["src"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.