diff --git a/framework/backend/entry-node.ts b/framework/backend/entry-node.ts
index 75f80bf1df5abff3fb0cb728f85d6403bde23f22..e69271ebbcf55494145f05c9e375cf7ed642b56e 100644
--- a/framework/backend/entry-node.ts
+++ b/framework/backend/entry-node.ts
@@ -42,4 +42,4 @@ import * as os from "os";
import * as url from "node:url";
import { serve } from "@hono/node-server";
import process from "node:process";
-import * as console from "lib/log.ts";
+import * as console from "@clo/lib/log.ts";
diff --git a/framework/bundle.ts b/framework/bundle.ts
index 603a2c407e47a41e8272927a5cdb882f2726ed4f..3395af706fa792c0b37000c557f3d236ddd384f9 100644
--- a/framework/bundle.ts
+++ b/framework/bundle.ts
@@ -37,7 +37,6 @@ export async function bundleClientJavaScript(
}
const clientPlugins: esbuild.Plugin[] = [
- projectRelativeResolution(),
markoViaBuildCache(),
{
name: "mark css external",
@@ -250,7 +249,6 @@ export async function bundleServerJavaScript({
return view.file;
},
}),
- projectRelativeResolution(),
markoViaBuildCache(),
{
name: "replace client references",
@@ -301,7 +299,7 @@ export async function bundleServerJavaScript({
"globalThis.CLOVER_SERVER_ENTRY": JSON.stringify(entry),
},
external: Object.keys(pkg.dependencies).filter(
- (x) => x !== "lib",
+ (x) => x !== "@clo/lib",
),
});
await trackEsbuild(io, metafile);
@@ -391,7 +389,6 @@ import * as hot from "./hot.ts";
import {
isIgnoredSource,
markoViaBuildCache,
- projectRelativeResolution,
virtualFiles,
} from "./esbuild-support.ts";
import { Io, toAbs } from "./incremental.ts";
@@ -400,6 +397,6 @@ import * as incr from "./incremental.ts";
import * as sg from "#sitegen";
import type { PageOrView } from "./generate.ts";
import type * as view from "#sitegen/view";
-import * as meta from "lib/render/meta.ts";
-import * as progress from "lib/progress.ts";
-import { ASSERT, UNWRAP } from "lib/assert.ts";
+import * as meta from "@clo/lib/render/meta.ts";
+import * as progress from "@clo/lib/progress.ts";
+import { ASSERT, UNWRAP } from "@clo/lib/assert.ts";
diff --git a/framework/css.ts b/framework/css.ts
index 32a8c0babecad6cc0a713568966c0cc7e0c21959..3c0013200764ffbf7fba5871dd4105658cc072a0 100644
--- a/framework/css.ts
+++ b/framework/css.ts
@@ -116,4 +116,4 @@ import * as hot from "./hot.ts";
import * as path from "node:path";
import { virtualFiles } from "./esbuild-support.ts";
import type { Io } from "./incremental.ts";
-import { UNWRAP } from "lib/assert.ts";
+import { UNWRAP } from "@clo/lib/assert.ts";
diff --git a/framework/esbuild-support.ts b/framework/esbuild-support.ts
index dbf204daca186dde26f80d327e8ae6fedbfad4fd..87e76b99ce30b80da37250b46280c876a2af954c 100644
--- a/framework/esbuild-support.ts
+++ b/framework/esbuild-support.ts
@@ -61,24 +61,6 @@ export function banFiles(
} satisfies esbuild.Plugin;
}
-export function projectRelativeResolution(root = process.cwd() + "/src") {
- return {
- name: "project relative resolution ('@/' prefix)",
- setup(b) {
- b.onResolve({ filter: /^@\// }, ({ path: id }) => {
- return {
- path: path.resolve(root, id.slice(2)),
- };
- });
- b.onResolve({ filter: /^#/ }, ({ path: id, importer }) => {
- return {
- path: hot.resolveFrom(importer, id),
- };
- });
- },
- } satisfies esbuild.Plugin;
-}
-
export function markoViaBuildCache(): esbuild.Plugin {
return {
name: "marko via build cache",
@@ -112,7 +94,7 @@ export function isIgnoredSource(source: string) {
}
import * as esbuild from "esbuild";
-import * as string from "lib/string.ts";
+import * as string from "@clo/lib/string.ts";
import * as path from "node:path";
import * as fs from "#sitegen/fs";
import * as hot from "./hot.ts";
diff --git a/framework/font.ts b/framework/font.ts
index 887ffa66be670177bce82abd5f019ddb0489145f..de98e95075165a44254deb8aafb4be841148b692 100644
--- a/framework/font.ts
+++ b/framework/font.ts
@@ -143,7 +143,7 @@ export async function fetchFont(name: string, sources: string[]) {
: process.platform === "darwin"
? [
"/Library/Fonts",
- path.posix.join(home, "Library/Fonts"),
+ path.posix.join(home, "@clo/library/Fonts"),
]
: [
"/usr/share/fonts",
@@ -211,10 +211,10 @@ import * as fs from "#sitegen/fs";
import * as os from "node:os";
import * as path from "node:path";
import * as sg from "#sitegen";
-import * as subprocess from "lib/subprocess.ts";
+import * as subprocess from "@clo/lib/subprocess.ts";
import * as incr from "./incremental.ts";
import * as crypto from "node:crypto";
-import * as async from "lib/async.ts";
-import * as error from "lib/error.ts";
+import * as async from "@clo/lib/async.ts";
+import * as error from "@clo/lib/error.ts";
import * as progress from "../lib/progress.ts";
-import { ASSERT } from "lib/assert.ts";
+import { ASSERT } from "@clo/lib/assert.ts";
diff --git a/framework/generate.ts b/framework/generate.ts
index 3a9978ef1a6b2bb47c6b9ba08f6784a870a3e047..aa6871ee3349c17925e26558af9d66381c3f0b52 100644
--- a/framework/generate.ts
+++ b/framework/generate.ts
@@ -414,12 +414,12 @@ export type PageOrView = PreparedPage | PreparedView;
import * as path from "node:path";
import * as fs from "#sitegen/fs";
-import * as meta from "lib/render/meta.ts";
-import * as render from "lib/render.ts";
+import * as meta from "@clo/lib/render/meta.ts";
+import * as render from "@clo/lib/render.ts";
import * as sg from "#sitegen";
import type { FileItem } from "#sitegen";
import * as progress from "../lib/progress.ts";
-import * as error from "lib/error.ts";
+import * as error from "@clo/lib/error.ts";
import SitegenWrap from "./sitegen-wrap.marko";
@@ -429,4 +429,4 @@ import * as fonts from "./font.ts";
import * as hot from "./hot.ts";
import * as incr from "./incremental.ts";
import { Io } from "./incremental.ts";
-import { ASSERT, UNWRAP } from "lib/assert.ts";
+import { ASSERT, UNWRAP } from "@clo/lib/assert.ts";
diff --git a/framework/hot.ts b/framework/hot.ts
index 4bd825bbebf23e7bec611665441db37aa3c6dc0b..f2826f2f0e513eabb547c474399dbed71424c82a 100644
--- a/framework/hot.ts
+++ b/framework/hot.ts
@@ -90,25 +90,6 @@ Module.prototype._compile = function (
return result;
};
-// Implement @/ prefix
-const ModuleUnderscoreResolveFilename = Module._resolveFilename;
-Module._resolveFilename = (...args) => {
- if (args[0].startsWith("@/")) {
- const replacedPath = "." + args[0].slice(1);
- try {
- return require.resolve(replacedPath, { paths: [projectSrc] });
- } catch (err: any) {
- if (
- err.code === "MODULE_NOT_FOUND" &&
- (err?.requireStack?.length ?? 0) <= 1
- ) {
- err.message.replace(replacedPath, args[0]);
- }
- }
- }
- return ModuleUnderscoreResolveFilename(...args);
-};
-
function loadEsbuild(module: NodeJS.Module, filepath: string) {
return loadEsbuildCode(module, filepath, fs.readFileSync(filepath, "utf8"));
}
@@ -323,4 +304,4 @@ import * as esbuild from "esbuild";
import { createRequire } from "node:module";
import * as self from "./hot.ts";
import { Buffer } from "node:buffer";
-import { UNWRAP } from "lib/assert.ts";
+import { UNWRAP } from "@clo/lib/assert.ts";
diff --git a/framework/incremental.ts b/framework/incremental.ts
index a4468807c958e01ab90fe1b157916a5b554debe2..88d31d2f111b5706b0485c7487a21626ebbc4b22 100644
--- a/framework/incremental.ts
+++ b/framework/incremental.ts
@@ -728,7 +728,7 @@ const zstdCompress = util.promisify(zlib.zstdCompress);
import * as hot from "./hot.ts";
import * as fs from "#sitegen/fs";
-import * as mime from "lib/mime.ts";
+import * as mime from "@clo/lib/mime.ts";
import * as manifest from "#sitegen/assets";
import * as path from "node:path";
@@ -736,9 +736,9 @@ import * as util from "node:util";
import * as crypto from "node:crypto";
import * as zlib from "node:zlib";
-import * as progress from "lib/progress.ts";
-import * as stack from "lib/log/stack.ts";
-import { formatSize } from "@/file-viewer/format.ts";
+import * as progress from "@clo/lib/progress.ts";
+import * as stack from "@clo/lib/log/stack.ts";
+import { formatSize } from "#src/file-viewer/format.ts";
import * as msgpackr from "msgpackr";
-import { ASSERT, UNWRAP } from "lib/assert.ts";
+import { ASSERT, UNWRAP } from "@clo/lib/assert.ts";
diff --git a/framework/lib/assets.ts b/framework/lib/assets.ts
index 94e658ae2a9b75bb2db8238b92acfc26120b05d0..b870367ff6c58929b025cbc3f3443ecb8e30f5f9 100644
--- a/framework/lib/assets.ts
+++ b/framework/lib/assets.ts
@@ -285,5 +285,5 @@ import type { AssetKey as Key } from "../../.clover/ts/asset.d.ts";
import * as crypto from "node:crypto";
import * as zlib from "node:zlib";
import * as util from "node:util";
-import * as log from "lib/log.ts";
-import { ASSERT, UNWRAP } from "lib/assert.ts";
+import * as log from "@clo/lib/log.ts";
+import { ASSERT, UNWRAP } from "@clo/lib/assert.ts";
diff --git a/framework/lib/path.ts b/framework/lib/path.ts
index d6fd2dded098765ec9688870b17eb36668a6675c..2cd99149bbc44f8c1c2aefefdbef62b8304a7e91 100644
--- a/framework/lib/path.ts
+++ b/framework/lib/path.ts
@@ -211,6 +211,6 @@ export class Path {
import * as path from "node:path";
import * as fs from "./fs.ts";
import * as util from "node:util";
-import * as error from "lib/error.ts";
+import * as error from "@clo/lib/error.ts";
import type { RmOptions } from "node:fs";
-import { ASSERT } from "lib/assert.ts";
+import { ASSERT } from "@clo/lib/assert.ts";
diff --git a/framework/lib/sitegen.ts b/framework/lib/sitegen.ts
index 5b85bee0486de5dde60e21bc3e68fd8b57710ef9..55ae173d45a3df4eed88aeb1125a7c4336eefc99 100644
--- a/framework/lib/sitegen.ts
+++ b/framework/lib/sitegen.ts
@@ -100,7 +100,7 @@ export function joinScripts(scriptSources: string[]) {
export { default as CloverScriptInclude } from "./add-script.marko";
-import * as render from "lib/render.ts";
-import type * as meta from "lib/render/meta.ts";
+import * as render from "@clo/lib/render.ts";
+import type * as meta from "@clo/lib/render/meta.ts";
import type * as css from "../css.ts";
-import { UNWRAP } from "lib/assert.ts";
+import { UNWRAP } from "@clo/lib/assert.ts";
diff --git a/framework/lib/view.ts b/framework/lib/view.ts
index 9c844437833035b83eedeb5d6115063a70c62d96..aeba4354152d0b9d9434a6daf351cf2358f59da5 100644
--- a/framework/lib/view.ts
+++ b/framework/lib/view.ts
@@ -117,14 +117,14 @@ export function regenerate(tag: RegenKey) {
}
}
-import * as meta from "lib/render/meta.ts";
+import * as meta from "@clo/lib/render/meta.ts";
import type * as hono from "#hono";
-import * as render from "lib/render.ts";
+import * as render from "@clo/lib/render.ts";
import * as sg from "./sitegen.ts";
import * as asset from "./assets.ts";
import type {
RegenKey,
RegisteredViews as ViewMap,
} from "../../.clover/ts/view.d.ts";
-import { UNWRAP } from "lib/assert.ts";
+import { UNWRAP } from "@clo/lib/assert.ts";
import SitegenWrap from "../sitegen-wrap.marko";
diff --git a/framework/watch.ts b/framework/watch.ts
index 4e8e2e5a353a3babe7dbe02ab557adea87999333..6a6195533e8b6c6cba47709992e36394054eaf41 100644
--- a/framework/watch.ts
+++ b/framework/watch.ts
@@ -170,4 +170,4 @@ import * as generate from "./generate.ts";
import * as incr from "./incremental.ts";
import * as path from "node:path";
import * as util from "node:util";
-import * as subprocess from "lib/subprocess.ts";
+import * as subprocess from "@clo/lib/subprocess.ts";
diff --git a/lib/deno.json b/lib/deno.json
index 43704fbd7ff49484986762f3d6968a59b6f35f2d..519c3b66ebadfe49171e8018e5946b5f9c381fe1 100644
--- a/lib/deno.json
+++ b/lib/deno.json
@@ -29,11 +29,11 @@
},
"compilerOptions": {
"jsx": "react-jsx",
- "jsxImportSource": "lib/render"
+ "jsxImportSource": "@clo/lib/render"
},
"imports": {
- "lib/render/jsx-runtime": "./render/jsx-runtime.ts",
- "lib/render/jsx-dev-runtime": "./render/jsx-runtime.ts"
+ "@clo/lib/render/jsx-runtime": "./render/jsx-runtime.ts",
+ "@clo/lib/render/jsx-dev-runtime": "./render/jsx-runtime.ts"
},
"exclude": [
"readme.npm.md",
diff --git a/lib/log/stack.ts b/lib/log/stack.ts
index 67dc12196c615c98e1cbdaaf7fd9c27b7fbb234d..6abc031cadb7acaeba1156737b44a64c887d949a 100644
--- a/lib/log/stack.ts
+++ b/lib/log/stack.ts
@@ -19,7 +19,7 @@
* }
*
* import * as fs from "node:fs";
- * import * as stack from "lib/log/stack.ts";
+ * import * as stack from "@clo/lib/log/stack.ts";
* ```
*
* @module
diff --git a/lib/mime.test.ts b/lib/mime.test.ts
index 8e130a08fb98e94eed36d102ec0272abbb317a5c..126054f3bff080cb533f0b8f8190d7156f449432 100644
--- a/lib/mime.test.ts
+++ b/lib/mime.test.ts
@@ -25,4 +25,4 @@ test("for", () => {
import { test } from "node:test";
import assert from "node:assert";
-import * as mime from "lib/mime.ts";
+import * as mime from "@clo/lib/mime.ts";
diff --git a/lib/progress.ts b/lib/progress.ts
index f43bae9900a26396d4f888dd659733032f8bad0b..f238c93c5d885b22a4123f6fda710cf0a07330ff 100644
--- a/lib/progress.ts
+++ b/lib/progress.ts
@@ -74,7 +74,7 @@ export function start(text: string, opts?: StartOptions): Node {
*
* ```ts
* await ffmpeg.spawn({
- * cmd: ["-i", "hello.mov", "-c:v", "libsvtav1", "hello.mp4"],
+ * cmd: ["-i", "hello.mov", "-c:v", "@clo/libsvtav1", "hello.mp4"],
* progress: progress.start("encode hello.mov"),
* });
* ```
diff --git a/lib/string/ansi.test.ts b/lib/string/ansi.test.ts
index e48423bf4675a6002c0004624cd8d544a8e0eb09..ac9a719b04e483ab2f5bc3ffa72412f7e8d13aca 100644
--- a/lib/string/ansi.test.ts
+++ b/lib/string/ansi.test.ts
@@ -21,4 +21,4 @@ test("trimToWidth", () => {
import { test } from "node:test";
import assert from "node:assert";
-import * as ansi from "lib/string/ansi.ts";
+import * as ansi from "@clo/lib/string/ansi.ts";
diff --git a/lib/subprocess/ffmpeg.ts b/lib/subprocess/ffmpeg.ts
index c452209e6cbe40aeb93527afa1f1101ef8baf290..71fcd878d4521fab64b52586fe296c53567c537f 100644
--- a/lib/subprocess/ffmpeg.ts
+++ b/lib/subprocess/ffmpeg.ts
@@ -13,7 +13,7 @@ export interface SpawnOptions {
*
* ```ts
* await ffmpeg.spawn({
- * cmd: ["-i", "hello.mov", "-c:v", "libsvtav1", "hello.mp4"],
+ * cmd: ["-i", "hello.mov", "-c:v", "@clo/libsvtav1", "hello.mp4"],
* progress: progress.start("encode hello.mov"),
* });
* ```
diff --git a/package-lock.json b/package-lock.json
index ea91650f189a7482276d8bdccb92e1a8a29fb8eb..7235f684ca9a25a1e0b704c47612a47adef73be1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5,6 +5,7 @@
"packages": {
"": {
"dependencies": {
+ "@clo/lib": "file:lib",
"@clo/markodown": "npm:@paperclover/markodown@rc",
"@hono/node-server": "1.14.3",
"@marko/compiler": "^5.39.55",
@@ -15,7 +16,6 @@
"esbuild": "0.25.5",
"hls.js": "1.6.5",
"hono": "4.11.9",
- "lib": "file:lib",
"marko": "^5.38.24",
"msgpackr": "1.11.5",
"playwright": "1.58.2",
@@ -26,7 +26,11 @@
"vscode-textmate": "9.2.0"
}
},
- "lib": {},
+ "@clo/lib": {},
+ "node_modules/@clo/lib": {
+ "resolved": "@clo/lib",
+ "link": true
+ },
"node_modules/@clo/markodown": {
"name": "@paperclover/markodown",
"version": "1.0.0-rc.15",
@@ -1077,10 +1081,6 @@
"lasso-caching-fs": "^1.0.0"
}
},
- "node_modules/lib": {
- "resolved": "lib",
- "link": true
- },
"node_modules/lie": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz",
diff --git a/package.json b/package.json
index 6942fc60f72d1583419c10fa1d24ac7224467549..28d6d6d98a4abb85be945c86f9f1287c7c4a7d82 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
"esbuild": "0.25.5",
"hls.js": "1.6.5",
"hono": "4.11.9",
- "lib": "file:lib",
+ "@clo/lib": "file:lib",
"marko": "^5.38.24",
"msgpackr": "1.11.5",
"playwright": "1.58.2",
@@ -22,6 +22,7 @@
"vscode-textmate": "9.2.0"
},
"imports": {
+ "#src/*": "./src/*",
"#sitegen": "./framework/lib/sitegen.ts",
"#sitegen/*": "./framework/lib/*.ts",
"#jsx/jsx-runtime": "./lib/render/jsx-runtime.ts",
diff --git a/src/backend.ts b/src/backend.ts
index bc1073e243f6395e6c45499fec105d882452b9d8..1bccfa6770eb11d794c88d2f8feb37db36ec8abc 100644
--- a/src/backend.ts
+++ b/src/backend.ts
@@ -64,4 +64,4 @@ import { logger } from "hono/logger";
import { trimTrailingSlash } from "hono/trailing-slash";
import * as assets from "#sitegen/assets";
import * as admin from "./admin.ts";
-import * as log from "lib/log.ts";
+import * as log from "@clo/lib/log.ts";
diff --git a/src/bin/deploy.ts b/src/bin/deploy.ts
index 313b127cf3fb32b8cba59859016ffb31127fe599..354ff94c5983cee7c86d185a12a3e2a2ca115568 100644
--- a/src/bin/deploy.ts
+++ b/src/bin/deploy.ts
@@ -55,7 +55,7 @@ export async function main() {
import * as incr from "../../framework/incremental.ts";
import { generate } from "../../framework/generate.ts";
-import * as progress from "lib/progress.ts";
-import * as subprocess from "lib/subprocess.ts";
+import * as progress from "@clo/lib/progress.ts";
+import * as subprocess from "@clo/lib/subprocess.ts";
import * as rsync from "../file-viewer/rsync.ts";
import { Path } from "#sitegen/path";
diff --git a/src/bin/download-db.ts b/src/bin/download-db.ts
index 1d40fa9c87384595eec28702481f2c88df3e1553..4ade011611d097ef12b32306fb6ed94b6737a8c6 100644
--- a/src/bin/download-db.ts
+++ b/src/bin/download-db.ts
@@ -21,6 +21,6 @@ export async function main() {
});
}
-import * as progress from "lib/progress.ts";
+import * as progress from "@clo/lib/progress.ts";
import * as rsync from "../file-viewer/rsync.ts";
import { Path } from "#sitegen/path";
diff --git a/src/bin/package-lib.ts b/src/bin/package-lib.ts
index 0680dfb05bb08d47ef2d797bbb7e7d8f1cd9957a..a98b2e96f9e39d256f4a67e04539d43bf52e025e 100644
--- a/src/bin/package-lib.ts
+++ b/src/bin/package-lib.ts
@@ -21,10 +21,10 @@ export async function updateJsrPackageExportsToAll(
}
export async function main() {
- const main = path.resolve("lib");
+ const main = path.resolve("@clo/lib");
await updateJsrPackageExportsToAll(main, progress);
}
-import * as progress from "lib/progress.ts";
+import * as progress from "@clo/lib/progress.ts";
import * as path from "node:path";
import * as fs from "node:fs/promises";
diff --git a/src/blog/drafts/webdev/marko-intro.markodown b/src/blog/drafts/webdev/marko-intro.markodown
index 456bdeee8e047e4a0a6d894a6c2aa209cf6bd029..50cc917b10b37b4990cf63b60a9d78016aa270f2 100644
--- a/src/blog/drafts/webdev/marko-intro.markodown
+++ b/src/blog/drafts/webdev/marko-intro.markodown
@@ -5,7 +5,7 @@ export const blog: BlogMeta = {
draft: true,
};
export const meta = formatBlogMeta(blob);
-export * as layout from "@/blog/layout.tsx";
+export * as layout from "#src/blog/layout.tsx";
I've been recently playing around [Marko], and after adding limited support
for it in my website generator, [sitegen], I instantly fell in love with how
@@ -287,8 +287,8 @@ function Page() {
console.info(render.sync().text);
import * as render from "#engine/render";
-import QuestionRender from "@/q+a/tags/question.marko";
-import { Question } from "@/q+a/models/Question.ts";
+import QuestionRender from "#src/q+a/tags/question.marko";
+import { Question } from "#src/q+a/models/Question.ts";
```
Here is the `question.marko` tag used to render [questions on the clover q+a](/q+a).
@@ -328,12 +328,12 @@ export const transitionDate = 1735639200000;
// this singleton script will make all the '