@becklyn/deployment-protection 0.4.0 → 0.4.1

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/README.md CHANGED
@@ -26,9 +26,9 @@ npm i @becklyn/deployment-protection
26
26
 
27
27
  ### Storybook (static on Vercel)
28
28
 
29
- Built Storybook is static (`storybook-static`), so protection is **Vercel Edge Middleware** — not a Storybook addon.
29
+ Built Storybook is static (`storybook-static`), so protection is **Vercel Routing Middleware** — not a Storybook addon.
30
30
 
31
- 1. Install the package in the project that deploys Storybook.
31
+ 1. Install the package in the project that deploys Storybook (published build, or workspace package after `npm run build`).
32
32
  2. Add `middleware.ts` at the **Vercel project root** (same level Vercel uses for `vercel.json` / output):
33
33
 
34
34
  ```ts
@@ -42,7 +42,7 @@ export const config = {
42
42
  ```
43
43
 
44
44
  3. Set the same environment variables as for Next.js (below).
45
- 4. Optional `vercel.json` for a Storybook-only project:
45
+ 4. `vercel.json` for a Storybook-only project — **`framework` must be `null`** (Other). Do **not** use the Vercel “Storybook” framework preset; it sets `disableRootMiddleware` and skips middleware entirely:
46
46
 
47
47
  ```json
48
48
  {
@@ -54,6 +54,8 @@ export const config = {
54
54
 
55
55
  `withStorybookDeploymentProtection` does **not** require the `next` package. The matcher must stay a **string literal** in `middleware.ts` (same static-analysis rule as Next.js).
56
56
 
57
+ Prefer the default **edge** runtime. `runtime: "nodejs"` is supported as well — both resolve to a self-contained ESM bundle (`dist/storybook.mjs` / `dist/edge.mjs`) so Vercel does not need to trace the multi-file tsc graph.
58
+
57
59
  Framework-agnostic alias (same implementation):
58
60
 
59
61
  ```ts
@@ -1,10 +1,14 @@
1
1
  /**
2
2
  * Storybook deployment protection for Vercel.
3
3
  *
4
- * Built Storybooks are static sites, so protection runs as **Vercel Edge Middleware**
4
+ * Built Storybooks are static sites, so protection runs as **Vercel Routing Middleware**
5
5
  * (not Storybook config). Drop a `middleware.ts` next to the Vercel project root that
6
6
  * serves `storybook-static` and set the same env vars as the Next.js integration.
7
7
  *
8
+ * The published `./storybook` and `./edge` entry points resolve to self-contained ESM
9
+ * bundles so Vercel edge/nodejs middleware can load them without tracing multi-file
10
+ * package internals.
11
+ *
8
12
  * @example middleware.ts
9
13
  * ```ts
10
14
  * import { withStorybookDeploymentProtection } from "@becklyn/deployment-protection/storybook";
@@ -19,7 +23,7 @@
19
23
  * };
20
24
  * ```
21
25
  *
22
- * Optional `vercel.json` for a Storybook-only project:
26
+ * Optional `vercel.json` for a Storybook-only project (`framework` must be `null`):
23
27
  * ```json
24
28
  * {
25
29
  * "buildCommand": "npm run build-storybook",
@@ -1 +1 @@
1
- {"version":3,"file":"storybook.d.ts","sourceRoot":"","sources":["../../src/storybook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EACH,qBAAqB,EACrB,4BAA4B,IAAI,iCAAiC,GACpE,MAAM,QAAQ,CAAC;AAChB,YAAY,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"storybook.d.ts","sourceRoot":"","sources":["../../src/storybook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EACH,qBAAqB,EACrB,4BAA4B,IAAI,iCAAiC,GACpE,MAAM,QAAQ,CAAC;AAChB,YAAY,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC"}
@@ -4,10 +4,14 @@ exports.withStorybookDeploymentProtection = exports.middlewarePassThrough = void
4
4
  /**
5
5
  * Storybook deployment protection for Vercel.
6
6
  *
7
- * Built Storybooks are static sites, so protection runs as **Vercel Edge Middleware**
7
+ * Built Storybooks are static sites, so protection runs as **Vercel Routing Middleware**
8
8
  * (not Storybook config). Drop a `middleware.ts` next to the Vercel project root that
9
9
  * serves `storybook-static` and set the same env vars as the Next.js integration.
10
10
  *
11
+ * The published `./storybook` and `./edge` entry points resolve to self-contained ESM
12
+ * bundles so Vercel edge/nodejs middleware can load them without tracing multi-file
13
+ * package internals.
14
+ *
11
15
  * @example middleware.ts
12
16
  * ```ts
13
17
  * import { withStorybookDeploymentProtection } from "@becklyn/deployment-protection/storybook";
@@ -22,7 +26,7 @@ exports.withStorybookDeploymentProtection = exports.middlewarePassThrough = void
22
26
  * };
23
27
  * ```
24
28
  *
25
- * Optional `vercel.json` for a Storybook-only project:
29
+ * Optional `vercel.json` for a Storybook-only project (`framework` must be `null`):
26
30
  * ```json
27
31
  * {
28
32
  * "buildCommand": "npm run build-storybook",
@@ -0,0 +1,7 @@
1
+ {
2
+ "format": "esm",
3
+ "entries": [
4
+ "dist/edge.mjs",
5
+ "dist/storybook.mjs"
6
+ ]
7
+ }