Skip to content

Commit

Permalink
Prevent timing from causing module to not import
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Mar 24, 2022
1 parent 0ee36f3 commit d63a4cb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
20 changes: 1 addition & 19 deletions packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,6 @@ import { getPageDataByComponent, eachPageData } from './internal.js';
// system, possibly one that parallelizes if async IO is detected.
const MAX_CONCURRENT_RENDERS = 1;

// Utility functions
async function loadRenderer(renderer: AstroRenderer, config: AstroConfig): Promise<SSRLoadedRenderer> {
const mod = (await import(resolveDependency(renderer.serverEntrypoint, config))) as { default: SSRLoadedRenderer['ssr'] };
return { ...renderer, ssr: mod.default };
}

async function loadRenderers(config: AstroConfig): Promise<SSRLoadedRenderer[]> {
return Promise.all(config._ctx.renderers.map((r) => loadRenderer(r, config)));
}

export function getByFacadeId<T>(facadeId: string, map: Map<string, T>): T | undefined {
return (
map.get(facadeId) ||
// Windows the facadeId has forward slashes, no idea why
map.get(facadeId.replace(/\//g, '\\'))
);
}

// Throttle the rendering a paths to prevents creating too many Promises on the microtask queue.
function* throttle(max: number, inPaths: string[]) {
let tmp = [];
Expand Down Expand Up @@ -88,7 +70,7 @@ export async function generatePages(result: RollupOutput, opts: StaticBuildOptio

const ssr = !!opts.astroConfig._ctx.adapter?.serverEntrypoint;
const outFolder = ssr ? getServerRoot(opts.astroConfig) : getOutRoot(opts.astroConfig);
const ssrEntryURL = new URL('./entry.mjs', outFolder);
const ssrEntryURL = new URL(`./entry.mjs?time=${Date.now()}`, outFolder);
const ssrEntry = await import(ssrEntryURL.toString());

for(const pageData of eachPageData(internals)) {
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/core/build/vite-plugin-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import type { AstroAdapter } from '../../@types/astro';
import type { StaticBuildOptions } from './types';
import type { SerializedRouteInfo, SerializedSSRManifest } from '../app/types';

import { chunkIsPage, rootRelativeFacadeId, getByFacadeId } from './generate.js';
import { serializeRouteData } from '../routing/index.js';
import { getPageDataByComponent, eachPageData } from './internal.js';
import { eachPageData } from './internal.js';
import { addRollupInput } from './add-rollup-input.js';
import { virtualModuleId as pagesVirtualModuleId } from './vite-plugin-pages.js';

Expand Down

0 comments on commit d63a4cb

Please sign in to comment.