@scenarist/nextjs-adapter 0.5.0 → 0.5.3

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
@@ -1630,22 +1630,14 @@ When tree-shaking succeeds, your production bundle has:
1630
1630
  - Next.js: Should work automatically
1631
1631
  - Custom bundlers: Add `conditions: ['production']`
1632
1632
 
1633
- 3. **Check dynamic imports:** Avoid dynamic imports that bypass tree-shaking
1633
+ 3. **Inspect bundle:** Search `.next/` for `__scenarist_shared_msw_server`, a global property name that survives minification
1634
1634
 
1635
- ```typescript
1636
- // ❌ BAD - Bypasses tree-shaking
1637
- const scenarist = await import('@scenarist/nextjs-adapter/app');
1638
-
1639
- // ✅ GOOD - Enables tree-shaking
1640
- import { createScenarist } from '@scenarist/nextjs-adapter/app';
1641
- const scenarist = createScenarist({ ... });
1642
- ```
1643
-
1644
- 4. **Inspect bundle:** Check `.next/` directory for MSW strings
1645
1635
  ```bash
1646
- grep -r "setupWorker\|HttpResponse\.json" .next/
1636
+ grep -rl --exclude-dir=cache "__scenarist_shared_msw_server" $(find .next -mindepth 1 -maxdepth 1 ! -name dev)
1647
1637
  ```
1648
1638
 
1639
+ Any file listed contains Scenarist and MSW code. The command skips the top-level `.next/dev` directory, which `next dev` writes and `next build` keeps, but still scans route folders named `dev` inside the production output. Do not rely on searching for MSW function names such as `setupWorker` or `HttpResponse.json`: minifiers rename them, so the search can miss MSW code.
1640
+
1649
1641
  ### Architecture Details
1650
1642
 
1651
1643
  The adapter uses **package.json conditional exports** to provide different entry points per environment:
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Next.js adapter for Scenarist.
3
+ *
4
+ * Provides MSW-based scenario management for Next.js applications (App Router and Pages Router).
5
+ *
6
+ * For App Router setup, helpers, and loggers, import from `@scenarist/nextjs-adapter/app`.
7
+ * For Pages Router setup, helpers, and loggers, import from `@scenarist/nextjs-adapter/pages`.
8
+ *
9
+ * Shared, router-agnostic Scenarist types are re-exported from the root entry point
10
+ * with zero runtime imports so production bundles remain unaffected.
11
+ *
12
+ * @module @scenarist/nextjs-adapter
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // Defining scenarios (router-agnostic)
17
+ * import type { ScenaristScenario, ScenaristScenarios } from '@scenarist/nextjs-adapter';
18
+ *
19
+ * export const defaultScenario: ScenaristScenario = {
20
+ * id: 'default',
21
+ * name: 'Default Scenario',
22
+ * description: 'Baseline mocks',
23
+ * mocks: [
24
+ * {
25
+ * method: 'GET',
26
+ * url: 'https://api.example.com/user',
27
+ * response: { status: 200, body: { name: 'Default User' } },
28
+ * },
29
+ * ],
30
+ * };
31
+ *
32
+ * export const scenarios = {
33
+ * default: defaultScenario,
34
+ * } as const satisfies ScenaristScenarios;
35
+ * ```
36
+ */
37
+ export type { ScenaristScenario, ScenaristMock, ScenaristResponse, ScenaristSequence, ScenaristMatch, ScenaristCaptureConfig, ScenaristScenarios, ScenaristConfig, ScenaristResult, Logger, LogLevel, LogCategory, LogContext, ConsoleLoggerConfig, LogFormat, } from "@scenarist/core";
38
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,MAAM,EACN,QAAQ,EACR,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,SAAS,GACV,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Next.js adapter for Scenarist.
3
+ *
4
+ * Provides MSW-based scenario management for Next.js applications (App Router and Pages Router).
5
+ *
6
+ * For App Router setup, helpers, and loggers, import from `@scenarist/nextjs-adapter/app`.
7
+ * For Pages Router setup, helpers, and loggers, import from `@scenarist/nextjs-adapter/pages`.
8
+ *
9
+ * Shared, router-agnostic Scenarist types are re-exported from the root entry point
10
+ * with zero runtime imports so production bundles remain unaffected.
11
+ *
12
+ * @module @scenarist/nextjs-adapter
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // Defining scenarios (router-agnostic)
17
+ * import type { ScenaristScenario, ScenaristScenarios } from '@scenarist/nextjs-adapter';
18
+ *
19
+ * export const defaultScenario: ScenaristScenario = {
20
+ * id: 'default',
21
+ * name: 'Default Scenario',
22
+ * description: 'Baseline mocks',
23
+ * mocks: [
24
+ * {
25
+ * method: 'GET',
26
+ * url: 'https://api.example.com/user',
27
+ * response: { status: 200, body: { name: 'Default User' } },
28
+ * },
29
+ * ],
30
+ * };
31
+ *
32
+ * export const scenarios = {
33
+ * default: defaultScenario,
34
+ * } as const satisfies ScenaristScenarios;
35
+ * ```
36
+ */
37
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scenarist/nextjs-adapter",
3
- "version": "0.5.0",
3
+ "version": "0.5.3",
4
4
  "description": "Next.js adapter for Scenarist (Pages Router and App Router)",
5
5
  "author": "Paul Hammond (citypaul) <paul@packsoftware.co.uk>",
6
6
  "license": "MIT",
@@ -58,9 +58,9 @@
58
58
  "LICENSE"
59
59
  ],
60
60
  "dependencies": {
61
- "@scenarist/core": "0.5.0",
62
- "@scenarist/msw-adapter": "0.5.0",
63
- "zod": "^4.6.5"
61
+ "@scenarist/core": "0.5.3",
62
+ "@scenarist/msw-adapter": "0.5.3",
63
+ "zod": "^4.6.7"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "msw": "^2.0.0",
@@ -69,13 +69,13 @@
69
69
  "devDependencies": {
70
70
  "@scenarist/eslint-config": "^0.0.0",
71
71
  "@scenarist/typescript-config": "0.0.0",
72
- "@types/node": "^25.9.8",
73
- "@vitest/coverage-v8": "^5.0.1",
72
+ "@types/node": "^25.9.9",
73
+ "@vitest/coverage-v8": "^5.1.1",
74
74
  "eslint": "^9.39.5",
75
75
  "msw": "^2.15.0",
76
- "next": "^16.3.5",
76
+ "next": "^16.4.6",
77
77
  "typescript": "^6.0.3",
78
- "vitest": "^5.0.1"
78
+ "vitest": "^5.1.1"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "tsc",