@opennextjs/cloudflare 1.2.1 → 1.3.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.
Files changed (66) hide show
  1. package/dist/cli/args.d.ts +2 -0
  2. package/dist/cli/args.js +37 -19
  3. package/dist/cli/build/build.d.ts +2 -2
  4. package/dist/cli/build/build.js +3 -0
  5. package/dist/cli/build/bundle-server.d.ts +1 -1
  6. package/dist/cli/build/bundle-server.js +4 -7
  7. package/dist/cli/build/open-next/compile-images.d.ts +5 -0
  8. package/dist/cli/build/open-next/compile-images.js +29 -0
  9. package/dist/cli/build/open-next/createServerBundle.js +0 -1
  10. package/dist/cli/build/patches/plugins/next-server.d.ts +0 -2
  11. package/dist/cli/build/patches/plugins/next-server.js +0 -19
  12. package/dist/cli/build/{patches/investigated → utils}/copy-package-cli-files.js +1 -1
  13. package/dist/cli/build/utils/index.d.ts +1 -1
  14. package/dist/cli/build/utils/index.js +1 -1
  15. package/dist/cli/build/utils/test-patch.d.ts +9 -0
  16. package/dist/cli/build/utils/test-patch.js +14 -0
  17. package/dist/cli/build/utils/workerd.js +3 -1
  18. package/dist/cli/templates/images.d.ts +24 -0
  19. package/dist/cli/templates/images.js +82 -0
  20. package/dist/cli/templates/worker.js +3 -3
  21. package/package.json +5 -2
  22. package/dist/api/durable-objects/bucket-cache-purge.spec.d.ts +0 -1
  23. package/dist/api/durable-objects/bucket-cache-purge.spec.js +0 -121
  24. package/dist/api/durable-objects/queue.spec.d.ts +0 -1
  25. package/dist/api/durable-objects/queue.spec.js +0 -287
  26. package/dist/api/durable-objects/sharded-tag-cache.spec.d.ts +0 -1
  27. package/dist/api/durable-objects/sharded-tag-cache.spec.js +0 -37
  28. package/dist/api/overrides/queue/memory-queue.spec.d.ts +0 -1
  29. package/dist/api/overrides/queue/memory-queue.spec.js +0 -76
  30. package/dist/api/overrides/queue/queue-cache.spec.d.ts +0 -1
  31. package/dist/api/overrides/queue/queue-cache.spec.js +0 -92
  32. package/dist/api/overrides/tag-cache/do-sharded-tag-cache.spec.d.ts +0 -1
  33. package/dist/api/overrides/tag-cache/do-sharded-tag-cache.spec.js +0 -413
  34. package/dist/api/overrides/tag-cache/tag-cache-filter.spec.d.ts +0 -1
  35. package/dist/api/overrides/tag-cache/tag-cache-filter.spec.js +0 -97
  36. package/dist/cli/build/patches/ast/patch-vercel-og-library.spec.d.ts +0 -1
  37. package/dist/cli/build/patches/ast/patch-vercel-og-library.spec.js +0 -50
  38. package/dist/cli/build/patches/ast/vercel-og.spec.d.ts +0 -1
  39. package/dist/cli/build/patches/ast/vercel-og.spec.js +0 -22
  40. package/dist/cli/build/patches/ast/webpack-runtime.spec.d.ts +0 -1
  41. package/dist/cli/build/patches/ast/webpack-runtime.spec.js +0 -102
  42. package/dist/cli/build/patches/index.d.ts +0 -1
  43. package/dist/cli/build/patches/index.js +0 -1
  44. package/dist/cli/build/patches/investigated/index.d.ts +0 -2
  45. package/dist/cli/build/patches/investigated/index.js +0 -2
  46. package/dist/cli/build/patches/investigated/patch-require.d.ts +0 -4
  47. package/dist/cli/build/patches/investigated/patch-require.js +0 -6
  48. package/dist/cli/build/patches/plugins/instrumentation.spec.d.ts +0 -1
  49. package/dist/cli/build/patches/plugins/instrumentation.spec.js +0 -91
  50. package/dist/cli/build/patches/plugins/next-server.spec.d.ts +0 -1
  51. package/dist/cli/build/patches/plugins/next-server.spec.js +0 -429
  52. package/dist/cli/build/patches/plugins/patch-depd-deprecations.spec.d.ts +0 -1
  53. package/dist/cli/build/patches/plugins/patch-depd-deprecations.spec.js +0 -29
  54. package/dist/cli/build/patches/plugins/res-revalidate.spec.d.ts +0 -1
  55. package/dist/cli/build/patches/plugins/res-revalidate.spec.js +0 -141
  56. package/dist/cli/build/patches/plugins/use-cache.spec.d.ts +0 -1
  57. package/dist/cli/build/patches/plugins/use-cache.spec.js +0 -156
  58. package/dist/cli/build/utils/apply-patches.d.ts +0 -12
  59. package/dist/cli/build/utils/apply-patches.js +0 -22
  60. package/dist/cli/build/utils/extract-project-env-vars.spec.d.ts +0 -1
  61. package/dist/cli/build/utils/extract-project-env-vars.spec.js +0 -67
  62. package/dist/cli/build/utils/workerd.spec.d.ts +0 -1
  63. package/dist/cli/build/utils/workerd.spec.js +0 -188
  64. package/dist/cli/commands/populate-cache.spec.d.ts +0 -1
  65. package/dist/cli/commands/populate-cache.spec.js +0 -61
  66. /package/dist/cli/build/{patches/investigated → utils}/copy-package-cli-files.d.ts +0 -0
