Skip to content

Commit

Permalink
fix: exclude image endpoint from being bundled
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Aug 14, 2023
1 parent 39515af commit ba4ed10
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/astro/src/core/build/plugins/plugin-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isServerLikeOutput } from '../../../prerender/utils.js';
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../../vite-plugin-scripts/index.js';
import type { SerializedRouteInfo, SerializedSSRManifest } from '../../app/types';
import { joinPaths, prependForwardSlash } from '../../path.js';
import { routeIsRedirect } from '../../redirects/index.js';
import { routeIsRedirect, routeIsAstroAssets } from '../../redirects/index.js';
import { serializeRouteData } from '../../routing/index.js';
import { addRollupInput } from '../add-rollup-input.js';
import { getOutFile, getOutFolder } from '../common.js';
Expand Down Expand Up @@ -53,6 +53,9 @@ function vitePluginSSR(
if (routeIsRedirect(pageData.route)) {
continue;
}
if (routeIsAstroAssets(pageData.route)) {
continue;
}
const virtualModuleName = getVirtualModulePageNameFromPath(ASTRO_PAGE_MODULE_ID, path);
let module = await this.resolve(virtualModuleName);
if (module) {
Expand Down
7 changes: 7 additions & 0 deletions packages/astro/src/core/redirects/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ export function routeIsRedirect(route: RouteData | undefined): route is Redirect
return route?.type === 'redirect';
}

export function routeIsAstroAssets(route: RouteData | undefined): boolean {
if (route) {
return route.route.includes('/_image');
}
return false;
}

export function redirectRouteGenerate(redirectRoute: RouteData, data: Params): string {
const routeData = redirectRoute.redirectRoute;
const route = redirectRoute.redirect;
Expand Down
7 changes: 6 additions & 1 deletion packages/astro/src/core/redirects/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export { RedirectComponentInstance, RedirectSinglePageBuiltModule } from './component.js';
export { redirectRouteGenerate, redirectRouteStatus, routeIsRedirect } from './helpers.js';
export {
redirectRouteGenerate,
redirectRouteStatus,
routeIsRedirect,
routeIsAstroAssets,
} from './helpers.js';
export { getRedirectLocationOrThrow } from './validate.js';

0 comments on commit ba4ed10

Please sign in to comment.