@chidchanun/bcp 0.1.4 → 0.1.6

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  All notable framework changes are tracked here before release.
4
4
 
5
+ ## 0.1.6 - Critical CSS and release visibility
6
+
7
+ ### Performance
8
+
9
+ - Small generated `/bcp.css` stylesheets are inlined into SSR HTML when they are 8 KiB or smaller, removing the stylesheet request from the initial render-critical path.
10
+ - Critical CSS optimization is applied in development and standalone production.
11
+ - Gzip, Brotli and deflate HTML responses are decoded, transformed and re-encoded so response compression remains intact.
12
+ - Applications with CSP policies that do not allow inline styles automatically keep the external `/bcp.css` link instead of breaking page styling.
13
+ - Critical CSS transformation is skipped entirely when the stylesheet is missing or larger than the inline threshold.
14
+
15
+ ### Reliability and release tooling
16
+
17
+ - Added regression tests for critical CSS inlining, size fallback, closing-style escaping, compressed responses and CSP fallback.
18
+ - Added `release:visibility-check` so an npm release is not considered ready until the exact framework and generator versions are readable from the registry.
19
+ - `release:publish:yes` and `release:resume` now run the registry visibility check after npm accepts the publish.
20
+
21
+ ## 0.1.5 - Application module boundaries
22
+
23
+ ### Developer experience
24
+
25
+ - Added the `@/` project-root alias for generated applications across TypeScript and BCP runtime resolution.
26
+ - Generated applications use TypeScript Bundler module resolution so extensionless application imports match BCP runtime behavior.
27
+ - React client hooks in hydrated application modules require an explicit `"use client"` directive.
28
+ - Added `bcp/server-only` to prevent server dependencies from entering hydrated client bundles.
29
+ - Database helpers generated by `create-bcp-app` are marked server-only automatically and are intended to be consumed from API routes.
30
+ - Development HTTP request logs now focus on application API traffic and suppress `/_bcp/*`, page/static requests and the legacy internal Tailwind stylesheet endpoint.
31
+ - Generated Tailwind projects now link `/bcp.css` directly from `public/` instead of routing CSS through `/api/bcp-styles`, shortening the initial request path and allowing normal static-asset caching/revalidation.
32
+
5
33
  ## 0.1.4 - Tailwind runtime fix
6
34
 
7
35
  ### create-bcp-app
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  BCP Framework is a React full-stack framework with file-based routing, SSR, client navigation, API routes, middleware, metadata, client islands, cache/revalidation, security defaults and standalone production builds.
4
4
 
5
- > Current status: pre-release `0.1.0`. The repository can produce npm-ready tarballs, validate Release Candidates and run npm publish dry-runs, but publishing to npm is intentionally a separate manual release action.
5
+ > Current development version: `0.1.6`. BCP is still pre-1.0 and validates each release candidate before the manual npm publish step.
6
6
 
7
7
  ## Quick start
8
8
 
@@ -40,12 +40,47 @@ app/
40
40
  └─ hello/
41
41
  └─ route.ts
42
42
 
43
+ lib/
43
44
  public/
44
45
  bcp.config.ts
45
46
  package.json
46
47
  tsconfig.json
47
48
  ```
48
49
 
50
+ ## Application imports and boundaries
51
+
52
+ Generated applications include the project-root `@/` alias:
53
+
54
+ ```ts
55
+ import {
56
+ db,
57
+ } from "@/lib/database";
58
+ ```
59
+
60
+ Modules that use React client hooks must declare `"use client"`:
61
+
62
+ ```tsx
63
+ "use client";
64
+
65
+ import {
66
+ useState,
67
+ } from "react";
68
+ ```
69
+
70
+ Server-only modules can declare:
71
+
72
+ ```ts
73
+ import "bcp/server-only";
74
+ ```
75
+
76
+ Database helpers generated by `create-bcp-app` include the server-only marker automatically. A server-only helper must not be imported from a page/client graph; put database work behind an API route instead.
77
+
78
+ See [Application Modules](docs/application-modules.md) for the complete boundary model and examples.
79
+
80
+ ## Tailwind and critical CSS
81
+
82
+ Generated Tailwind projects compile to `public/bcp.css`. BCP 0.1.6 inlines that stylesheet into SSR HTML when it is 8 KiB or smaller, removing the stylesheet request from the initial render-critical path. Larger stylesheets remain external so the browser can cache them normally. If the application's Content Security Policy does not allow inline styles, BCP automatically keeps the external stylesheet link.
83
+
49
84
  ## Commands
50
85
 
51
86
  ```bash
@@ -217,6 +252,8 @@ npm run rc:check
217
252
 
218
253
  `rc:check` validates tests/release metadata, checks npm package-name availability or ownership, performs `npm publish --dry-run`, and clean-installs both generated tarballs into temporary projects.
219
254
 
255
+ After a real publish, `npm run release:visibility-check` verifies that the exact framework and generator versions are readable from the npm registry before the release is treated as ready for installation.
256
+
220
257
  `package:prepare` stages the framework at `.package/bcp`. The default package name is `bcp`; set `BCP_PACKAGE_NAME` when preparing a scoped or alternate package name.
221
258
 
