Skip to content

Commit 5cc5a32

Browse files
committed
v4
- add vite 5 support
1 parent b9ff47f commit 5cc5a32

38 files changed

+630
-647
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 4.0.0
4+
- update vite to 5.x
5+
36
## 3.1.0
47
- add `initAppOnBoot` option, when set to true, the app will be initialized on vite server boot.
58

README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,6 @@
8383
swcOptions: {}
8484
})
8585
],
86-
optimizeDeps: {
87-
// Vite does not work well with optionnal dependencies,
88-
// you can mark them as ignored for now
89-
// eg: for nestjs, exlude these optional dependencies:
90-
// exclude: [
91-
// '@nestjs/microservices',
92-
// '@nestjs/websockets',
93-
// 'cache-manager',
94-
// 'class-transformer',
95-
// 'class-validator',
96-
// 'fastify-swagger',
97-
// ],
98-
},
9986
});
10087
```
10188

examples/apollo/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"devDependencies": {
1818
"@types/cors": "^2.8.13",
19-
"vite": "^4.0.4",
19+
"vite": "^5.0.0",
2020
"vite-plugin-node": "workspace:*"
2121
}
22-
}
22+
}
File renamed without changes.

examples/cloudfunction/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"devDependencies": {
1616
"@swc/core": "^1.2.155",
17-
"vite": "^4.0.4",
17+
"vite": "^5.0.0",
1818
"vite-plugin-node": "workspace:*"
1919
}
20-
}
20+
}

examples/express/vite.config.ts renamed to examples/cloudfunction/vite.config.mts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ import { defineConfig } from 'vite';
22
import { VitePluginNode } from 'vite-plugin-node';
33

44
export default defineConfig({
5-
ssr: {
6-
format: 'cjs',
7-
},
85
server: {
96
port: 3699,
107
},
118
plugins: [
129
...VitePluginNode({
1310
adapter: 'express',
1411
appPath: './app.ts',
12+
tsCompiler: 'swc',
1513
}),
1614
],
1715
});

examples/express/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"express": "^4.17.1"
1414
},
1515
"devDependencies": {
16-
"vite": "^4.0.4",
16+
"vite": "^5.0.0",
1717
"vite-plugin-node": "workspace:*"
1818
}
19-
}
19+
}

examples/cloudfunction/vite.config.ts renamed to examples/express/vite.config.mts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import { VitePluginNode } from 'vite-plugin-node';
33

44
export default defineConfig({
55
server: {
6-
port: 3699
6+
port: 3699,
77
},
88
plugins: [
99
...VitePluginNode({
1010
adapter: 'express',
1111
appPath: './app.ts',
12-
tsCompiler: 'swc'
13-
})
14-
]
12+
}),
13+
],
1514
});

examples/fastify/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const app = async () => {
44
const app = fastify();
55

66
app.get('/', (req, reply) => {
7-
reply.send('change me to see updates, fastify!~');
7+
reply.send('change me to see updates, fastify!~~');
88
});
99

1010
app.get('/ping', (req, reply) => {

examples/fastify/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"fastify": "^3.27.1"
1212
},
1313
"devDependencies": {
14-
"vite": "^4.0.4",
14+
"vite": "^5.0.0",
1515
"vite-plugin-node": "workspace:*"
1616
}
17-
}
17+
}

examples/fastify/vite.config.ts renamed to examples/fastify/vite.config.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default defineConfig({
55
plugins: [
66
...VitePluginNode({
77
adapter: 'fastify',
8-
appPath: './app.ts'
9-
})
10-
]
8+
appPath: './app.ts',
9+
}),
10+
],
1111
});

examples/initAppOnBoot/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import express from 'express';
33
const app = express();
44

55
app.get('/', (req, res) => {
6-
res.send('change me to see updates, express~!');
6+
res.send('change me to see updates, express~!!');
77
});
88

99
app.get('/ip', async (req, res) => {

examples/initAppOnBoot/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"express": "^4.17.1"
1414
},
1515
"devDependencies": {
16-
"vite": "^4.5.0",
16+
"vite": "^5.0.0",
1717
"vite-plugin-node": "workspace:*"
1818
}
1919
}

examples/node/vite.config.ts renamed to examples/initAppOnBoot/vite.config.mts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import { defineConfig } from 'vite';
22
import { VitePluginNode } from 'vite-plugin-node';
33

44
export default defineConfig({
5-
server: {
6-
port: 3699
7-
},
85
plugins: [
96
...VitePluginNode({
107
adapter: 'express',
11-
appPath: './app.ts'
12-
})
13-
]
8+
appPath: './app.ts',
9+
initAppOnBoot: true,
10+
}),
11+
],
1412
});

examples/koa/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Koa from 'koa';
33
const app = new Koa();
44

55
app.use(async (ctx) => {
6-
ctx.body = 'Change Me and Refresh to see HMR!';
6+
ctx.body = 'Change Me and Refresh to see HMR!!';
77
});
88

99
if (import.meta.env.PROD) {

examples/koa/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"koa": "^2.13.3"
1212
},
1313
"devDependencies": {
14-
"vite": "^4.0.4",
14+
"vite": "^5.0.0",
1515
"vite-plugin-node": "workspace:*"
1616
}
17-
}
17+
}

examples/koa/vite.config.ts renamed to examples/koa/vite.config.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default defineConfig({
55
plugins: [
66
...VitePluginNode({
77
adapter: 'koa',
8-
appPath: './app.ts'
9-
})
10-
]
8+
appPath: './app.ts',
9+
}),
10+
],
1111
});

examples/marble/app.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,39 @@
11
import * as T from 'fp-ts/lib/Task';
22
import { pipe } from 'fp-ts/lib/function';
3-
import { createServer, httpListener } from '@marblejs/http';
4-
import { isTestEnv, getPortEnv } from '@marblejs/core/dist/+internal/utils';
3+
import { createServer, httpListener, r } from '@marblejs/http';
54
import { logger$ } from '@marblejs/middleware-logger';
65
import { bodyParser$ } from '@marblejs/middleware-body';
7-
import { r } from '@marblejs/http';
86
import { mapTo } from 'rxjs/operators';
9-
import { reader } from '@marblejs/core';
107

118
const middlewares = [logger$(), bodyParser$()];
129

1310
export const api$ = r.pipe(
1411
r.matchPath('/'),
1512
r.matchType('GET'),
16-
r.useEffect((req$) =>
17-
req$.pipe(mapTo({ body: 'change me to see updates, express, hmr' }))
18-
)
13+
r.useEffect(req$ =>
14+
req$.pipe(mapTo({ body: 'change me to see updates, marble, hmr' })),
15+
),
1916
);
2017

2118
const effects = [api$];
2219

2320
export const listener = httpListener({
2421
middlewares,
25-
effects
22+
effects,
2623
});
2724

2825
export const server = () =>
2926
createServer({
3027
port: 3000,
31-
listener
28+
listener,
3229
});
3330

3431
if (import.meta.env.PROD) {
3532
const main = pipe(
3633
server,
37-
T.map((run) => run())
34+
T.map(run => run()),
3835
);
3936
main();
4037
}
4138

42-
export const viteNodeApp = { server: server(), listener: listener };
39+
export const viteNodeApp = { server: server(), listener };

examples/marble/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"typescript": "^4.3.2"
2525
},
2626
"devDependencies": {
27-
"@types/node": "14",
28-
"vite": "^4.0.4",
27+
"@types/node": "^18.19.55",
28+
"vite": "^5.0.0",
2929
"vite-plugin-node": "workspace:*"
3030
}
31-
}
31+
}

examples/marble/tsconfig.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/marble/vite.config.mts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from 'vite';
2+
import { VitePluginNode } from 'vite-plugin-node';
3+
4+
export default defineConfig({
5+
plugins: [
6+
...VitePluginNode({
7+
adapter: 'marble',
8+
appPath: './app.ts',
9+
}),
10+
],
11+
});

examples/marble/vite.config.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

examples/nest/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
"@nestjs/cli": "^8.0.0",
3434
"@nestjs/schematics": "^8.0.0",
3535
"@nestjs/testing": "^8.0.0",
36-
"@swc/core": "^1.2.155",
36+
"@swc/core": "^1.7.26",
3737
"@types/express": "^4.17.13",
3838
"@types/jest": "^26.0.24",
39-
"@types/node": "^16.0.0",
39+
"@types/node": "^18.19.55",
4040
"@types/supertest": "^2.0.11",
4141
"@typescript-eslint/eslint-plugin": "^5.23.0",
4242
"@typescript-eslint/parser": "^5.23.0",
@@ -49,7 +49,7 @@
4949
"ts-node": "^10.0.0",
5050
"tsconfig-paths": "^3.10.1",
5151
"typescript": "^4.3.5",
52-
"vite": "^4.0.4",
52+
"vite": "^5.0.0",
5353
"vite-plugin-node": "workspace:*"
5454
},
5555
"jest": {
@@ -69,4 +69,4 @@
6969
"coverageDirectory": "../coverage",
7070
"testEnvironment": "node"
7171
}
72-
}
72+
}

examples/nest/src/app.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import { str } from './str';
44
@Injectable()
55
export class AppService {
66
getHello(): string {
7-
return `change me to see updates! ${str} from a new file,..`;
7+
return `change me to see updates! ${str} from a new file,..!`;
88
}
99
}

examples/nest/vite.config.mts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from 'vite';
2+
import { VitePluginNode } from 'vite-plugin-node';
3+
4+
export default defineConfig({
5+
plugins: [
6+
...VitePluginNode({
7+
adapter: 'nest',
8+
appPath: './src/main.ts',
9+
tsCompiler: 'swc',
10+
}),
11+
],
12+
});

examples/nest/vite.config.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

examples/node/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import http from 'http';
22

33
const requestListener: http.RequestListener = (req, res) => {
44
res.writeHead(200);
5-
res.end('raw node server!~');
5+
res.end('raw node server!~!');
66
};
77

88
if (import.meta.env.PROD) {

examples/node/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"build": "vite build"
1010
},
1111
"devDependencies": {
12-
"vite": "^4.0.4",
12+
"vite": "^5.0.0",
1313
"vite-plugin-node": "workspace:*"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)