Skip to content

Commit 1807084

Browse files
debug2
1 parent 8826d2d commit 1807084

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

plugin-vite/tests/test_utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ export default defineConfig({
7676
}
7777

7878
export async function buildVite() {
79-
const tmp = await withTmpDir();
79+
const tmp = await withTmpDir({
80+
dir: path.join(import.meta.dirname!, ".."),
81+
prefix: "tmp_vite_",
82+
});
8083

8184
const builder = await createBuilder({
8285
root: DEMO_DIR,

src/build_cache.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export class ProdBuildCache<State> implements BuildCache<State> {
6666

6767
// deno-lint-ignore no-console
6868
console.log("reading", { root: this.root, filePath: info.filePath });
69-
const filePath = path.join(this.root, info.filePath);
69+
const filePath = path.isAbsolute(info.filePath)
70+
? info.filePath
71+
: path.join(this.root, info.filePath);
7072

7173
const [stat, file] = await Promise.all([
7274
Deno.stat(filePath),

src/dev/dev_build_cache.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,25 @@ export function generateServerEntry(
529529
console.log("server entry", {
530530
root: options.root,
531531
});
532+
533+
let rootPath = `path.join(import.meta.dirname, ${
534+
JSON.stringify(options.root)
535+
})`;
536+
if (path.isAbsolute(options.root)) {
537+
// deno-lint-ignore no-console
538+
console.warn(
539+
`WARN: using absolute root path in snapshot: "${options.root}"`,
540+
);
541+
542+
rootPath = JSON.stringify(options.root);
543+
}
544+
532545
return `${EDIT_WARNING}
533546
import { setBuildCache, ProdBuildCache, path } from "fresh/internal";
534547
import * as snapshot from "${options.snapshotSpecifier}";
535548
import { app } from "${options.serverEntry}";
536549
537-
const root = path.join(import.meta.dirname, ${JSON.stringify(options.root)});
550+
const root = ${rootPath};
538551
setBuildCache(app, new ProdBuildCache(root, snapshot), "production");
539552
540553
export default {

0 commit comments

Comments
 (0)