diff --git a/deno.lock b/deno.lock index c6202001e50..00c3db3cba8 100644 --- a/deno.lock +++ b/deno.lock @@ -5,27 +5,20 @@ "jsr:@deno-library/progress@^1.5.1": "1.5.1", "jsr:@deno/cache-dir@0.14": "0.14.0", "jsr:@deno/doc@0.172": "0.172.0", - "jsr:@deno/esbuild-plugin@^1.0.1": "1.1.1", "jsr:@deno/esbuild-plugin@^1.1.1": "1.1.1", "jsr:@deno/graph@0.86": "0.86.9", "jsr:@deno/graph@~0.82.3": "0.82.3", "jsr:@deno/loader@~0.2.1": "0.2.1", - "jsr:@fresh/core@^2.0.0-alpha.37": "2.0.0-alpha.37", - "jsr:@fresh/plugin-tailwind@^0.0.1-alpha.7": "0.0.1-alpha.7", "jsr:@marvinh-test/fresh-island@^0.0.1": "0.0.1", - "jsr:@std/assert@0.221": "0.221.0", "jsr:@std/assert@^1.0.13": "1.0.13", "jsr:@std/async@1": "1.0.13", "jsr:@std/async@^1.0.13": "1.0.13", "jsr:@std/bytes@^1.0.5": "1.0.6", "jsr:@std/bytes@^1.0.6": "1.0.6", "jsr:@std/cli@^1.0.19": "1.0.20", - "jsr:@std/cli@^1.0.20": "1.0.20", "jsr:@std/collections@^1.0.11": "1.1.2", "jsr:@std/collections@^1.1.1": "1.1.2", "jsr:@std/crypto@1": "1.0.5", - "jsr:@std/crypto@^1.0.5": "1.0.5", - "jsr:@std/data-structures@^1.0.8": "1.0.8", "jsr:@std/datetime@~0.225.2": "0.225.5", "jsr:@std/encoding@1": "1.0.10", "jsr:@std/encoding@^1.0.10": "1.0.10", @@ -33,14 +26,11 @@ "jsr:@std/fmt@1.0.3": "1.0.3", "jsr:@std/fmt@^1.0.3": "1.0.8", "jsr:@std/fmt@^1.0.7": "1.0.8", - "jsr:@std/fmt@^1.0.8": "1.0.8", "jsr:@std/front-matter@^1.0.5": "1.0.9", "jsr:@std/fs@1": "1.0.19", "jsr:@std/fs@^1.0.18": "1.0.19", - "jsr:@std/fs@^1.0.19": "1.0.19", "jsr:@std/fs@^1.0.6": "1.0.19", "jsr:@std/html@1": "1.0.4", - "jsr:@std/html@^1.0.4": "1.0.4", "jsr:@std/http@^1.0.15": "1.0.19", "jsr:@std/internal@^1.0.6": "1.0.9", "jsr:@std/internal@^1.0.7": "1.0.9", @@ -51,16 +41,12 @@ "jsr:@std/json@^1.0.2": "1.0.2", "jsr:@std/jsonc@1": "1.0.2", "jsr:@std/media-types@1": "1.1.0", - "jsr:@std/media-types@^1.1.0": "1.1.0", - "jsr:@std/net@^1.0.4": "1.0.4", - "jsr:@std/path@0.221": "0.221.0", "jsr:@std/path@1": "1.1.1", "jsr:@std/path@^1.0.8": "1.1.1", "jsr:@std/path@^1.1.0": "1.1.1", "jsr:@std/path@^1.1.1": "1.1.1", "jsr:@std/semver@1": "1.0.5", "jsr:@std/streams@1": "1.0.10", - "jsr:@std/streams@^1.0.10": "1.0.10", "jsr:@std/testing@^1.0.12": "1.0.14", "jsr:@std/toml@^1.0.3": "1.0.8", "jsr:@std/uuid@^1.0.7": "1.0.9", @@ -138,39 +124,6 @@ "@deno/loader@0.2.1": { "integrity": "c9fcc7309ce6a77306d37a7dc4b886e547aafc5204a4a28b0eafa523ffa5c9fc" }, - "@fresh/core@2.0.0-alpha.37": { - "integrity": "26f2eeb1891c1e05d5e45f67fcd3da9f2b0810b2b8e9c52b05bb168a2e56a7c0", - "dependencies": [ - "jsr:@deno/esbuild-plugin@^1.0.1", - "jsr:@std/crypto@1", - "jsr:@std/datetime", - "jsr:@std/encoding@1", - "jsr:@std/fmt@^1.0.7", - "jsr:@std/fs@1", - "jsr:@std/html@1", - "jsr:@std/http", - "jsr:@std/jsonc", - "jsr:@std/media-types@1", - "jsr:@std/path@1", - "jsr:@std/semver", - "jsr:@std/uuid", - "npm:@opentelemetry/api", - "npm:@preact/signals@^2.2.1", - "npm:esbuild-wasm", - "npm:preact-render-to-string", - "npm:preact@^10.26.9" - ] - }, - "@fresh/plugin-tailwind@0.0.1-alpha.7": { - "integrity": "b940991bdb76f0995dc58b25183f1001d72c4020e049d384ad3fb751556aa2a9", - "dependencies": [ - "jsr:@std/path@0.221", - "npm:autoprefixer", - "npm:cssnano", - "npm:postcss", - "npm:tailwindcss" - ] - }, "@marvinh-test/fresh-island@0.0.1": { "integrity": "890f2595e60b1aaeaa8d73c6ad2c1247d4c5b895387df230f7f3b2a4da29b585", "dependencies": [ @@ -179,9 +132,6 @@ "npm:preact@^10.26.9" ] }, - "@std/assert@0.221.0": { - "integrity": "a5f1aa6e7909dbea271754fd4ab3f4e687aeff4873b4cef9a320af813adb489a" - }, "@std/assert@1.0.13": { "integrity": "ae0d31e41919b12c656c742b22522c32fb26ed0cba32975cb0de2a273cb68b29", "dependencies": [ @@ -203,9 +153,6 @@ "@std/crypto@1.0.5": { "integrity": "0dcfbb319fe0bba1bd3af904ceb4f948cde1b92979ec1614528380ed308a3b40" }, - "@std/data-structures@1.0.8": { - "integrity": "2fb7219247e044c8fcd51341788547575653c82ae2c759ff209e0263ba7d9b66" - }, "@std/datetime@0.225.5": { "integrity": "9f650f6caec546b80172e95a4edb8478d5fe060c4c937f7ede242ffceab6efc9" }, @@ -215,7 +162,7 @@ "@std/expect@1.0.16": { "integrity": "ceeef6dda21f256a5f0f083fcc0eaca175428b523359a9b1d9b3a1df11cc7391", "dependencies": [ - "jsr:@std/assert@^1.0.13", + "jsr:@std/assert", "jsr:@std/internal@^1.0.7" ] }, @@ -235,7 +182,6 @@ "@std/fs@1.0.19": { "integrity": "051968c2b1eae4d2ea9f79a08a3845740ef6af10356aff43d3e2ef11ed09fb06", "dependencies": [ - "jsr:@std/internal@^1.0.9", "jsr:@std/path@^1.1.1" ] }, @@ -245,15 +191,7 @@ "@std/http@1.0.19": { "integrity": "52128c8d00a1f0b20019f8b72376e7ef5f3133375b6f805b5bc89b9de2ad4686", "dependencies": [ - "jsr:@std/cli@^1.0.20", - "jsr:@std/encoding@^1.0.10", - "jsr:@std/fmt@^1.0.8", - "jsr:@std/fs@^1.0.19", - "jsr:@std/html@^1.0.4", - "jsr:@std/media-types@^1.1.0", - "jsr:@std/net", - "jsr:@std/path@^1.1.1", - "jsr:@std/streams@^1.0.10" + "jsr:@std/encoding@^1.0.10" ] }, "@std/internal@1.0.9": { @@ -280,15 +218,6 @@ "@std/media-types@1.1.0": { "integrity": "c9d093f0c05c3512932b330e3cc1fe1d627b301db33a4c2c2185c02471d6eaa4" }, - "@std/net@1.0.4": { - "integrity": "2f403b455ebbccf83d8a027d29c5a9e3a2452fea39bb2da7f2c04af09c8bc852" - }, - "@std/path@0.221.0": { - "integrity": "0a36f6b17314ef653a3a1649740cc8db51b25a133ecfe838f20b79a56ebe0095", - "dependencies": [ - "jsr:@std/assert@0.221" - ] - }, "@std/path@1.1.1": { "integrity": "fe00026bd3a7e6a27f73709b83c607798be40e20c81dde655ce34052fd82ec76", "dependencies": [ @@ -299,17 +228,12 @@ "integrity": "529f79e83705714c105ad0ba55bec0f9da0f24d2f726b6cc1c15e505cc2c0624" }, "@std/streams@1.0.10": { - "integrity": "75c0b1431873cd0d8b3d679015220204d36d3c7420d93b60acfc379eb0dc30af", - "dependencies": [ - "jsr:@std/bytes@^1.0.6" - ] + "integrity": "75c0b1431873cd0d8b3d679015220204d36d3c7420d93b60acfc379eb0dc30af" }, "@std/testing@1.0.14": { "integrity": "144b3737105b9071cb50c957681f58a1b8ec0f3e5b19ad830f401c5fa931e8f0", "dependencies": [ - "jsr:@std/assert@^1.0.13", - "jsr:@std/async@^1.0.13", - "jsr:@std/data-structures", + "jsr:@std/assert", "jsr:@std/fs@^1.0.18", "jsr:@std/internal@^1.0.8", "jsr:@std/path@^1.1.0" @@ -324,8 +248,7 @@ "@std/uuid@1.0.9": { "integrity": "44b627bf2d372fe1bd099e2ad41b2be41a777fc94e62a3151006895a037f1642", "dependencies": [ - "jsr:@std/bytes@^1.0.6", - "jsr:@std/crypto@^1.0.5" + "jsr:@std/bytes@^1.0.6" ] }, "@std/yaml@1.0.8": { diff --git a/src/app_test.tsx b/src/app_test.tsx index de956123f72..560152c42d4 100644 --- a/src/app_test.tsx +++ b/src/app_test.tsx @@ -469,9 +469,7 @@ Deno.test.ignore("App - finish setup", async () => { app, await ProdBuildCache.fromSnapshot({ ...app.config, - build: { - outDir: "foo", - }, + buildOutDir: "foo", }, getIslandRegistry(app).size), ); diff --git a/src/build_cache.ts b/src/build_cache.ts index 709ab36fef3..82ff93e2eea 100644 --- a/src/build_cache.ts +++ b/src/build_cache.ts @@ -104,7 +104,7 @@ export class ProdBuildCache implements BuildCache { if (info === undefined) return null; const base = info.generated - ? this.#config.build.outDir + ? this.#config.buildOutDir : this.#config.staticDir; const filePath = info.generated ? path.join(base, "static", pathname) diff --git a/src/build_cache_test.ts b/src/build_cache_test.ts index 24e65b5df0a..b9f2204efd1 100644 --- a/src/build_cache_test.ts +++ b/src/build_cache_test.ts @@ -21,9 +21,7 @@ Deno.test({ mode: "production", basePath: "/", staticDir: path.join(tmp, "static"), - build: { - outDir: path.join(tmp, "dist"), - }, + buildOutDir: path.join(tmp, "dist"), }; await Deno.mkdir(path.join(tmp, "static", ".well-known"), { recursive: true, diff --git a/src/config.ts b/src/config.ts index 5987c6dabed..d6819835a0f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -9,16 +9,14 @@ export interface FreshConfig { * @default Deno.cwd() */ root?: string; - build?: { - /** - * The directory to write generated files to when `dev.ts build` is run. - * - * This can be an absolute path, a file URL or a relative path. - * Relative paths are resolved against the `root` option. - * @default "_fresh" - */ - outDir?: string; - }; + /** + * The directory to write generated files to when `dev.ts build` is run. + * + * This can be an absolute path, a file URL or a relative path. + * Relative paths are resolved against the `root` option. + * @default "_fresh" + */ + buildOutDir?: string; /** * Serve fresh from a base path instead of from the root. * "/foo/bar" -> http://localhost:8000/foo/bar @@ -38,17 +36,7 @@ export interface FreshConfig { /** * The final resolved Fresh configuration where fields the user didn't specify are set to the default values. */ -export interface ResolvedFreshConfig { - root: string; - build: { - outDir: string; - }; - /** - * Serve fresh from a base path instead of from the root. - * "/foo/bar" -> http://localhost:8000/foo/bar - */ - basePath: string; - staticDir: string; +export interface ResolvedFreshConfig extends Required { /** * The mode Fresh can run in. */ @@ -92,9 +80,7 @@ export function normalizeConfig(options: FreshConfig): ResolvedFreshConfig { return { root, - build: { - outDir: parseDirPath(options.build?.outDir ?? "_fresh", root), - }, + buildOutDir: parseDirPath(options.buildOutDir ?? "_fresh", root), basePath: options.basePath ?? "", staticDir: parseDirPath(options.staticDir ?? "static", root), mode: "production", @@ -102,5 +88,5 @@ export function normalizeConfig(options: FreshConfig): ResolvedFreshConfig { } export function getSnapshotPath(config: ResolvedFreshConfig): string { - return path.join(config.build.outDir, "snapshot.json"); + return path.join(config.buildOutDir, "snapshot.json"); } diff --git a/src/config_test.ts b/src/config_test.ts index adae62b5807..ed83f49a91a 100644 --- a/src/config_test.ts +++ b/src/config_test.ts @@ -49,8 +49,7 @@ Deno.test("normalizeConfig - root", () => { Deno.test("normalizeConfig - build.outDir", () => { const cwd = Deno.cwd().replaceAll("\\", "/"); - const outDir = (options: FreshConfig) => - normalizeConfig(options).build.outDir; + const outDir = (options: FreshConfig) => normalizeConfig(options).buildOutDir; // Default outDir expect(outDir({ root: "./src" })).toEqual(`${cwd}/src/_fresh`); @@ -58,21 +57,21 @@ Deno.test("normalizeConfig - build.outDir", () => { expect(outDir({ root: "file:///src" })).toEqual("/src/_fresh"); // Relative outDir - expect(outDir({ root: "/src", build: { outDir: "dist" } })).toEqual( + expect(outDir({ root: "/src", buildOutDir: "dist" })).toEqual( "/src/dist", ); - expect(outDir({ root: "/src", build: { outDir: "./dist" } })).toEqual( + expect(outDir({ root: "/src", buildOutDir: "./dist" })).toEqual( "/src/dist", ); // Absolute outDir - expect(outDir({ root: "/src", build: { outDir: "/dist" } })).toEqual( + expect(outDir({ root: "/src", buildOutDir: "/dist" })).toEqual( "/dist", ); - expect(outDir({ root: "/src", build: { outDir: "/dist/fresh" } })).toEqual( + expect(outDir({ root: "/src", buildOutDir: "/dist/fresh" })).toEqual( "/dist/fresh", ); - expect(outDir({ root: "/src", build: { outDir: "file:///dist" } })).toEqual( + expect(outDir({ root: "/src", buildOutDir: "file:///dist" })).toEqual( "/dist", ); }); diff --git a/src/dev/builder.ts b/src/dev/builder.ts index 0f627106e1b..9677a49e185 100644 --- a/src/dev/builder.ts +++ b/src/dev/builder.ts @@ -103,8 +103,8 @@ export class Builder { } async #build(app: App, dev: boolean): Promise { - const { build } = app.config; - const staticOutDir = path.join(build.outDir, "static"); + const { buildOutDir } = app.config; + const staticOutDir = path.join(buildOutDir, "static"); if (!this.#addedInternalTransforms) { this.#addedInternalTransforms = true; @@ -209,7 +209,7 @@ export class Builder { if (!dev) { // deno-lint-ignore no-console console.log( - `Assets written to: ${colors.cyan(build.outDir)}`, + `Assets written to: ${colors.cyan(buildOutDir)}`, ); } } diff --git a/src/dev/builder_test.ts b/src/dev/builder_test.ts index 65e1c9c4595..f8f95366043 100644 --- a/src/dev/builder_test.ts +++ b/src/dev/builder_test.ts @@ -35,9 +35,7 @@ Deno.test({ await Deno.writeTextFile(path.join(tmp, "foo.css"), "body { color: red; }"); const app = new App({ staticDir: tmp, - build: { - outDir: path.join(tmp, "dist"), - }, + buildOutDir: path.join(tmp, "dist"), }); await builder.build(app); @@ -60,9 +58,7 @@ Deno.test({ ); const app = new App({ staticDir: tmp, - build: { - outDir: path.join(tmp, "dist"), - }, + buildOutDir: path.join(tmp, "dist"), }); await builder.build(app); @@ -87,9 +83,7 @@ Deno.test({ ); const app = new App({ staticDir: tmp, - build: { - outDir: path.join(tmp, "dist"), - }, + buildOutDir: path.join(tmp, "dist"), }); await builder.build(app); @@ -115,9 +109,7 @@ Deno.test({ ); const app = new App({ staticDir: tmp, - build: { - outDir: path.join(tmp, "dist"), - }, + buildOutDir: path.join(tmp, "dist"), }); await builder.build(app); @@ -140,9 +132,7 @@ Deno.test({ const tmp = _tmp.dir; const app = new App({ staticDir: tmp, - build: { - outDir: path.join(tmp, "dist"), - }, + buildOutDir: path.join(tmp, "dist"), }); app.island("jsr:@marvinh-test/fresh-island", "RemoteIsland", RemoteIsland); @@ -205,9 +195,7 @@ Deno.test({ ); const app = new App({ staticDir: tmp, - build: { - outDir: path.join(tmp, "dist"), - }, + buildOutDir: path.join(tmp, "dist"), }); await builder.build(app); @@ -224,9 +212,7 @@ Deno.test({ const tmp = await Deno.makeTempDir(); const app = new App({ staticDir: tmp, - build: { - outDir: path.join(tmp, "dist"), - }, + buildOutDir: path.join(tmp, "dist"), }); const abort = new AbortController(); const port = 8011; diff --git a/src/dev/dev_build_cache.ts b/src/dev/dev_build_cache.ts index 358addc1bc3..04fc0252d07 100644 --- a/src/dev/dev_build_cache.ts +++ b/src/dev/dev_build_cache.ts @@ -188,8 +188,8 @@ export class DiskBuildCache implements DevBuildCache { this.#processedFiles.set(pathname, hash); const outDir = pathname === "/metafile.json" - ? this.config.build.outDir - : path.join(this.config.build.outDir, "static"); + ? this.config.buildOutDir + : path.join(this.config.buildOutDir, "static"); const filePath = path.join(outDir, pathname); assertInDir(filePath, outDir); @@ -204,7 +204,7 @@ export class DiskBuildCache implements DevBuildCache { async flush(): Promise { const staticDir = this.config.staticDir; - const outDir = this.config.build.outDir; + const outDir = this.config.buildOutDir; if (await fsAdapter.isDirectory(staticDir)) { const entries = fsAdapter.walk(staticDir, { @@ -272,7 +272,7 @@ export class DiskBuildCache implements DevBuildCache { } if (maybeHash === null) { - const filePath = path.join(this.config.build.outDir, "static", name); + const filePath = path.join(this.config.buildOutDir, "static", name); const file = await Deno.open(filePath); hash = await hashContent(file.readable); } diff --git a/src/dev/dev_build_cache_test.ts b/src/dev/dev_build_cache_test.ts index 513865ed18a..9f8a849d6ff 100644 --- a/src/dev/dev_build_cache_test.ts +++ b/src/dev/dev_build_cache_test.ts @@ -15,9 +15,7 @@ Deno.test({ mode: "development", basePath: "/", staticDir: path.join(tmp, "static"), - build: { - outDir: path.join(tmp, "dist"), - }, + buildOutDir: path.join(tmp, "dist"), }; const fileTransformer = new FreshFileTransformer(createFakeFs({})); const buildCache = new MemoryBuildCache( diff --git a/src/middlewares/static_files_test.ts b/src/middlewares/static_files_test.ts index bb9c1c1df04..98c7db62d88 100644 --- a/src/middlewares/static_files_test.ts +++ b/src/middlewares/static_files_test.ts @@ -136,9 +136,7 @@ Deno.test("static files - disables caching in development", async () => { buildCache, config: { basePath: "", - build: { - outDir: "", - }, + buildOutDir: "", mode: "development", root: ".", staticDir: "", @@ -164,9 +162,7 @@ Deno.test("static files - enables caching in production", async () => { buildCache, config: { basePath: "", - build: { - outDir: "", - }, + buildOutDir: "", mode: "production", root: ".", staticDir: "", diff --git a/src/test_utils.ts b/src/test_utils.ts index 35908758a07..05aa0362e1e 100644 --- a/src/test_utils.ts +++ b/src/test_utils.ts @@ -61,9 +61,7 @@ export class FakeServer { } const DEFAULT_CONFIG: ResolvedFreshConfig = { - build: { - outDir: "", - }, + buildOutDir: "", mode: "production", basePath: "", root: "", diff --git a/tests/test_utils.tsx b/tests/test_utils.tsx index f64136e3bfe..d44427eda86 100644 --- a/tests/test_utils.tsx +++ b/tests/test_utils.tsx @@ -74,7 +74,7 @@ export function Doc(props: { children?: ComponentChildren; title?: string }) { export async function buildProd(app: App) { const outDir = await Deno.makeTempDir(); // FIXME: Sharing build output path is weird - app.config.build.outDir = outDir; + app.config.buildOutDir = outDir; const builder = new Builder({}); await builder.build(app); const cache = await ProdBuildCache.fromSnapshot(