cloudflare-next-intl 0.9.9 → 0.9.10

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,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- // Usage: cfni-check-dynamic-pages [--app-dir=src/app] [--mode=off|report|fix] [--skip=a/page.tsx,b/page.tsx]
3
- // Env equivalents: CFNI_DYNAMIC_PAGES_APP_DIR, CFNI_DYNAMIC_PAGES_MODE, CFNI_DYNAMIC_PAGES_SKIP (comma-separated).
2
+ // Usage: cfni-check-dynamic-pages [--app-dir=src/app] [--mode=off|report|fix] [--target=next|vinext] [--skip=a/page.tsx,b/page.tsx]
3
+ // Env equivalents: CFNI_DYNAMIC_PAGES_APP_DIR, CFNI_DYNAMIC_PAGES_MODE, CFNI_DYNAMIC_PAGES_TARGET, CFNI_DYNAMIC_PAGES_SKIP (comma-separated).
4
4
  import { resolve } from 'node:path';
5
5
  import { checkDynamicPages } from '../dist/src/dynamic_pages_check/check_dynamic_pages.js';
6
6
 
@@ -12,10 +12,11 @@ function argValue(name) {
12
12
 
13
13
  const appDir = resolve(argValue('app-dir') ?? process.env.CFNI_DYNAMIC_PAGES_APP_DIR ?? 'src/app');
14
14
  const mode = argValue('mode') ?? process.env.CFNI_DYNAMIC_PAGES_MODE ?? 'report';
15
+ const target = argValue('target') ?? process.env.CFNI_DYNAMIC_PAGES_TARGET ?? 'next';
15
16
  const skipRaw = argValue('skip') ?? process.env.CFNI_DYNAMIC_PAGES_SKIP ?? '';
16
17
  const skip = skipRaw.split(',').map((s) => s.trim()).filter(Boolean).map((s) => resolve(s));
17
18
 
18
- const reports = await checkDynamicPages({ appDir, mode, skip });
19
+ const reports = await checkDynamicPages({ appDir, mode, target, skip });
19
20
 
20
21
  if (reports.length === 0) {
21
22
  console.log(mode === 'off' ? 'checkDynamicPages: disabled (mode=off).' : `checkDynamicPages: no page/route files found under ${appDir}.`);
@@ -2,11 +2,12 @@ export type DynamicPagesCheckMode = 'off' | 'report' | 'fix';
2
2
  export interface CheckDynamicPagesOptions {
3
3
  appDir: string;
4
4
  mode?: DynamicPagesCheckMode;
5
+ target?: 'next' | 'vinext';
5
6
  skip?: readonly string[];
6
7
  }
7
8
  export interface CheckDynamicPagesReport {
8
9
  file: string;
9
- action: 'added-force-dynamic' | 'would-add-force-dynamic' | 'already-declared' | 'no-dynamic-usage-detected' | 'skipped';
10
+ action: 'added-force-dynamic' | 'would-add-force-dynamic' | 'added-force-static' | 'would-add-force-static' | 'already-declared' | 'no-dynamic-usage-detected' | 'skipped';
10
11
  }
11
12
  export interface CheckDynamicPagesIo {
12
13
  findPageFiles?: (appDir: string) => string[];
@@ -6,6 +6,7 @@ export async function checkDynamicPages(options, io = {}) {
6
6
  const mode = options.mode ?? 'report';
7
7
  if (mode === 'off')
8
8
  return [];
9
+ const target = options.target ?? 'next';
9
10
  const findPageFiles = io.findPageFiles ?? findPageFilesImpl;
10
11
  const readFile = io.readFile ?? ((file) => readFileSync(file, 'utf8'));
11
12
  const writeFile = io.writeFile ?? ((file, contents) => writeFileSync(file, contents, 'utf8'));
@@ -23,7 +24,17 @@ export async function checkDynamicPages(options, io = {}) {
23
24
  continue;
24
25
  }
25
26
  if (detection.detectedDynamicApis.length === 0) {
26
- reports.push({ file, action: 'no-dynamic-usage-detected' });
27
+ if (target !== 'vinext') {
28
+ reports.push({ file, action: 'no-dynamic-usage-detected' });
29
+ continue;
30
+ }
31
+ if (mode === 'fix') {
32
+ writeFile(file, insertDynamicExport(source, 'force-static'));
33
+ reports.push({ file, action: 'added-force-static' });
34
+ }
35
+ else {
36
+ reports.push({ file, action: 'would-add-force-static' });
37
+ }
27
38
  continue;
28
39
  }
29
40
  if (mode === 'fix') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.9.9",
3
+ "version": "0.9.10",
4
4
  "description": "Optimized Next Intl Package Special for App Router and Cloudflare",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",