Skip to content

Commit

Permalink
fix: register edge in production
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Jun 2, 2024
1 parent 42930fb commit 2b473a8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion providers/vite_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ export default class ViteProvider {
}

async boot() {
await this.registerEdgePlugin()

if (!this.app.inDev) return

const vite = await this.app.container.make('vite')
await Promise.all([vite.createDevServer(), this.registerEdgePlugin()])
await vite.createDevServer()
}

async shutdown() {
Expand Down
29 changes: 29 additions & 0 deletions tests/backend/provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,33 @@ test.group('Inertia Provider', () => {

await app.terminate()
})

test('register edge plugin in production', async ({ assert }) => {
process.env.NODE_ENV = 'production'

const ignitor = new IgnitorFactory()
.merge({
rcFileContents: {
providers: [
() => import('../../providers/vite_provider.js'),
() => import('@adonisjs/core/providers/edge_provider'),
],
},
})
.withCoreConfig()
.withCoreProviders()
.merge({ config: { vite: defineConfig({}) } })
.create(BASE_URL, { importer: IMPORTER })

const app = ignitor.createApp('web')
await app.init()
await app.boot()

const edge = await import('edge.js')
await edge.default.renderRaw('')

assert.isDefined(edge.default.tags.vite)

await app.terminate()
})
})

0 comments on commit 2b473a8

Please sign in to comment.