Skip to content

Commit 8c54ceb

Browse files
authored
Merge branch 'main' into check-docs
2 parents ad9e16f + 51e4d33 commit 8c54ceb

4 files changed

Lines changed: 19 additions & 32 deletions

File tree

src/build_cache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from "@std/path";
2-
import type { ResolvedFreshConfig } from "./config.ts";
2+
import { getSnapshotPath, type ResolvedFreshConfig } from "./config.ts";
33
import { DENO_DEPLOYMENT_ID, setBuildId } from "./runtime/build_id.ts";
44
import * as colors from "@std/fmt/colors";
55

@@ -30,7 +30,7 @@ export interface BuildCache {
3030

3131
export class ProdBuildCache implements BuildCache {
3232
static async fromSnapshot(config: ResolvedFreshConfig, islandCount: number) {
33-
const snapshotPath = path.join(config.build.outDir, "snapshot.json");
33+
const snapshotPath = getSnapshotPath(config);
3434

3535
const staticFiles = new Map<string, FileSnapshot>();
3636
const islandToChunk = new Map<string, string>();

src/constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
export const INTERNAL_PREFIX = "/_frsh";
2-
export const DEV_CLIENT_URL = `${INTERNAL_PREFIX}/fresh_dev_client.js`;
32
export const DEV_ERROR_OVERLAY_URL = `${INTERNAL_PREFIX}/error_overlay`;
43
export const ALIVE_URL = `${INTERNAL_PREFIX}/alive`;
5-
export const JS_PREFIX = `/js`;

src/dev/dev_build_cache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { BuildCache, StaticFile } from "../build_cache.ts";
22
import * as path from "@std/path";
33
import { SEPARATOR as WINDOWS_SEPARATOR } from "@std/path/windows/constants";
4-
import type { ResolvedFreshConfig } from "../config.ts";
4+
import { getSnapshotPath, type ResolvedFreshConfig } from "../config.ts";
55
import type { BuildSnapshot } from "../build_cache.ts";
66
import { encodeHex } from "@std/encoding/hex";
77
import { crypto } from "@std/crypto";
@@ -284,7 +284,7 @@ export class DiskBuildCache implements DevBuildCache {
284284
}
285285

286286
await Deno.writeTextFile(
287-
path.join(this.config.build.outDir, "snapshot.json"),
287+
getSnapshotPath(this.config),
288288
JSON.stringify(snapshot, null, 2),
289289
);
290290
}

tests/precompile_test.ts

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,26 @@
1-
import * as path from "@std/path";
21
import { expect } from "@std/expect";
32

43
Deno.test("JSX precompile - check config", async () => {
5-
const cwd = path.join(import.meta.dirname!, "fixture_precompile", "invalid");
6-
const output = await new Deno.Command(Deno.execPath(), {
7-
args: [
8-
"run",
9-
"-A",
10-
path.join(cwd, "dev.ts"),
11-
],
12-
cwd,
4+
const { stderr, success } = await new Deno.Command(Deno.execPath(), {
5+
args: ["run", "-A", "dev.ts"],
6+
cwd: new URL("./fixture_precompile/invalid", import.meta.url),
137
}).output();
148

15-
const stderr = new TextDecoder().decode(output.stderr);
16-
expect(stderr).toContain("jsxPrecompileSkipElements to contain");
17-
expect(output.code).toEqual(1);
9+
const stderrText = new TextDecoder().decode(stderr);
10+
expect(stderrText).toContain("jsxPrecompileSkipElements to contain");
11+
expect(success).toEqual(false);
1812
});
1913

2014
Deno.test("JSX precompile - run vnode hooks", async () => {
21-
const cwd = path.join(import.meta.dirname!, "fixture_precompile", "valid");
22-
const output = await new Deno.Command(Deno.execPath(), {
23-
args: [
24-
"run",
25-
"-A",
26-
path.join(cwd, "main.tsx"),
27-
],
28-
cwd,
15+
const { stdout, success } = await new Deno.Command(Deno.execPath(), {
16+
args: ["run", "-A", "main.tsx"],
17+
cwd: new URL("./fixture_precompile/valid", import.meta.url),
2918
}).output();
3019

31-
const stdout = new TextDecoder().decode(output.stdout);
32-
expect(stdout).toContain('<img src="/foo.jpg?__frsh_c=');
33-
expect(stdout).toContain('<source src="/bar.jpg?__frsh_c=');
34-
expect(stdout).toContain('<div f-client-nav="true">');
35-
expect(stdout).toContain('<span f-client-nav="false">');
36-
expect(output.code).toEqual(0);
20+
const stdoutText = new TextDecoder().decode(stdout);
21+
expect(stdoutText).toContain('<img src="/foo.jpg?__frsh_c=');
22+
expect(stdoutText).toContain('<source src="/bar.jpg?__frsh_c=');
23+
expect(stdoutText).toContain('<div f-client-nav="true">');
24+
expect(stdoutText).toContain('<span f-client-nav="false">');
25+
expect(success).toEqual(true);
3726
});

0 commit comments

Comments
 (0)