fix: extract build-id into seperate package to fix publishing (#3194)

Also makes it easier to replace during bundling.
This commit is contained in:
Marvin Hagemeister
2025-08-06 12:53:50 +02:00
committed by GitHub
parent ba2e01fec0
commit 83036d87ee
18 changed files with 41 additions and 16 deletions
+3
View File
@@ -0,0 +1,3 @@
# Fresh build id
Don't use this package directly. It's considered internal for Fresh.
+11
View File
@@ -0,0 +1,11 @@
{
"name": "@fresh/build-id",
"version": "1.0.0",
"license": "MIT",
"exports": {
".": "./mod.ts"
},
"imports": {
"@std/encoding": "jsr:@std/encoding@^1.0.10"
}
}
+3 -2
View File
@@ -1,6 +1,7 @@
{
"nodeModulesDir": "auto",
"workspace": [
"./build-id",
"./examples",
"./init",
"./plugin-tailwindcss",
@@ -19,8 +20,7 @@
"./dev": "./src/dev/mod.ts",
"./compat": "./src/compat.ts",
"./internal": "./src/internals.ts",
"./internal-dev": "./src/internals_dev.ts",
"./build-id": "./src/runtime/build_id.ts"
"./internal-dev": "./src/internals_dev.ts"
},
"tasks": {
"test": "deno test -A --parallel",
@@ -57,6 +57,7 @@
"imports": {
"@deno/doc": "jsr:@deno/doc@^0.172.0",
"@deno/esbuild-plugin": "jsr:@deno/esbuild-plugin@^1.1.5",
"@fresh/build-id": "jsr:@fresh/build-id@^1.0.0",
"@std/cli": "jsr:@std/cli@^1.0.19",
"@std/collections": "jsr:@std/collections@^1.1.2",
"@std/http": "jsr:@std/http@^1.0.15",
Generated
+8
View File
@@ -90,6 +90,8 @@
"npm:tailwindcss@^4.1.10": "4.1.11",
"npm:ts-morph@26": "26.0.0",
"npm:vite-plugin-inspect@^11.3.2": "11.3.2_vite@7.0.6__@types+node@22.15.15__picomatch@4.0.3_@types+node@22.15.15",
"npm:vite@*": "7.0.6_@types+node@22.15.15_picomatch@4.0.3",
"npm:vite@7.0.6": "7.0.6_@types+node@22.15.15_picomatch@4.0.3",
"npm:vite@^7.0.6": "7.0.6_@types+node@22.15.15_picomatch@4.0.3"
},
"jsr": {
@@ -2855,6 +2857,7 @@
"jsr:@astral/astral@~0.5.3",
"jsr:@deno/doc@0.172",
"jsr:@deno/esbuild-plugin@^1.1.5",
"jsr:@fresh/build-id@1",
"jsr:@fresh/core@^2.0.0-alpha.37",
"jsr:@marvinh-test/fresh-island@^0.0.1",
"jsr:@std/async@^1.0.13",
@@ -2892,6 +2895,11 @@
"npm:ts-morph@26"
],
"members": {
"build-id": {
"dependencies": [
"jsr:@std/encoding@^1.0.10"
]
},
"plugin-tailwindcss-v3": {
"dependencies": [
"npm:autoprefixer@^10.4.21",
+3 -1
View File
@@ -3,6 +3,8 @@ import type { Plugin } from "vite";
export function buildIdPlugin(): Plugin {
let buildId = "";
const regex = /^(jsr:)?@fresh\/build-id(@.*)?$/;
return {
name: "fresh:build-id",
async config(_, env) {
@@ -20,7 +22,7 @@ export function buildIdPlugin(): Plugin {
return true;
},
resolveId(id) {
if (id === "fresh/build-id") {
if (regex.test(id)) {
return `\0fresh/build-id`;
}
},
+1 -1
View File
@@ -1,6 +1,6 @@
import { trace } from "@opentelemetry/api";
import { DENO_DEPLOYMENT_ID } from "fresh/build-id";
import { DENO_DEPLOYMENT_ID } from "@fresh/build-id";
import * as colors from "@std/fmt/colors";
import {
type MaybeLazyMiddleware,
+1 -1
View File
@@ -4,7 +4,7 @@ import { fsItemsToCommands, type FsRouteFile } from "./fs_routes.ts";
import type { ServerIslandRegistry } from "./context.ts";
import type { AnyComponent } from "preact";
import { UniqueNamer } from "./utils.ts";
import { setBuildId } from "fresh/build-id";
import { setBuildId } from "@fresh/build-id";
export interface FileSnapshot {
name: string;
+1 -1
View File
@@ -3,7 +3,7 @@ import { Context } from "./context.ts";
import { App } from "fresh";
import { asset } from "fresh/runtime";
import { FakeServer } from "./test_utils.ts";
import { BUILD_ID } from "fresh/build-id";
import { BUILD_ID } from "@fresh/build-id";
import { parseHtml } from "../tests/test_utils.tsx";
Deno.test("FreshReqContext.prototype.redirect", () => {
+1 -1
View File
@@ -17,7 +17,7 @@ import {
type FsRoute,
MemoryBuildCache,
} from "./dev_build_cache.ts";
import { BUILD_ID } from "../runtime/build_id.ts";
import { BUILD_ID } from "@fresh/build-id";
import { updateCheck } from "./update_check.ts";
import { devErrorOverlay } from "./middlewares/error_overlay/middleware.tsx";
import { automaticWorkspaceFolders } from "./middlewares/automatic_workspace_folders.ts";
+1 -1
View File
@@ -3,7 +3,7 @@ import * as path from "@std/path";
import { Builder, specToName } from "./builder.ts";
import { App } from "../app.ts";
import { DEV_ERROR_OVERLAY_URL } from "../constants.ts";
import { BUILD_ID } from "fresh/build-id";
import { BUILD_ID } from "@fresh/build-id";
import { withTmpDir, writeFiles } from "../test_utils.ts";
import {
getStdOutput,
+2 -2
View File
@@ -166,14 +166,14 @@ function buildIdPlugin(buildId: string): EsbuildPlugin {
return {
name: "fresh-build-id",
setup(build) {
build.onResolve({ filter: /^fresh\/build-id$/ }, (args) => {
build.onResolve({ filter: /^(jsr:)?@fresh\/build-id(@.*)?$/ }, (args) => {
return {
path: args.path,
namespace: "fresh-internal",
};
});
build.onLoad({
filter: /^fresh\/build-id$/,
filter: /^(jsr:)?@fresh\/build-id$/,
namespace: "fresh-internal",
}, () => {
return {
+1 -1
View File
@@ -1,6 +1,6 @@
import { globToRegExp, isGlob } from "@std/path";
import type { FsAdapter } from "../fs.ts";
import { BUILD_ID } from "../runtime/build_id.ts";
import { BUILD_ID } from "@fresh/build-id";
import { assetInternal } from "../runtime/shared_internal.tsx";
export type TransformMode = "development" | "production";
+1 -1
View File
@@ -1,6 +1,6 @@
import type { Middleware } from "./mod.ts";
import { ASSET_CACHE_BUST_KEY } from "../runtime/shared_internal.tsx";
import { BUILD_ID } from "fresh/build-id";
import { BUILD_ID } from "@fresh/build-id";
import { tracer } from "../otel.ts";
import { getBuildCache } from "../context.ts";
+1 -1
View File
@@ -3,7 +3,7 @@ import { serveMiddleware } from "../test_utils.ts";
import type { BuildCache, StaticFile } from "../build_cache.ts";
import { expect } from "@std/expect";
import { ASSET_CACHE_BUST_KEY } from "../runtime/shared_internal.tsx";
import { BUILD_ID } from "fresh/build-id";
import { BUILD_ID } from "@fresh/build-id";
import type { Command } from "../commands.ts";
import type { ServerIslandRegistry } from "../context.ts";
import { getContentType } from "../dev/dev_build_cache.ts";
+1 -1
View File
@@ -1,6 +1,6 @@
import { options } from "preact";
import { assetHashingHook, CLIENT_NAV_ATTR } from "../shared_internal.tsx";
import { BUILD_ID } from "fresh/build-id";
import { BUILD_ID } from "@fresh/build-id";
const oldVNodeHook = options.vnode;
options.vnode = (vnode) => {
+1 -1
View File
@@ -23,7 +23,7 @@ import {
setActiveUrl,
} from "../shared_internal.tsx";
import type { BuildCache } from "../../build_cache.ts";
import { BUILD_ID } from "fresh/build-id";
import { BUILD_ID } from "@fresh/build-id";
import {
DEV_ERROR_OVERLAY_URL,
PARTIAL_SEARCH_PARAM,
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ComponentChildren, VNode } from "preact";
import { BUILD_ID } from "fresh/build-id";
import { BUILD_ID } from "@fresh/build-id";
import { assetInternal, assetSrcSetInternal } from "./shared_internal.tsx";
/**