Skip to content

Commit 56a82ee

Browse files
committed
update
1 parent ca8c359 commit 56a82ee

8 files changed

Lines changed: 16 additions & 32 deletions

File tree

src/app_test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,7 @@ Deno.test.ignore("FreshApp - finish setup", async () => {
426426
app,
427427
await ProdBuildCache.fromSnapshot({
428428
...app.config,
429-
build: {
430-
outDir: "foo",
431-
},
429+
buildOutDir: "foo",
432430
}, getIslandRegistry(app).size),
433431
);
434432

src/build_cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class ProdBuildCache implements BuildCache {
104104
if (info === undefined) return null;
105105

106106
const base = info.generated
107-
? this.#config.build.outDir
107+
? this.#config.buildOutDir
108108
: this.#config.staticDir;
109109
const filePath = info.generated
110110
? path.join(base, "static", pathname)

src/config.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,7 @@ export interface FreshConfig {
2020
/**
2121
* The final resolved Fresh configuration where fields the user didn't specify are set to the default values.
2222
*/
23-
export interface ResolvedFreshConfig {
24-
root: string;
25-
build: {
26-
outDir: string;
27-
};
28-
basePath: string;
29-
staticDir: string;
23+
export interface ResolvedFreshConfig extends Required<FreshConfig> {
3024
/**
3125
* Tells you in which mode Fresh is currently running in.
3226
*/
@@ -58,15 +52,13 @@ export function normalizeConfig(options: FreshConfig): ResolvedFreshConfig {
5852

5953
return {
6054
root,
61-
build: {
62-
outDir: options.buildOutDir ?? path.join(root, "_fresh"),
63-
},
55+
buildOutDir: options.buildOutDir ?? path.join(root, "_fresh"),
6456
basePath: options.basePath ?? "",
6557
staticDir: options.staticDir ?? path.join(root, "static"),
6658
mode: "production",
6759
};
6860
}
6961

7062
export function getSnapshotPath(config: ResolvedFreshConfig): string {
71-
return path.join(config.build.outDir, "snapshot.json");
63+
return path.join(config.buildOutDir, "snapshot.json");
7264
}

src/dev/builder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ export class Builder implements FreshBuilder {
104104
}
105105

106106
async #build<T>(app: App<T>, dev: boolean): Promise<void> {
107-
const { build } = app.config;
108-
const staticOutDir = path.join(build.outDir, "static");
107+
const { buildOutDir } = app.config;
108+
const staticOutDir = path.join(buildOutDir, "static");
109109

110110
if (!this.#addedInternalTransforms) {
111111
this.#addedInternalTransforms = true;
@@ -206,7 +206,7 @@ export class Builder implements FreshBuilder {
206206
if (!dev) {
207207
// deno-lint-ignore no-console
208208
console.log(
209-
`Assets written to: ${colors.cyan(build.outDir)}`,
209+
`Assets written to: ${colors.cyan(buildOutDir)}`,
210210
);
211211
}
212212
}

src/dev/dev_build_cache.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ export class DiskBuildCache implements DevBuildCache {
188188
this.#processedFiles.set(pathname, hash);
189189

190190
const outDir = pathname === "/metafile.json"
191-
? this.config.build.outDir
192-
: path.join(this.config.build.outDir, "static");
191+
? this.config.buildOutDir
192+
: path.join(this.config.buildOutDir, "static");
193193
const filePath = path.join(outDir, pathname);
194194
assertInDir(filePath, outDir);
195195

@@ -204,7 +204,7 @@ export class DiskBuildCache implements DevBuildCache {
204204

205205
async flush(): Promise<void> {
206206
const staticDir = this.config.staticDir;
207-
const outDir = this.config.build.outDir;
207+
const outDir = this.config.buildOutDir;
208208

209209
if (await fsAdapter.isDirectory(staticDir)) {
210210
const entries = fsAdapter.walk(staticDir, {
@@ -272,7 +272,7 @@ export class DiskBuildCache implements DevBuildCache {
272272
}
273273

274274
if (maybeHash === null) {
275-
const filePath = path.join(this.config.build.outDir, "static", name);
275+
const filePath = path.join(this.config.buildOutDir, "static", name);
276276
const file = await Deno.open(filePath);
277277
hash = await hashContent(file.readable);
278278
}

src/middlewares/static_files_test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ Deno.test("static files - disables caching in development", async () => {
136136
buildCache,
137137
config: {
138138
basePath: "",
139-
build: {
140-
outDir: "",
141-
},
139+
buildOutDir: "",
142140
mode: "development",
143141
root: ".",
144142
staticDir: "",
@@ -164,9 +162,7 @@ Deno.test("static files - enables caching in production", async () => {
164162
buildCache,
165163
config: {
166164
basePath: "",
167-
build: {
168-
outDir: "",
169-
},
165+
buildOutDir: "",
170166
mode: "production",
171167
root: ".",
172168
staticDir: "",

src/test_utils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ export class FakeServer {
5252
}
5353

5454
const DEFAULT_CONFIG: ResolvedFreshConfig = {
55-
build: {
56-
outDir: "",
57-
},
55+
buildOutDir: "",
5856
mode: "production",
5957
basePath: "",
6058
root: "",

tests/test_utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function Doc(props: { children?: ComponentChildren; title?: string }) {
6464
export async function buildProd(app: App<unknown>) {
6565
const outDir = await Deno.makeTempDir();
6666
// FIXME: Sharing build output path is weird
67-
app.config.build.outDir = outDir;
67+
app.config.buildOutDir = outDir;
6868
const builder = new Builder({});
6969
await builder.build(app);
7070
const cache = await ProdBuildCache.fromSnapshot(

0 commit comments

Comments
 (0)