Skip to content

Commit

Permalink
v4
Browse files Browse the repository at this point in the history
- add vite 5 support
  • Loading branch information
axe-me committed Oct 9, 2024
1 parent b9ff47f commit 5cc5a32
Show file tree
Hide file tree
Showing 38 changed files with 630 additions and 647 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 4.0.0
- update vite to 5.x

## 3.1.0
- add `initAppOnBoot` option, when set to true, the app will be initialized on vite server boot.

Expand Down
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,6 @@
swcOptions: {}
})
],
optimizeDeps: {
// Vite does not work well with optionnal dependencies,
// you can mark them as ignored for now
// eg: for nestjs, exlude these optional dependencies:
// exclude: [
// '@nestjs/microservices',
// '@nestjs/websockets',
// 'cache-manager',
// 'class-transformer',
// 'class-validator',
// 'fastify-swagger',
// ],
},
});
```

Expand Down
4 changes: 2 additions & 2 deletions examples/apollo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"devDependencies": {
"@types/cors": "^2.8.13",
"vite": "^4.0.4",
"vite": "^5.0.0",
"vite-plugin-node": "workspace:*"
}
}
}
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/cloudfunction/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"devDependencies": {
"@swc/core": "^1.2.155",
"vite": "^4.0.4",
"vite": "^5.0.0",
"vite-plugin-node": "workspace:*"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import { defineConfig } from 'vite';
import { VitePluginNode } from 'vite-plugin-node';

export default defineConfig({
ssr: {
format: 'cjs',
},
server: {
port: 3699,
},
plugins: [
...VitePluginNode({
adapter: 'express',
appPath: './app.ts',
tsCompiler: 'swc',
}),
],
});
4 changes: 2 additions & 2 deletions examples/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"express": "^4.17.1"
},
"devDependencies": {
"vite": "^4.0.4",
"vite": "^5.0.0",
"vite-plugin-node": "workspace:*"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { VitePluginNode } from 'vite-plugin-node';

export default defineConfig({
server: {
port: 3699
port: 3699,
},
plugins: [
...VitePluginNode({
adapter: 'express',
appPath: './app.ts',
tsCompiler: 'swc'
})
]
}),
],
});
2 changes: 1 addition & 1 deletion examples/fastify/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const app = async () => {
const app = fastify();

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

app.get('/ping', (req, reply) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"fastify": "^3.27.1"
},
"devDependencies": {
"vite": "^4.0.4",
"vite": "^5.0.0",
"vite-plugin-node": "workspace:*"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
plugins: [
...VitePluginNode({
adapter: 'fastify',
appPath: './app.ts'
})
]
appPath: './app.ts',
}),
],
});
2 changes: 1 addition & 1 deletion examples/initAppOnBoot/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import express from 'express';
const app = express();

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

app.get('/ip', async (req, res) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/initAppOnBoot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"express": "^4.17.1"
},
"devDependencies": {
"vite": "^4.5.0",
"vite": "^5.0.0",
"vite-plugin-node": "workspace:*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { defineConfig } from 'vite';
import { VitePluginNode } from 'vite-plugin-node';

export default defineConfig({
server: {
port: 3699
},
plugins: [
...VitePluginNode({
adapter: 'express',
appPath: './app.ts'
})
]
appPath: './app.ts',
initAppOnBoot: true,
}),
],
});
2 changes: 1 addition & 1 deletion examples/koa/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Koa from 'koa';
const app = new Koa();

app.use(async (ctx) => {
ctx.body = 'Change Me and Refresh to see HMR!';
ctx.body = 'Change Me and Refresh to see HMR!!';
});

if (import.meta.env.PROD) {
Expand Down
4 changes: 2 additions & 2 deletions examples/koa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"koa": "^2.13.3"
},
"devDependencies": {
"vite": "^4.0.4",
"vite": "^5.0.0",
"vite-plugin-node": "workspace:*"
}
}
}
6 changes: 3 additions & 3 deletions examples/koa/vite.config.ts → examples/koa/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
plugins: [
...VitePluginNode({
adapter: 'koa',
appPath: './app.ts'
})
]
appPath: './app.ts',
}),
],
});
19 changes: 8 additions & 11 deletions examples/marble/app.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,39 @@
import * as T from 'fp-ts/lib/Task';
import { pipe } from 'fp-ts/lib/function';
import { createServer, httpListener } from '@marblejs/http';
import { isTestEnv, getPortEnv } from '@marblejs/core/dist/+internal/utils';
import { createServer, httpListener, r } from '@marblejs/http';
import { logger$ } from '@marblejs/middleware-logger';
import { bodyParser$ } from '@marblejs/middleware-body';
import { r } from '@marblejs/http';
import { mapTo } from 'rxjs/operators';
import { reader } from '@marblejs/core';

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

export const api$ = r.pipe(
r.matchPath('/'),
r.matchType('GET'),
r.useEffect((req$) =>
req$.pipe(mapTo({ body: 'change me to see updates, express, hmr' }))
)
r.useEffect(req$ =>
req$.pipe(mapTo({ body: 'change me to see updates, marble, hmr' })),
),
);

const effects = [api$];

export const listener = httpListener({
middlewares,
effects
effects,
});

export const server = () =>
createServer({
port: 3000,
listener
listener,
});

if (import.meta.env.PROD) {
const main = pipe(
server,
T.map((run) => run())
T.map(run => run()),
);
main();
}

export const viteNodeApp = { server: server(), listener: listener };
export const viteNodeApp = { server: server(), listener };
6 changes: 3 additions & 3 deletions examples/marble/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"typescript": "^4.3.2"
},
"devDependencies": {
"@types/node": "14",
"vite": "^4.0.4",
"@types/node": "^18.19.55",
"vite": "^5.0.0",
"vite-plugin-node": "workspace:*"
}
}
}
6 changes: 0 additions & 6 deletions examples/marble/tsconfig.json

This file was deleted.

11 changes: 11 additions & 0 deletions examples/marble/vite.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'vite';
import { VitePluginNode } from 'vite-plugin-node';

export default defineConfig({
plugins: [
...VitePluginNode({
adapter: 'marble',
appPath: './app.ts',
}),
],
});
19 changes: 0 additions & 19 deletions examples/marble/vite.config.ts

This file was deleted.

8 changes: 4 additions & 4 deletions examples/nest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"@nestjs/cli": "^8.0.0",
"@nestjs/schematics": "^8.0.0",
"@nestjs/testing": "^8.0.0",
"@swc/core": "^1.2.155",
"@swc/core": "^1.7.26",
"@types/express": "^4.17.13",
"@types/jest": "^26.0.24",
"@types/node": "^16.0.0",
"@types/node": "^18.19.55",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
Expand All @@ -49,7 +49,7 @@
"ts-node": "^10.0.0",
"tsconfig-paths": "^3.10.1",
"typescript": "^4.3.5",
"vite": "^4.0.4",
"vite": "^5.0.0",
"vite-plugin-node": "workspace:*"
},
"jest": {
Expand All @@ -69,4 +69,4 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
}
2 changes: 1 addition & 1 deletion examples/nest/src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { str } from './str';
@Injectable()
export class AppService {
getHello(): string {
return `change me to see updates! ${str} from a new file,..`;
return `change me to see updates! ${str} from a new file,..!`;
}
}
12 changes: 12 additions & 0 deletions examples/nest/vite.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from 'vite';
import { VitePluginNode } from 'vite-plugin-node';

export default defineConfig({
plugins: [
...VitePluginNode({
adapter: 'nest',
appPath: './src/main.ts',
tsCompiler: 'swc',
}),
],
});
24 changes: 0 additions & 24 deletions examples/nest/vite.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion examples/node/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import http from 'http';

const requestListener: http.RequestListener = (req, res) => {
res.writeHead(200);
res.end('raw node server!~');
res.end('raw node server!~!');
};

if (import.meta.env.PROD) {
Expand Down
4 changes: 2 additions & 2 deletions examples/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "vite build"
},
"devDependencies": {
"vite": "^4.0.4",
"vite": "^5.0.0",
"vite-plugin-node": "workspace:*"
}
}
}
Loading

0 comments on commit 5cc5a32

Please sign in to comment.