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