Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build-id/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Fresh build id

Don't use this package directly. It's considered internal for Fresh.
11 changes: 11 additions & 0 deletions build-id/deno.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
File renamed without changes.
5 changes: 3 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"nodeModulesDir": "auto",
"workspace": [
"./build-id",
"./examples",
"./init",
"./plugin-tailwindcss",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion plugin-vite/src/plugins/build_id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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`;
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/build_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/context_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/dev/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/dev/builder_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/dev/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/dev/file_transformer.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/static_files.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/static_files_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/client/preact_hooks_client.ts
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/server/preact_hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/shared.ts
Original file line number Diff line number Diff line change
@@ -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";

/**
Expand Down