cloudflare-next-intl 0.13.0 → 0.13.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.
@@ -8,6 +8,7 @@ export { userAgentStubPlugin, USER_AGENT_STUB_ID, USER_AGENT_STUB_CODE } from ".
8
8
  export { cfWorkersClientStubPlugin, CF_WORKERS_CLIENT_STUB_ID, CF_WORKERS_CLIENT_STUB_CODE } from "./cf_workers_client_stub.js";
9
9
  export { bufferStubPlugin, BUFFER_STUB_ID } from "./buffer_stub.js";
10
10
  export { tailwindSourcesPlugin } from "./tailwind_sources_plugin.js";
11
+ export { staticNotFoundNoStorePlugin, appendStaticNoStoreRule, STATIC_NO_STORE_RULE } from "./static_not_found_no_store.js";
11
12
  export { optionalFirebaseStubPlugin, optionalFirebaseStubId, optionalFirebaseStubCode, isModuleInstalled, OPTIONAL_FIREBASE_MODULES, OPTIONAL_FIREBASE_STUB_PREFIX, } from "./optional_firebase_stub.js";
12
13
  export { reactEvalStubPlugin, reactEvalEsbuildPlugin, transformReactEval, EVAL_WARNING_RE, EVAL_POLYFILL_SNIPPET, } from "./react_eval_stub.js";
13
14
  export { vinextRouteWiringFixPlugin, patchAppPageRouteWiring, isAppPageRouteWiringFile, isAppPageRouteWiringAlreadyFixed, isVinextAppPageRouteWiringSafeOnDisk, patchAppPageBoundaryRender, isAppPageBoundaryRenderFile, isAppPageBoundaryRenderAlreadyFixed, isVinextAppPageBoundaryRenderSafeOnDisk, resolveVinextAppPageBoundaryRenderPath, patchAppPageProbe, isAppPageProbeFile, isAppPageProbeAlreadyFixed, isVinextAppPageProbeSafeOnDisk, syncPatchVinextOnDisk, type VinextRouteWiringFixPluginOptions, } from "./vinext_route_wiring_fix.js";
@@ -8,6 +8,7 @@ export { userAgentStubPlugin, USER_AGENT_STUB_ID, USER_AGENT_STUB_CODE } from ".
8
8
  export { cfWorkersClientStubPlugin, CF_WORKERS_CLIENT_STUB_ID, CF_WORKERS_CLIENT_STUB_CODE } from "./cf_workers_client_stub.js";
9
9
  export { bufferStubPlugin, BUFFER_STUB_ID } from "./buffer_stub.js";
10
10
  export { tailwindSourcesPlugin } from "./tailwind_sources_plugin.js";
11
+ export { staticNotFoundNoStorePlugin, appendStaticNoStoreRule, STATIC_NO_STORE_RULE } from "./static_not_found_no_store.js";
11
12
  export { optionalFirebaseStubPlugin, optionalFirebaseStubId, optionalFirebaseStubCode, isModuleInstalled, OPTIONAL_FIREBASE_MODULES, OPTIONAL_FIREBASE_STUB_PREFIX, } from "./optional_firebase_stub.js";
12
13
  export { reactEvalStubPlugin, reactEvalEsbuildPlugin, transformReactEval, EVAL_WARNING_RE, EVAL_POLYFILL_SNIPPET, } from "./react_eval_stub.js";
13
14
  export { vinextRouteWiringFixPlugin, patchAppPageRouteWiring, isAppPageRouteWiringFile, isAppPageRouteWiringAlreadyFixed, isVinextAppPageRouteWiringSafeOnDisk, patchAppPageBoundaryRender, isAppPageBoundaryRenderFile, isAppPageBoundaryRenderAlreadyFixed, isVinextAppPageBoundaryRenderSafeOnDisk, resolveVinextAppPageBoundaryRenderPath, patchAppPageProbe, isAppPageProbeFile, isAppPageProbeAlreadyFixed, isVinextAppPageProbeSafeOnDisk, syncPatchVinextOnDisk, } from "./vinext_route_wiring_fix.js";
@@ -17,6 +17,7 @@ export interface CloudflareNextIntlOptions extends LocaleFilePluginOptions {
17
17
  userAgentStub?: boolean;
18
18
  cfWorkersClientStub?: boolean;
19
19
  tailwindSources?: boolean;
20
+ staticNotFoundNoStore?: boolean;
20
21
  bufferStub?: boolean;
21
22
  reactEvalStub?: boolean;
22
23
  optionalFirebaseStub?: boolean;
@@ -2,6 +2,7 @@ import { buildIdAsset } from "./build_id_asset.js";
2
2
  import { userAgentStubPlugin } from "./user_agent_stub.js";
3
3
  import { cfWorkersClientStubPlugin } from "./cf_workers_client_stub.js";
4
4
  import { tailwindSourcesPlugin } from "./tailwind_sources_plugin.js";
5
+ import { staticNotFoundNoStorePlugin } from "./static_not_found_no_store.js";
5
6
  import { bufferStubPlugin } from "./buffer_stub.js";
6
7
  import { reactEvalStubPlugin } from "./react_eval_stub.js";
7
8
  import { optionalFirebaseStubPlugin } from "./optional_firebase_stub.js";
@@ -85,6 +86,9 @@ export function cloudflareNextIntl(options = {}) {
85
86
  if (options.tailwindSources !== false) {
86
87
  plugins.push(tailwindSourcesPlugin());
87
88
  }
89
+ if (options.staticNotFoundNoStore !== false) {
90
+ plugins.push(staticNotFoundNoStorePlugin());
91
+ }
88
92
  if (options.userAgentStub !== false) {
89
93
  plugins.push(userAgentStubPlugin());
90
94
  }
@@ -0,0 +1,10 @@
1
+ import type { Plugin } from "vite";
2
+ export declare const STATIC_NO_STORE_RULE: {
3
+ source: string;
4
+ headers: {
5
+ key: string;
6
+ value: string;
7
+ }[];
8
+ };
9
+ export declare function appendStaticNoStoreRule(code: string): string;
10
+ export declare function staticNotFoundNoStorePlugin(): Plugin;
@@ -0,0 +1,19 @@
1
+ export const STATIC_NO_STORE_RULE = {
2
+ source: "/_next/static/:path*",
3
+ headers: [{ key: "Cache-Control", value: "no-store, must-revalidate" }],
4
+ };
5
+ const CONFIG_HEADERS_LITERAL = /(configHeaders:\s*|__configHeaders\s*=\s*)(\[[^\n]*\])(?=\s*[,;])/g;
6
+ export function appendStaticNoStoreRule(code) {
7
+ return code.replace(CONFIG_HEADERS_LITERAL, (_match, prefix, literal) => `${prefix}${JSON.stringify([...JSON.parse(literal), STATIC_NO_STORE_RULE])}`);
8
+ }
9
+ export function staticNotFoundNoStorePlugin() {
10
+ return {
11
+ name: "cfni:static-not-found-no-store",
12
+ transform(code, id) {
13
+ if (!id.includes("virtual:vinext-"))
14
+ return undefined;
15
+ const next = appendStaticNoStoreRule(code);
16
+ return next === code ? undefined : { code: next, map: null };
17
+ },
18
+ };
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
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",