Skip to content

Commit e18a334

Browse files
fix: extract build-id into seperate package to fix publishing
Also makes it easier to replace during bundling.
1 parent 36aa9b5 commit e18a334

17 files changed

Lines changed: 43 additions & 14 deletions

File tree

build-id/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Fresh build id
2+
3+
Don't use this package directly. It's considered internal for Fresh.

build-id/deno.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@fresh/build-id",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"exports": {
6+
".": "./mod.ts"
7+
},
8+
"imports": {
9+
"@std/encoding": "jsr:@std/encoding@^1.0.10"
10+
}
11+
}
File renamed without changes.

deno.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"nodeModulesDir": "auto",
33
"workspace": [
4+
"./build-id",
45
"./examples",
56
"./init",
67
"./plugin-tailwindcss",
@@ -19,8 +20,7 @@
1920
"./dev": "./src/dev/mod.ts",
2021
"./compat": "./src/compat.ts",
2122
"./internal": "./src/internals.ts",
22-
"./internal-dev": "./src/internals_dev.ts",
23-
"./build-id": "./src/runtime/build_id.ts"
23+
"./internal-dev": "./src/internals_dev.ts"
2424
},
2525
"tasks": {
2626
"test": "deno test -A --parallel",
@@ -57,6 +57,7 @@
5757
"imports": {
5858
"@deno/doc": "jsr:@deno/doc@^0.172.0",
5959
"@deno/esbuild-plugin": "jsr:@deno/esbuild-plugin@^1.1.5",
60+
"@fresh/build-id": "jsr:@fresh/build-id@^1.0.0",
6061
"@std/cli": "jsr:@std/cli@^1.0.19",
6162
"@std/collections": "jsr:@std/collections@^1.1.2",
6263
"@std/http": "jsr:@std/http@^1.0.15",

deno.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin-vite/src/plugins/build_id.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import type { Plugin } from "vite";
33
export function buildIdPlugin(): Plugin {
44
let buildId = "";
55

6+
const regex = /^(jsr:)?@fresh\/build-id(@.*)?$/;
7+
68
return {
79
name: "fresh:build-id",
810
async config(_, env) {
@@ -20,7 +22,7 @@ export function buildIdPlugin(): Plugin {
2022
return true;
2123
},
2224
resolveId(id) {
23-
if (id === "fresh/build-id") {
25+
if (regex.test(id)) {
2426
return `\0fresh/build-id`;
2527
}
2628
},

plugin-vite/src/plugins/deno.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ export function deno(): Plugin {
4444
return id;
4545
}
4646

47+
if (resolved.includes("build_id")) {
48+
console.log("deno", { resolved });
49+
}
50+
4751
const type = getDenoType(options.attributes.type ?? "default");
4852
if (
4953
type !== RequestedModuleType.Default ||

src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { trace } from "@opentelemetry/api";
22

3-
import { DENO_DEPLOYMENT_ID } from "fresh/build-id";
3+
import { DENO_DEPLOYMENT_ID } from "@fresh/build-id";
44
import * as colors from "@std/fmt/colors";
55
import {
66
type MaybeLazyMiddleware,

src/build_cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { fsItemsToCommands, type FsRouteFile } from "./fs_routes.ts";
44
import type { ServerIslandRegistry } from "./context.ts";
55
import type { AnyComponent } from "preact";
66
import { UniqueNamer } from "./utils.ts";
7-
import { setBuildId } from "fresh/build-id";
7+
import { setBuildId } from "@fresh/build-id";
88

99
export interface FileSnapshot {
1010
name: string;

src/context_test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Context } from "./context.ts";
33
import { App } from "fresh";
44
import { asset } from "fresh/runtime";
55
import { FakeServer } from "./test_utils.ts";
6-
import { BUILD_ID } from "fresh/build-id";
6+
import { BUILD_ID } from "@fresh/build-id";
77
import { parseHtml } from "../tests/test_utils.tsx";
88

99
Deno.test("FreshReqContext.prototype.redirect", () => {

0 commit comments

Comments
 (0)