fix: middleware entry point to not be set (#8036)
* fix: middleware entry point to not be set * chore: update tests
This commit is contained in:
parent
fa3e839843
commit
87d4b18437
3 changed files with 22 additions and 8 deletions
5
.changeset/rotten-flowers-know.md
Normal file
5
.changeset/rotten-flowers-know.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix a bug where the middleware entry point was passed to integrations even though the configuration `build.excludeMiddleware` was set to `false`.
|
|
@ -56,7 +56,7 @@ export function vitePluginMiddleware(
|
|||
if (chunk.type === 'asset') {
|
||||
continue;
|
||||
}
|
||||
if (chunk.fileName === 'middleware.mjs') {
|
||||
if (chunk.fileName === 'middleware.mjs' && opts.settings.config.build.excludeMiddleware) {
|
||||
internals.middlewareEntryPoint = new URL(chunkName, opts.settings.config.build.server);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,13 +118,7 @@ describe('Middleware API in PROD mode, SSR', () => {
|
|||
fixture = await loadFixture({
|
||||
root: './fixtures/middleware-dev/',
|
||||
output: 'server',
|
||||
adapter: testAdapter({
|
||||
setEntryPoints(entryPointsOrMiddleware) {
|
||||
if (entryPointsOrMiddleware instanceof URL) {
|
||||
middlewarePath = entryPointsOrMiddleware;
|
||||
}
|
||||
},
|
||||
}),
|
||||
adapter: testAdapter({}),
|
||||
});
|
||||
await fixture.build();
|
||||
});
|
||||
|
@ -218,6 +212,21 @@ describe('Middleware API in PROD mode, SSR', () => {
|
|||
});
|
||||
|
||||
it('the integration should receive the path to the middleware', async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/middleware-dev/',
|
||||
output: 'server',
|
||||
build: {
|
||||
excludeMiddleware: true,
|
||||
},
|
||||
adapter: testAdapter({
|
||||
setEntryPoints(entryPointsOrMiddleware) {
|
||||
if (entryPointsOrMiddleware instanceof URL) {
|
||||
middlewarePath = entryPointsOrMiddleware;
|
||||
}
|
||||
},
|
||||
}),
|
||||
});
|
||||
await fixture.build();
|
||||
expect(middlewarePath).to.not.be.undefined;
|
||||
try {
|
||||
const path = fileURLToPath(middlewarePath);
|
||||
|
|
Loading…
Reference in a new issue