222
259
  No real npm publish command is run automatically by the repository.
@@ -224,6 +261,7 @@ No real npm publish command is run automatically by the repository.
224
261
  ## Documentation
225
262
 
226
263
  - [Getting Started](docs/getting-started.md)
264
+ - [Application Modules](docs/application-modules.md)
227
265
  - [Routing](docs/routing.md)
228
266
  - [Configuration](docs/configuration.md)
229
267
  - [Caching](docs/caching.md)
@@ -0,0 +1,116 @@
1
+ # Application Modules
2
+
3
+ BCP applications can import project files through the project-root `@/` alias.
4
+
5
+ ```ts
6
+ import {
7
+ db,
8
+ } from "@/lib/database";
9
+ ```
10
+
11
+ The generated `tsconfig.json` maps `@/*` to the project root. BCP also installs a Node.js resolver during development so the same alias works in SSR and API route modules. Production builds resolve the alias through the application bundler.
12
+
13
+ ## Client modules
14
+
15
+ A page or shared module that uses React client hooks must begin with the `"use client"` directive.
16
+
17
+ ```tsx
18
+ "use client";
19
+
20
+ import {
21
+ useEffect,
22
+ useState,
23
+ } from "react";
24
+
25
+ export default function UsersPage() {
26
+ const [users, setUsers] =
27
+ useState([]);
28
+
29
+ useEffect(
30
+ () => {
31
+ void fetch("/api/users")
32
+ .then(
33
+ (response) =>
34
+ response.json()
35
+ )
36
+ .then(
37
+ setUsers
38
+ );
39
+ },
40
+ []
41
+ );
42
+
43
+ return (
44
+ <pre>
45
+ {JSON.stringify(users, null, 2)}
46
+ </pre>
47
+ );
48
+ }
49
+ ```
50
+
51
+ BCP checks client-reachable page/layout module graphs at development startup and production build time. Using React client hooks without `"use client"` causes a boundary error.
52
+
53
+ Client island files (`*.island.ts` and `*.island.tsx`) are already explicit client entry points and keep their existing island semantics.
54
+
55
+ ## Server-only modules
56
+
57
+ Use `bcp/server-only` in modules that contain database clients, secrets, filesystem access, or other code that must never enter a browser bundle.
58
+
59
+ ```ts
60
+ import "bcp/server-only";
61
+
62
+ import mysql from "mysql2/promise";
63
+
64
+ export const db =
65
+ mysql.createPool(
66
+ process.env.DATABASE_URL ??
67
+ ""
68
+ );
69
+ ```
70
+
71
+ Database helpers generated by `create-bcp-app` include this marker automatically.
72
+
73
+ Do not import a server-only module directly from a page or client component:
74
+
75
+ ```ts
76
+ // Not allowed in a page/client graph
77
+ import {
78
+ db,
79
+ } from "@/lib/database";
80
+ ```
81
+
82
+ Put the database operation behind an API route instead:
83
+
84
+ ```ts
85
+ // app/api/users/route.ts
86
+ import {
87
+ db,
88
+ } from "@/lib/database";
89
+
90
+ export async function GET() {
91
+ const [rows] =
92
+ await db.query(
93
+ "SELECT * FROM users"
94
+ );
95
+
96
+ return Response.json({
97
+ data: rows,
98
+ });
99
+ }
100
+ ```
101
+
102
+ Then call the API from the client:
103
+
104
+ ```ts
105
+ const response =
106
+ await fetch(
107
+ "/api/users"
108
+ );
109
+
110
+ const result =
111
+ await response.json();
112
+ ```
113
+
114
+ ## Current boundary model
115
+
116
+ BCP 0.1.x is not a React Server Components implementation. Pages and layouts can participate in browser hydration, so server-only dependencies must remain behind API routes or other server execution paths. The boundary checks are designed to make that rule explicit and prevent accidental database or secret-bearing code from entering client bundles.
@@ -0,0 +1,13 @@
1
+ # Development request logging
2
+
3
+ BCP keeps development request output focused on application API traffic.
4
+
5
+ By default, request-style console lines are shown for application API routes such as:
6
+
7
+ ```text
8
+ GET /api/users 200 1.24ms
9
+ ```
10
+
11
+ BCP suppresses framework and browser bootstrap traffic such as `/_bcp/*`, page/document requests, public static assets, and the generated Tailwind stylesheet endpoint `/api/bcp-styles`.
12
+
13
+ Build, SSR, Fast Refresh, watcher and error diagnostics are not affected by this filter.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chidchanun/bcp",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "BCP Framework - a React full-stack framework with file-based routing, SSR, APIs, middleware, islands, caching and standalone production builds.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,6 +43,11 @@
43
43
  "types": "./packages/client/src/config.ts",
44
44
  "default": "./packages/client/src/config.ts"
45
45
  },
46
+ "./server-only": {
47
+ "types": "./packages/client/src/server-only.d.ts",
48
+ "browser": "./packages/client/src/server-only.browser.mjs",
49
+ "default": "./packages/client/src/server-only.mjs"
50
+ },
46
51
  "./middleware": {
47
52
  "types": "./packages/server/src/middleware.ts",
48
53
  "default": "./packages/server/src/middleware.ts"