-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support TS/JSX inside node_modules
- Loading branch information
1 parent
6be7e50
commit 4b9b2d5
Showing
15 changed files
with
321 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 |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
node_modules/ | ||
dist/ | ||
playground-temp/ | ||
test-results/ | ||
.swc/ |
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,24 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { setupDevServer, setupBuildAndPreview } from "../../utils.ts"; | ||
|
||
test("TS lib build", async ({ page }) => { | ||
const { testUrl, server } = await setupBuildAndPreview("ts-lib"); | ||
await page.goto(testUrl); | ||
await expect(page.locator("main")).toHaveText("Home page"); | ||
|
||
await page.locator("a", { hasText: "About" }).click(); | ||
await expect(page.locator("main")).toHaveText("About page"); | ||
|
||
await server.httpServer.close(); | ||
}); | ||
|
||
test("TS lib dev", async ({ page }) => { | ||
const { testUrl, server } = await setupDevServer("ts-lib"); | ||
await page.goto(testUrl); | ||
await expect(page.locator("main")).toHaveText("Home page"); | ||
|
||
await page.locator("a", { hasText: "About" }).click(); | ||
await expect(page.locator("main")).toHaveText("About page"); | ||
|
||
await server.close(); | ||
}); |
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" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + React + TS lib</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" 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,22 @@ | ||
{ | ||
"name": "playground-ts-lib", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@generouted/react-router": "^1.11.7", | ||
"generouted": "^1.11.7", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-router-dom": "^6.9.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.0.29", | ||
"@types/react-dom": "^18.0.11", | ||
"@vitejs/plugin-react-swc": "../../dist" | ||
} | ||
} |
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,9 @@ | ||
import { StrictMode } from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
import { Routes } from "generouted/react-router"; | ||
|
||
createRoot(document.getElementById("root")!).render( | ||
<StrictMode> | ||
<Routes /> | ||
</StrictMode>, | ||
); |
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,3 @@ | ||
export default function NotFound() { | ||
return <h1>404</h1> | ||
} |
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 @@ | ||
import { Link, Outlet } from "react-router-dom"; | ||
|
||
export default function App() { | ||
return ( | ||
<section style={{ margin: 24 }}> | ||
<header style={{ display: "flex", gap: 24 }}> | ||
<Link to="/">Home</Link> | ||
<Link to="/about">About</Link> | ||
</header> | ||
|
||
<main> | ||
<Outlet /> | ||
</main> | ||
</section> | ||
); | ||
} |
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,3 @@ | ||
export default function About() { | ||
return <h1>About page</h1>; | ||
} |
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,10 @@ | ||
import { Outlet } from "react-router-dom"; | ||
|
||
export default function Home() { | ||
return ( | ||
<div> | ||
<h1>Home page</h1> | ||
<Outlet /> | ||
</div> | ||
); | ||
} |
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 @@ | ||
{ | ||
"include": ["src", "vite.config.ts"], | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"lib": ["ESNext", "DOM", "DOM.Iterable"], | ||
"target": "ESNext", | ||
"jsx": "react-jsx", | ||
"types": ["vite/client"], | ||
"noEmit": true, | ||
"isolatedModules": true, | ||
"skipLibCheck": true, | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"resolveJsonModule": true, | ||
"noUncheckedIndexedAccess": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
|
||
/* Linting */ | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"useUnknownInCatchVariables": true | ||
} | ||
} |
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,7 @@ | ||
import { defineConfig } from "vite"; | ||
import react from "@vitejs/plugin-react-swc"; | ||
|
||
export default defineConfig({ | ||
optimizeDeps: { include: ["react-router-dom"] }, | ||
plugins: [react()], | ||
}); |
Oops, something went wrong.