Skip to content

Commit

Permalink
chore(kernel): swap @fastify/vite by @athenna/vite
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Jan 2, 2025
1 parent 3fab750 commit 383678d
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 980 deletions.
534 changes: 23 additions & 511 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/http",
"version": "5.14.0",
"version": "5.15.0",
"description": "The Athenna Http server. Built on top of fastify.",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
Expand Down Expand Up @@ -82,13 +82,13 @@
"@athenna/test": "^5.2.0",
"@athenna/tsconfig": "^5.0.0",
"@athenna/view": "^5.1.0",
"@athenna/vite": "^5.1.0",
"@fastify/cors": "^10.0.1",
"@fastify/helmet": "^13.0.0",
"@fastify/rate-limit": "^10.2.1",
"@fastify/static": "^8.0.3",
"@fastify/swagger": "^9.4.0",
"@fastify/swagger-ui": "^5.2.0",
"@fastify/vite": "^7.0.1",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"autocannon": "^7.15.0",
Expand Down
6 changes: 3 additions & 3 deletions src/kernels/HttpKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const swaggerUiPlugin = await Module.safeImport('@fastify/swagger-ui')
const rateLimitPlugin = await Module.safeImport('@fastify/rate-limit')
const staticPlugin = await Module.safeImport('@fastify/static')
const rTracerPlugin = await Module.safeImport('cls-rtracer')
const vitePlugin = await Module.safeImport('@fastify/vite')
const vitePlugin = await Module.safeImport('@athenna/vite/plugins/fastify')

export class HttpKernel {
/**
Expand Down Expand Up @@ -206,7 +206,7 @@ export class HttpKernel {
}

/**
* Register the @fastify/vite plugin in the Http server.
* Register the @athenna/vite plugin in the Http server.
*/
public async registerVite(trace?: boolean): Promise<void> {
if (trace === false) {
Expand All @@ -226,7 +226,7 @@ export class HttpKernel {
}

if (!vitePlugin) {
debug('Not able to register vite plugin. Install @fastify/vite package.')
debug('Not able to register vite plugin. Install @athenna/vite package.')

return
}
Expand Down
51 changes: 0 additions & 51 deletions src/providers/HttpServerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
* file that was distributed with this source code.
*/

import { View } from '@athenna/view'
import { Vite } from '#src/vite/index'
import { EdgeError } from 'edge-error'
import { ServiceProvider } from '@athenna/ioc'
import { ServerImpl } from '#src/server/ServerImpl'

Expand All @@ -21,54 +18,6 @@ export class HttpServerProvider extends ServiceProvider {
)
}

public boot() {
View.edge.global('vite', new Vite())
View.edge.registerTag({
tagName: 'vite',
seekable: true,
block: false,
compile(parser, buffer, token) {
/**
* Ensure an argument is defined
*/
if (!token.properties.jsArg.trim()) {
throw new EdgeError(
'Missing entrypoint name',
'E_RUNTIME_EXCEPTION',
{
filename: token.filename,
line: token.loc.start.line,
col: token.loc.start.col
}
)
}

const parsed = parser.utils.transformAst(
parser.utils.generateAST(
token.properties.jsArg,
token.loc,
token.filename
),
token.filename,
parser
)

const entrypoints = parser.utils.stringify(parsed)
const methodCall =
parsed.type === 'SequenceExpression'
? `generateEntryPointsTags${entrypoints}`
: `generateEntryPointsTags(${entrypoints})`

buffer.outputExpression(
`(await state.vite.${methodCall}).join('\\n')`,
token.filename,
token.loc.start.line,
false
)
}
})
}

public async shutdown() {
const Server = this.container.use<ServerImpl>('Athenna/Core/HttpServer')

Expand Down
77 changes: 0 additions & 77 deletions src/vite/config.ts

This file was deleted.

Loading

0 comments on commit 383678d

Please sign in to comment.