Skip to content

Commit

Permalink
Fix Windows bug
Browse files Browse the repository at this point in the history
  • Loading branch information
drwpow committed Sep 23, 2021
1 parent ad63605 commit 70cc74a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"dev": "astro-scripts dev \"src/**/*.ts\"",
"postbuild": "astro-scripts copy \"src/**/*.astro\"",
"benchmark": "node test/benchmark/dev.bench.js && node test/benchmark/build.bench.js",
"test": "mocha --parallel --timeout 15000"
"test": "mocha --parallel --timeout 15000 -g \"Astro basics\""
},
"dependencies": {
"@astrojs/compiler": "^0.1.0-canary.45",
Expand Down
7 changes: 4 additions & 3 deletions packages/astro/src/runtime/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as eslexer from 'es-module-lexer';
import { fileURLToPath } from 'url';
import fs from 'fs';
import path from 'path';
import slash from 'slash';
import { renderPage } from './astro.js';
import glob from 'tiny-glob';
import { generatePaginateFunction } from './paginate.js';
Expand Down Expand Up @@ -87,8 +88,8 @@ async function resolveRenderers(viteServer: ViteDevServer, ids: string[]) {
return renderers;
}

async function resolveImportedModules(viteServer: ViteDevServer, file: string) {
const { url } = await viteServer.moduleGraph.ensureEntryFromUrl(file);
async function resolveImportedModules(viteServer: ViteDevServer, file: URL) {
const { url } = await viteServer.moduleGraph.ensureEntryFromUrl(slash(fileURLToPath(file))); // note: for some reason Vite expects forward slashes here for Windows, which `slash()` helps resolve
const modulesByFile = viteServer.moduleGraph.getModulesByFile(url);
if (!modulesByFile) {
return {};
Expand Down Expand Up @@ -138,7 +139,7 @@ export async function ssr({ astroConfig, filePath, logging, mode, origin, pathna

// 1.5. resolve renderers and imported modules.
// important that this happens _after_ ssrLoadModule, otherwise `importedModules` would be empty
const [renderers, importedModules] = await Promise.all([resolveRenderers(viteServer, astroConfig.renderers), resolveImportedModules(viteServer, fileURLToPath(filePath))]);
const [renderers, importedModules] = await Promise.all([resolveRenderers(viteServer, astroConfig.renderers), resolveImportedModules(viteServer, filePath)]);

// 2. handle dynamic routes
let params: Params = {};
Expand Down

0 comments on commit 70cc74a

Please sign in to comment.