cloudflare-next-intl 0.10.8 → 0.10.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.
@@ -4,15 +4,22 @@ export function bufferStubPlugin() {
4
4
  name: "cfni:buffer-stub",
5
5
  enforce: "pre",
6
6
  resolveId(id, _importer, options) {
7
- if ((id === "node:buffer" || id === "buffer") &&
7
+ if (id === "node:buffer" &&
8
8
  (this.environment?.name === "client" || options?.ssr === false)) {
9
9
  return BUFFER_STUB_ID;
10
10
  }
11
11
  },
12
12
  load(id) {
13
13
  if (id === BUFFER_STUB_ID) {
14
- return `export { Buffer } from "buffer";\nexport default { Buffer };`;
14
+ return `import bufferModule, { Buffer } from "buffer";\nexport { Buffer };\nexport default bufferModule;`;
15
15
  }
16
16
  },
17
+ config() {
18
+ return {
19
+ optimizeDeps: {
20
+ include: ["buffer"],
21
+ },
22
+ };
23
+ },
17
24
  };
18
25
  }
@@ -1,10 +1,18 @@
1
- import type { Plugin } from "vite";
1
+ import type { Plugin, UserConfig } from "vite";
2
2
  import type { PluginBuild } from "esbuild";
3
3
  export declare const EVAL_WARNING_RE: RegExp;
4
4
  export declare const EVAL_POLYFILL_SNIPPET = "\nif (typeof globalThis !== \"undefined\") {\n try {\n (0, eval)(\"null\");\n } catch {\n var _origEval = globalThis.eval;\n globalThis.eval = function (code) {\n if (code === \"null\") return null;\n if (typeof code === \"string\") {\n var match = code.match(/\\(\\{\\s*(\"(?:[^\"\\\\\\\\]|\\\\.)*\")\\s*:\\s*(?:async\\s+)?(?:function|\\(?\\)?\\s*=>|class)/);\n if (match) {\n try {\n var name = JSON.parse(match[1]);\n var fn = function () {};\n Object.defineProperty(fn, \"name\", { value: name, configurable: true });\n return { [name]: fn };\n } catch {}\n }\n }\n if (typeof _origEval === \"function\") {\n try {\n return _origEval.call(this, code);\n } catch {}\n }\n return null;\n };\n }\n}\n";
5
5
  export declare function transformReactEval(code: string): string;
6
+ export declare const reactEvalRolldownPlugin: {
7
+ name: string;
8
+ transform(code: string): {
9
+ code: string;
10
+ map: null;
11
+ } | undefined;
12
+ };
6
13
  export declare const reactEvalEsbuildPlugin: {
7
14
  name: string;
8
15
  setup(build: PluginBuild): void;
9
16
  };
17
+ export declare function getReactEvalConfig(): UserConfig;
10
18
  export declare function reactEvalStubPlugin(): Plugin;
@@ -34,6 +34,17 @@ export function transformReactEval(code) {
34
34
  }
35
35
  return EVAL_POLYFILL_SNIPPET + "\n" + code.replace(EVAL_WARNING_RE, "/* silenced react eval warning */");
36
36
  }
37
+ export const reactEvalRolldownPlugin = {
38
+ name: "cfni:react-eval-stub-rolldown",
39
+ transform(code) {
40
+ if (code.includes("eval() is not supported in this environment")) {
41
+ return {
42
+ code: transformReactEval(code),
43
+ map: null,
44
+ };
45
+ }
46
+ },
47
+ };
37
48
  export const reactEvalEsbuildPlugin = {
38
49
  name: "cfni:react-eval-stub-esbuild",
39
50
  setup(build) {
@@ -49,6 +60,38 @@ export const reactEvalEsbuildPlugin = {
49
60
  });
50
61
  },
51
62
  };
63
+ export function getReactEvalConfig() {
64
+ const rolldownConfig = {
65
+ rolldownOptions: {
66
+ plugins: [reactEvalRolldownPlugin],
67
+ },
68
+ };
69
+ return {
70
+ optimizeDeps: {
71
+ include: ["buffer", "next/web-vitals"],
72
+ ...rolldownConfig,
73
+ },
74
+ ssr: {
75
+ noExternal: ["cloudflare-next-intl", "cloudflare-next-intl-db"],
76
+ optimizeDeps: rolldownConfig,
77
+ },
78
+ environments: {
79
+ rsc: {
80
+ resolve: {
81
+ noExternal: ["cloudflare-next-intl", "cloudflare-next-intl-db"],
82
+ },
83
+ optimizeDeps: {
84
+ include: [
85
+ "cloudflare-next-intl-db",
86
+ "cloudflare-next-intl-db/schema",
87
+ "cloudflare-next-intl-db/helpers",
88
+ ],
89
+ ...rolldownConfig,
90
+ },
91
+ },
92
+ },
93
+ };
94
+ }
52
95
  export function reactEvalStubPlugin() {
53
96
  return {
54
97
  name: "cfni:react-eval-stub",
@@ -62,30 +105,7 @@ export function reactEvalStubPlugin() {
62
105
  }
63
106
  },
64
107
  config() {
65
- return {
66
- optimizeDeps: {
67
- exclude: ["react-server-dom-webpack", "react-server-dom-webpack/client.edge"],
68
- esbuildOptions: {
69
- plugins: [reactEvalEsbuildPlugin],
70
- },
71
- },
72
- ssr: {
73
- optimizeDeps: {
74
- esbuildOptions: {
75
- plugins: [reactEvalEsbuildPlugin],
76
- },
77
- },
78
- },
79
- environments: {
80
- rsc: {
81
- optimizeDeps: {
82
- esbuildOptions: {
83
- plugins: [reactEvalEsbuildPlugin],
84
- },
85
- },
86
- },
87
- },
88
- };
108
+ return getReactEvalConfig();
89
109
  },
90
110
  };
91
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.10.8",
3
+ "version": "0.10.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",