@pablozaiden/webapp 0.5.3 → 0.5.4

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.
@@ -17,6 +17,26 @@ await buildWebAppBinary({
17
17
  });
18
18
  ```
19
19
 
20
+ The binary builder compiles the browser bundle with the framework defaults needed for `webapp` apps, including Tailwind CSS v4 processing. If an app needs extra browser build behavior, add Bun plugins or browser-only defines under `web.build`:
21
+
22
+ ```ts
23
+ await buildWebAppBinary({
24
+ entrypoint: "src/index.ts",
25
+ outfile: "./dist/my-app",
26
+ web: {
27
+ entry: "./frontend.tsx",
28
+ build: {
29
+ plugins: [myBrowserPlugin],
30
+ define: {
31
+ "process.env.MY_BROWSER_FLAG": JSON.stringify("enabled"),
32
+ },
33
+ },
34
+ },
35
+ });
36
+ ```
37
+
38
+ App-provided plugins run before the framework defaults. Use `web.build.disableDefaultPlugins` only for specialized builds that intentionally replace the framework browser pipeline.
39
+
20
40
  Run the binary with the same CLI contract:
21
41
 
22
42
  ```bash
@@ -415,6 +415,8 @@ await buildWebAppBinary({
415
415
  });
416
416
  ```
417
417
 
418
+ `buildWebAppBinary` includes the framework browser build defaults, including Tailwind CSS v4 processing. Apps that need additional browser-only transforms can pass Bun plugins or defines through `web.build.plugins` and `web.build.define`; app plugins run before the framework defaults.
419
+
418
420
  ## Adaptation checklist
419
421
 
420
422
  1. Replace `my-app` everywhere with the binary name.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pablozaiden/webapp",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Opinionated Bun + React webapp framework for single-server apps",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -43,6 +43,7 @@
43
43
  "dependencies": {
44
44
  "@simplewebauthn/browser": "13.3.0",
45
45
  "@simplewebauthn/server": "13.3.1",
46
+ "bun-plugin-tailwind": "0.1.2",
46
47
  "jose": "6.2.3",
47
48
  "tailwindcss": "4.3.1",
48
49
  "zod": "4.4.3"
@@ -1,3 +1,5 @@
1
+ import type { BunPlugin } from "bun";
2
+ import tailwindPlugin from "bun-plugin-tailwind";
1
3
  import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
4
  import { basename, dirname, extname, resolve } from "node:path";
3
5
 
@@ -15,6 +17,11 @@ export interface BuildWebAppBinaryOptions {
15
17
  define?: Record<string, string>;
16
18
  web?: {
17
19
  entry?: string;
20
+ build?: {
21
+ plugins?: BunPlugin[];
22
+ define?: Record<string, string>;
23
+ disableDefaultPlugins?: boolean;
24
+ };
18
25
  };
19
26
  }
20
27
 
@@ -41,6 +48,10 @@ configureWebAppRenderer(createRoot);
41
48
  `);
42
49
  writeFileSync(clientEntry, `import ${JSON.stringify(webEntry)};
43
50
  `);
51
+ const browserPlugins = [
52
+ ...(options.web?.build?.plugins ?? []),
53
+ ...(options.web?.build?.disableDefaultPlugins ? [] : [tailwindPlugin]),
54
+ ];
44
55
  const browserBuild = await Bun.build({
45
56
  entrypoints: [rendererEntry, clientEntry],
46
57
  outdir: browserOutDir,
@@ -50,7 +61,8 @@ configureWebAppRenderer(createRoot);
50
61
  publicPath: "/webapp-compiled/",
51
62
  minify: true,
52
63
  sourcemap: "external",
53
- define: options.define,
64
+ define: { ...options.define, ...options.web?.build?.define },
65
+ plugins: browserPlugins,
54
66
  });
55
67
  if (!browserBuild.success) {
56
68
  for (const log of browserBuild.logs) {
@@ -1,5 +1,5 @@
1
1
  import type { Server, ServerWebSocket, WebSocketHandler } from "bun";
2
- import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
2
+ import { existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
3
3
  import { tmpdir } from "node:os";
4
4
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -181,7 +181,7 @@ function safeCachePathSegment(value: string): string {
181
181
  function createDocumentCacheDir(envPrefix: string): string {
182
182
  const root = join(tmpdir(), "webapp", safeCachePathSegment(envPrefix));
183
183
  mkdirSync(root, { recursive: true });
184
- const cacheDir = mkdtempSync(join(root, WEBAPP_DOCUMENT_CACHE_PREFIX));
184
+ const cacheDir = realpathSync(mkdtempSync(join(root, WEBAPP_DOCUMENT_CACHE_PREFIX)));
185
185
  documentCacheDirs.add(cacheDir);
186
186
  if (!documentCacheCleanupRegistered) {
187
187
  documentCacheCleanupRegistered = true;