@akanjs/devkit 3.0.0-alpha.94 → 3.0.0-alpha.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import {
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
3
|
+
import { AKAN_BACKEND_MINIFY, AKAN_OPTIONAL_BACKEND_EXTERNALS } from "./applicationBuildRunner";
|
|
3
4
|
|
|
4
5
|
describe("ApplicationBuildRunner", () => {
|
|
5
6
|
test("externalizes Akan optional backend dependencies", () => {
|
|
@@ -7,4 +8,38 @@ describe("ApplicationBuildRunner", () => {
|
|
|
7
8
|
expect.arrayContaining(["@libsql/client", "bullmq", "ioredis", "postgres", "protobufjs"]),
|
|
8
9
|
);
|
|
9
10
|
});
|
|
11
|
+
|
|
12
|
+
test("keeps backend identifiers so a class names its own logger and stack frames", () => {
|
|
13
|
+
expect(AKAN_BACKEND_MINIFY.identifiers).toBe(false);
|
|
14
|
+
expect(AKAN_BACKEND_MINIFY.whitespace).toBe(true);
|
|
15
|
+
expect(AKAN_BACKEND_MINIFY.syntax).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("a bundler that mangles identifiers loses the class name a Logger reads", async () => {
|
|
19
|
+
const dir = `${process.env.TMPDIR ?? "/tmp"}/akan-minify-${Bun.randomUUIDv7()}`;
|
|
20
|
+
const entry = `${dir}/entry.ts`;
|
|
21
|
+
await Bun.write(
|
|
22
|
+
entry,
|
|
23
|
+
`const serve = () => class Service { readonly name = this.constructor.name; };
|
|
24
|
+
export class SampleService extends serve() {}
|
|
25
|
+
console.info(new SampleService().name);
|
|
26
|
+
`,
|
|
27
|
+
);
|
|
28
|
+
const build = async (minify: Bun.BuildConfig["minify"]) => {
|
|
29
|
+
const result = await Bun.build({ entrypoints: [entry], target: "bun", minify, outdir: `${dir}/out` });
|
|
30
|
+
expect(result.success).toBe(true);
|
|
31
|
+
const proc = Bun.spawn([process.execPath, result.outputs[0].path], { stdout: "pipe" });
|
|
32
|
+
return (await new Response(proc.stdout).text()).trim();
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
expect(await build(AKAN_BACKEND_MINIFY)).toBe("SampleService");
|
|
36
|
+
expect(await build(true)).not.toBe("SampleService");
|
|
37
|
+
// Bun 1.4.2 accepts `keepNames` and ignores it; drop this expectation once it keeps the name.
|
|
38
|
+
expect(await build({ whitespace: true, syntax: true, identifiers: true, keepNames: true })).not.toBe(
|
|
39
|
+
"SampleService",
|
|
40
|
+
);
|
|
41
|
+
} finally {
|
|
42
|
+
await rm(dir, { recursive: true, force: true });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
10
45
|
});
|
|
@@ -60,6 +60,11 @@ const SSR_RENDER_EXTERNALS = [
|
|
|
60
60
|
"react-server-dom-webpack/client.browser",
|
|
61
61
|
] as const;
|
|
62
62
|
|
|
63
|
+
// Identifier mangling renames every class, and `this.constructor.name` is what names a service's logger, an
|
|
64
|
+
// `Exception`, a guard, and every frame of a stack trace — for ~2% of boot on server bytes nothing downloads.
|
|
65
|
+
// `minify.keepNames` typechecks and does nothing as of Bun 1.4.2.
|
|
66
|
+
export const AKAN_BACKEND_MINIFY = { whitespace: true, syntax: true, identifiers: false } as const;
|
|
67
|
+
|
|
63
68
|
export const AKAN_OPTIONAL_BACKEND_EXTERNALS = [
|
|
64
69
|
"@libsql/client",
|
|
65
70
|
"bullmq",
|
|
@@ -203,7 +208,7 @@ export class ApplicationBuildRunner {
|
|
|
203
208
|
entrypoints: backendEntryPoints,
|
|
204
209
|
outdir: this.#app.dist.cwdPath,
|
|
205
210
|
target: "bun",
|
|
206
|
-
minify:
|
|
211
|
+
minify: AKAN_BACKEND_MINIFY,
|
|
207
212
|
naming: { entry: "[name].[ext]", chunk: "chunk-[hash].[ext]" },
|
|
208
213
|
define: { "process.env.NODE_ENV": JSON.stringify("production") },
|
|
209
214
|
plugins: backendExternals.length > 0 ? [this.#createExternalSpecifiersPlugin(backendExternals)] : [],
|
|
@@ -214,7 +219,7 @@ export class ApplicationBuildRunner {
|
|
|
214
219
|
entrypoints: [this.#resolveRscWorkerBuildEntry()],
|
|
215
220
|
outdir: this.#app.dist.cwdPath,
|
|
216
221
|
target: "bun",
|
|
217
|
-
minify:
|
|
222
|
+
minify: AKAN_BACKEND_MINIFY,
|
|
218
223
|
naming: { entry: "[name].[ext]", chunk: "chunk-[hash].[ext]" },
|
|
219
224
|
conditions: ["react-server"],
|
|
220
225
|
// `akan build` must embed production react-server-dom regardless of the shell's NODE_ENV.
|
|
@@ -226,7 +231,7 @@ export class ApplicationBuildRunner {
|
|
|
226
231
|
entrypoints: [this.#resolveConsoleRuntimeBuildEntry()],
|
|
227
232
|
outdir: this.#app.dist.cwdPath,
|
|
228
233
|
target: "bun",
|
|
229
|
-
minify:
|
|
234
|
+
minify: AKAN_BACKEND_MINIFY,
|
|
230
235
|
naming: { entry: "console-runtime.[ext]", chunk: "chunk-[hash].[ext]" },
|
|
231
236
|
define: { "process.env.NODE_ENV": JSON.stringify("production") },
|
|
232
237
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.96",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@langchain/openai": "^1.4.6",
|
|
45
45
|
"@tailwindcss/node": "^4.3.0",
|
|
46
46
|
"@trapezedev/project": "^7.1.4",
|
|
47
|
-
"akanjs": "3.0.0-alpha.
|
|
47
|
+
"akanjs": "3.0.0-alpha.96",
|
|
48
48
|
"chalk": "^5.6.2",
|
|
49
49
|
"commander": "^14.0.3",
|
|
50
50
|
"dayjs": "^1.11.20",
|