@@ -1,188 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import { transformBuildCondition, transformPackageJson } from "./workerd";
3
- describe("transformBuildCondition", () => {
4
- test("top level", () => {
5
- const exports = {
6
- workerd: "./path/to/workerd.js",
7
- default: "./path/to/default.js",
8
- };
9
- const workerd = transformBuildCondition(exports, "workerd");
10
- const defaultExport = transformBuildCondition(exports, "default");
11
- const moduleExport = transformBuildCondition(exports, "module");
12
- expect(workerd.hasBuildCondition).toBe(true);
13
- expect(workerd.transformedExports).toEqual({
14
- workerd: "./path/to/workerd.js",
15
- });
16
- expect(defaultExport.hasBuildCondition).toBe(true);
17
- expect(defaultExport.transformedExports).toEqual({
18
- default: "./path/to/default.js",
19
- });
20
- expect(moduleExport.hasBuildCondition).toBe(false);
21
- expect(moduleExport.transformedExports).toEqual({
22
- workerd: "./path/to/workerd.js",
23
- default: "./path/to/default.js",
24
- });
25
- });
26
- test("nested", () => {
27
- const exports = {
28
- ".": "/path/to/index.js",
29
- "./server": {
30
- "react-server": {
31
- workerd: "./server.edge.js",
32
- other: "./server.js",
33
- },
34
- default: "./server.js",
35
- },
36
- };
37
- const workerd = transformBuildCondition(exports, "workerd");
38
- const defaultExport = transformBuildCondition(exports, "default");
39
- const moduleExport = transformBuildCondition(exports, "module");
40
- expect(workerd.hasBuildCondition).toBe(true);
41
- expect(workerd.transformedExports).toEqual({
42
- ".": "/path/to/index.js",
43
- "./server": {
44
- "react-server": {
45
- workerd: "./server.edge.js",
46
- },
47
- default: "./server.js",
48
- },
49
- });
50
- expect(defaultExport.hasBuildCondition).toBe(true);
51
- expect(defaultExport.transformedExports).toEqual({
52
- ".": "/path/to/index.js",
53
- "./server": {
54
- "react-server": {
55
- workerd: "./server.edge.js",
56
- other: "./server.js",
57
- },
58
- default: "./server.js",
59
- },
60
- });
61
- expect(moduleExport.hasBuildCondition).toBe(false);
62
- expect(moduleExport.transformedExports).toEqual({
63
- ".": "/path/to/index.js",
64
- "./server": {
65
- "react-server": {
66
- workerd: "./server.edge.js",
67
- other: "./server.js",
68
- },
69
- default: "./server.js",
70
- },
71
- });
72
- });
73
- test("only consider leaves", () => {
74
- const exports = {
75
- ".": "/path/to/index.js",
76
- "./server": {
77
- workerd: {
78
- default: "./server.edge.js",
79
- },
80
- },
81
- };
82
- const workerd = transformBuildCondition(exports, "workerd");
83
- expect(workerd.hasBuildCondition).toBe(false);
84
- expect(workerd.transformedExports).toEqual({
85
- ".": "/path/to/index.js",
86
- "./server": {
87
- workerd: {
88
- default: "./server.edge.js",
89
- },
90
- },
91
- });
92
- });
93
- });
94
- describe("transformPackageJson", () => {
95
- test("no exports nor imports", () => {
96
- const json = {
97
- name: "test",
98
- main: "index.js",
99
- version: "1.0.0",
100
- description: "test package",
101
- };
102
- const { transformed, hasBuildCondition } = transformPackageJson(json);
103
- expect(transformed).toEqual(json);
104
- expect(hasBuildCondition).toBe(false);
105
- });
106
- test("exports only with no workerd condition", () => {
107
- const json = {
108
- name: "test",
109
- exports: {
110
- ".": "./index.js",
111
- "./server": "./server.js",
112
- },
113
- };
114
- const { transformed, hasBuildCondition } = transformPackageJson(json);
115
- expect(transformed).toEqual(json);
116
- expect(hasBuildCondition).toBe(false);
117
- });
118
- test("exports only with nested workerd condition", () => {
119
- const json = {
120
- name: "test",
121
- exports: {
122
- ".": "./index.js",
123
- "./server": {
124
- workerd: "./server.edge.js",
125
- other: "./server.js",
126
- },
127
- },
128
- };
129
- const { transformed, hasBuildCondition } = transformPackageJson(json);
130
- expect(transformed).toEqual({
131
- name: "test",
132
- exports: {
133
- ".": "./index.js",
134
- "./server": {
135
- workerd: "./server.edge.js",
136
- },
137
- },
138
- });
139
- expect(hasBuildCondition).toBe(true);
140
- });
141
- test("imports only with top level workerd condition", () => {
142
- const json = {
143
- name: "test",
144
- imports: {
145
- workerd: "./server.edge.js",
146
- default: "./server.js",
147
- },
148
- };
149
- const { transformed, hasBuildCondition } = transformPackageJson(json);
150
- expect(transformed).toEqual({
151
- name: "test",
152
- imports: {
153
- workerd: "./server.edge.js",
154
- },
155
- });
156
- expect(hasBuildCondition).toBe(true);
157
- });
158
- test("exports and imports with workerd condition both nested and top level", () => {
159
- const json = {
160
- name: "test",
161
- exports: {
162
- ".": "./index.js",
163
- "./server": {
164
- workerd: "./server.edge.js",
165
- other: "./server.js",
166
- },
167
- },
168
- imports: {
169
- workerd: "./server.edge.js",
170
- default: "./server.js",
171
- },
172
- };
173
- const { transformed, hasBuildCondition } = transformPackageJson(json);
174
- expect(transformed).toEqual({
175
- name: "test",
176
- exports: {
177
- ".": "./index.js",
178
- "./server": {
179
- workerd: "./server.edge.js",
180
- },
181
- },
182
- imports: {
183
- workerd: "./server.edge.js",
184
- },
185
- });
186
- expect(hasBuildCondition).toBe(true);
187
- });
188
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,61 +0,0 @@
1
- import { mkdirSync, writeFileSync } from "node:fs";
2
- import path from "node:path";
3
- import mockFs from "mock-fs";
4
- import { afterAll, beforeAll, describe, expect, test } from "vitest";
5
- import { getCacheAssets } from "./populate-cache";
6
- describe("getCacheAssets", () => {
7
- beforeAll(() => {
8
- mockFs();
9
- const fetchBaseDir = "/base/path/cache/__fetch/buildID";
10
- const cacheDir = "/base/path/cache/buildID/path/to";
11
- mkdirSync(fetchBaseDir, { recursive: true });
12
- mkdirSync(cacheDir, { recursive: true });
13
- for (let i = 0; i < 3; i++) {
14
- writeFileSync(path.join(fetchBaseDir, `${i}`), "", { encoding: "utf-8" });
15
- writeFileSync(path.join(cacheDir, `${i}.cache`), "", { encoding: "utf-8" });
16
- }
17
- });
18
- afterAll(() => mockFs.restore());
19
- test("list cache assets", () => {
20
- expect(getCacheAssets({ outputDir: "/base/path" })).toMatchInlineSnapshot(`
21
- [
22
- {
23
- "buildId": "buildID",
24
- "fullPath": "/base/path/cache/buildID/path/to/2.cache",
25
- "isFetch": false,
26
- "key": "/path/to/2",
27
- },
28
- {
29
- "buildId": "buildID",
30
- "fullPath": "/base/path/cache/buildID/path/to/1.cache",
31
- "isFetch": false,
32
- "key": "/path/to/1",
33
- },
34
- {
35
- "buildId": "buildID",
36
- "fullPath": "/base/path/cache/buildID/path/to/0.cache",
37
- "isFetch": false,
38
- "key": "/path/to/0",
39
- },
40
- {
41
- "buildId": "buildID",
42
- "fullPath": "/base/path/cache/__fetch/buildID/2",
43
- "isFetch": true,
44
- "key": "/2",
45
- },
46
- {
47
- "buildId": "buildID",
48
- "fullPath": "/base/path/cache/__fetch/buildID/1",
49
- "isFetch": true,
50
- "key": "/1",
51
- },
52
- {
53
- "buildId": "buildID",
54
- "fullPath": "/base/path/cache/__fetch/buildID/0",
55
- "isFetch": true,
56
- "key": "/0",
57
- },
58
- ]
59
- `);
60
- });
61
- });