Skip to content

Commit 83036d8

Browse files
fix: extract build-id into seperate package to fix publishing (#3194)
Also makes it easier to replace during bundling.
1 parent ba2e01f commit 83036d8

18 files changed

Lines changed: 41 additions & 16 deletions

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
},

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", () => {

src/dev/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
type FsRoute,
1818
MemoryBuildCache,
1919
} from "./dev_build_cache.ts";
20-
import { BUILD_ID } from "../runtime/build_id.ts";
20+
import { BUILD_ID } from "@fresh/build-id";
2121
import { updateCheck } from "./update_check.ts";
2222
import { devErrorOverlay } from "./middlewares/error_overlay/middleware.tsx";
2323
import { automaticWorkspaceFolders } from "./middlewares/automatic_workspace_folders.ts";

0 commit comments

Comments
 (0)