Skip to content

Commit

Permalink
feat!: use modern type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
cyco130 committed Jul 17, 2023
1 parent 998a855 commit 80279df
Show file tree
Hide file tree
Showing 64 changed files with 830 additions and 712 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ dist

# Stores VSCode versions used for testing VSCode extensions
.vscode-test
.vscode/

# yarn v2
.yarn/cache
Expand Down
4 changes: 2 additions & 2 deletions ci/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"ci": "vitest run --reporter=verbose --no-threads"
},
"dependencies": {
"@types/node": "^18.16.19",
"@types/node": "^20.4.2",
"kill-port": "^2.0.1",
"node-fetch": "^3.3.1",
"ps-tree": "^1.2.0",
"puppeteer": "^20.8.1",
"puppeteer": "^20.8.2",
"typescript": "^5.1.6",
"vitest": "^0.33.0"
},
Expand Down
2 changes: 1 addition & 1 deletion ci/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "Node"
"moduleResolution": "Bundler"
}
}
4 changes: 2 additions & 2 deletions examples/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
],
"devDependencies": {
"@types/express": "^4.17.17",
"@types/node": "^18.16.19",
"@types/node": "^20.4.2",
"typescript": "^5.1.6",
"vavite": "1.8.3",
"vite": "^4.4.3"
"vite": "^4.4.4"
},
"dependencies": {
"express": "^4.18.2"
Expand Down
1 change: 0 additions & 1 deletion examples/express/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference types="vite/client" />

import express, { RequestHandler } from "express";
import httpDevServer from "vavite/http-dev-server";
import viteDevServer from "vavite/vite-dev-server";

const app = express();
Expand Down
2 changes: 1 addition & 1 deletion examples/express/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "Node"
"moduleResolution": "Bundler"
}
}
10 changes: 5 additions & 5 deletions examples/fastify-vite-plugin-ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
},
"dependencies": {
"@fastify/static": "^6.10.2",
"@types/node": "^18.16.19",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@types/node": "^20.4.2",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"cross-env": "^7.0.3",
"fastify": "^4.19.2",
"fastify": "^4.20.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.6",
"vavite": "1.8.3",
"vite": "^4.4.3",
"vite": "^4.4.4",
"vite-plugin-ssr": "^0.4.133"
}
}
2 changes: 1 addition & 1 deletion examples/fastify-vite-plugin-ssr/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"strict": true,
"module": "ES2020",
"moduleResolution": "Node",
"moduleResolution": "Bundler",
"target": "ES2017",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"jsx": "react",
Expand Down
2 changes: 0 additions & 2 deletions examples/fastify-vite-plugin-ssr/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/// <reference types="vavite/vite-config" />

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import ssr from "vite-plugin-ssr/plugin";
Expand Down
6 changes: 3 additions & 3 deletions examples/fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"dist"
],
"devDependencies": {
"@types/node": "^18.16.19",
"@types/node": "^20.4.2",
"typescript": "^5.1.6",
"vavite": "1.8.3",
"vite": "^4.4.3"
"vite": "^4.4.4"
},
"dependencies": {
"fastify": "^4.19.2"
"fastify": "^4.20.0"
}
}
2 changes: 1 addition & 1 deletion examples/fastify/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "Node"
"moduleResolution": "Bundler"
}
}
5 changes: 2 additions & 3 deletions examples/hapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
"dist"
],
"devDependencies": {
"@types/hapi__hapi": "^21.0.0",
"@types/node": "^18.16.19",
"@types/node": "^20.4.2",
"typescript": "^5.1.6",
"vavite": "1.8.3",
"vite": "^4.4.3"
"vite": "^4.4.4"
},
"dependencies": {
"@hapi/hapi": "^21.3.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/hapi/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "Node"
"moduleResolution": "Bundler"
}
}
4 changes: 2 additions & 2 deletions examples/koa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"devDependencies": {
"@types/koa": "^2.13.6",
"@types/koa__router": "^12.0.0",
"@types/node": "^18.16.19",
"@types/node": "^20.4.2",
"typescript": "^5.1.6",
"vavite": "1.8.3",
"vite": "^4.4.3"
"vite": "^4.4.4"
},
"dependencies": {
"@koa/router": "^12.0.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/koa/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "Node"
"moduleResolution": "Bundler"
}
}
18 changes: 9 additions & 9 deletions examples/nestjs-vite-plugin-ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
"dist"
],
"devDependencies": {
"@swc/core": "^1.3.68",
"@swc/core": "^1.3.69",
"@types/express": "^4.17.17",
"@types/node": "^18.16.19",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@types/node": "^20.4.2",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"cross-env": "^7.0.3",
"rollup-plugin-swc3": "^0.9.0",
"rollup-plugin-swc3": "^0.9.1",
"typescript": "^5.1.6",
"vavite": "1.8.3",
"vite": "^4.4.3",
"vite": "^4.4.4",
"vite-tsconfig-paths": "^4.2.0"
},
"dependencies": {
"@nestjs/common": "^10.0.5",
"@nestjs/core": "^10.0.5",
"@nestjs/platform-express": "^10.0.5",
"@nestjs/common": "^10.1.0",
"@nestjs/core": "^10.1.0",
"@nestjs/platform-express": "^10.1.0",
"@nestjs/serve-static": "^4.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { renderToPipeableStream } from "react-dom/server";
// @ts-expect-error - no types
import reactStreaming from "react-streaming/server";
import { escapeInject } from "vite-plugin-ssr/server";
import type { PageContextBuiltIn } from "vite-plugin-ssr";
Expand Down
2 changes: 1 addition & 1 deletion examples/nestjs-vite-plugin-ssr/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "Node",
"moduleResolution": "Bundler",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"jsx": "react-jsx",
Expand Down
2 changes: 0 additions & 2 deletions examples/nestjs-vite-plugin-ssr/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/// <reference types="vavite/vite-config" />

import { defineConfig } from "vite";
import vavite from "vavite";
import { swc } from "rollup-plugin-swc3";
Expand Down
14 changes: 7 additions & 7 deletions examples/nestjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
"dist"
],
"devDependencies": {
"@swc/core": "^1.3.68",
"@swc/core": "^1.3.69",
"@types/express": "^4.17.17",
"@types/node": "^18.16.19",
"rollup-plugin-swc3": "^0.9.0",
"@types/node": "^20.4.2",
"rollup-plugin-swc3": "^0.9.1",
"typescript": "^5.1.6",
"vavite": "1.8.3",
"vite": "^4.4.3"
"vite": "^4.4.4"
},
"dependencies": {
"@nestjs/common": "^10.0.5",
"@nestjs/core": "^10.0.5",
"@nestjs/platform-express": "^10.0.5",
"@nestjs/common": "^10.1.0",
"@nestjs/core": "^10.1.0",
"@nestjs/platform-express": "^10.1.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/nestjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "Node",
"moduleResolution": "Bundler",
"experimentalDecorators": true,
"types": ["vite/client"]
}
Expand Down
4 changes: 2 additions & 2 deletions examples/simple-standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"build": "vite build --ssr --mode=production"
},
"devDependencies": {
"@types/node": "^18.16.19",
"@types/node": "^20.4.2",
"typescript": "^5.1.6",
"vavite": "1.8.3",
"vite": "^4.4.3"
"vite": "^4.4.4"
}
}
2 changes: 1 addition & 1 deletion examples/simple-standalone/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "Node"
"moduleResolution": "Bundler"
}
}
4 changes: 2 additions & 2 deletions examples/socket-io/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
],
"devDependencies": {
"@types/express": "^4.17.17",
"@types/node": "^18.16.19",
"@types/node": "^20.4.2",
"typescript": "^5.1.6",
"vavite": "1.8.3",
"vite": "^4.4.3"
"vite": "^4.4.4"
},
"dependencies": {
"express": "^4.18.2",
Expand Down
54 changes: 35 additions & 19 deletions examples/socket-io/server.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
/// <reference types="vite/client" />

import express, { RequestHandler } from "express";
import httpDevServer from "vavite/http-dev-server";
import viteDevServer from "vavite/vite-dev-server";
import { Server } from "socket.io";
import express from "express";
import { Server as SocketIOServer } from "socket.io";
import type {} from "node:http";
import type {} from "node:net";

declare module "node:net" {
interface Socket {
server: import("node:http").Server;
}
}

declare module "node:http" {
interface Server {
io?: SocketIOServer;
}
}

const app = express();
const io = new Server();

let io: SocketIOServer;

app.use((req, res, next) => {
if (!io || io !== req.socket.server.io) {
req.socket.server.io?.close();

io = req.socket.server.io = new SocketIOServer(req.socket.server);

io.on("connection", (socket) => {
socket.on("chat message", (msg) => {
io.emit("chat message", msg);
});
});
}

next();
});

app.get("/", async (req, res) => {
res.sendFile(process.cwd() + "/view.html");
});

if (httpDevServer) {
httpDevServer.on("request", app);
io.attach(viteDevServer.httpServer!);
} else {
console.log("Starting prod server");
const server = app.listen(3000);
io.attach(server);
}

io.on("connection", (socket) => {
socket.on("chat message", (msg) => {
io.emit("chat message", msg);
});
});
export default app;
2 changes: 1 addition & 1 deletion examples/socket-io/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "Node"
"moduleResolution": "Bundler"
}
}
2 changes: 1 addition & 1 deletion examples/socket-io/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import vavite from "vavite";
export default defineConfig({
plugins: [
vavite({
serverEntry: "/server.ts",
handlerEntry: "/server.ts",
reloadOn: "static-deps-change",
}),
],
Expand Down
8 changes: 4 additions & 4 deletions examples/ssr-react-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
},
"devDependencies": {
"@types/express": "^4.17.17",
"@types/node": "^18.16.19",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@types/node": "^20.4.2",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"typescript": "^5.1.6",
"vavite": "1.8.3",
"vite": "^4.4.3"
"vite": "^4.4.4"
},
"dependencies": {
"express": "^4.18.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr-react-express/server-entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function render(req: Request, res: Response, importer: PageImporter) {
clientEntryPath = "/client-entry.tsx";
} else {
// In production we'll figure out the path to the client entry file using the manifest
// @ts-expect-error: This only exists after the client build is complete
// @ts-ignore: This only exists after the client build is complete
const manifest = (await import("./dist/client/manifest.json")).default;
clientEntryPath = manifest["client-entry.tsx"].file;

Expand Down
Loading

0 comments on commit 80279df

Please sign in to comment.