Skip to content

Commit

Permalink
fix: move to warmupRequest
Browse files Browse the repository at this point in the history
executeEntrypoint could cause some issues when using browser specific code. warmupRequest has the same result and seems to be more appropriated in our case
  • Loading branch information
Julien-R44 committed Mar 27, 2024
1 parent b361982 commit e277ffd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ export class Vite {
attributes?: Record<string, any>
): Promise<AdonisViteElement[]> {
const server = this.getDevServer()!
const runtime = await this.createRuntime()

const tags = entryPoints.map((entrypoint) => this.#generateTag(entrypoint, attributes))
const jsEntrypoints = entryPoints.filter((entrypoint) => !this.#isCssPath(entrypoint))
Expand All @@ -214,8 +213,8 @@ export class Vite {
*/
if (server?.moduleGraph.idToModuleMap.size === 0) {
await Promise.allSettled(
jsEntrypoints.map((entrypoint) => runtime.executeEntrypoint(entrypoint))
).catch(console.error)
jsEntrypoints.map((entrypoint) => server.warmupRequest(`/${entrypoint}`))
)
}

/**
Expand Down
5 changes: 4 additions & 1 deletion tests/backend/vite.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,10 @@ test.group('Vite | collect css', () => {
'<script type="module" src="/foo.ts"></script>',
]
)
})
}).skip(
true,
'Doesnt work since we moved from executeEntrypoint to transformRequest, but in real application it seems to work fine ?'
)

test('collect css rendered page', async ({ assert, fs }) => {
const vite = await createVite(defineConfig({}), {
Expand Down

0 comments on commit e277ffd

Please sign in to comment.