@opennextjs/cloudflare 0.3.9 → 0.4.0
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 +1 -64
- package/dist/api/{get-cloudflare-context.d.ts → cloudflare-context.d.ts} +8 -1
- package/dist/api/cloudflare-context.js +96 -0
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/kvCache.d.ts +0 -5
- package/dist/api/kvCache.js +15 -28
- package/dist/cli/build/build.d.ts +1 -1
- package/dist/cli/build/build.js +2 -12
- package/dist/cli/build/bundle-server.d.ts +4 -5
- package/dist/cli/build/bundle-server.js +39 -38
- package/dist/cli/build/open-next/compile-env-files.d.ts +1 -1
- package/dist/cli/build/open-next/compile-env-files.js +2 -2
- package/dist/cli/build/open-next/createServerBundle.js +3 -2
- package/dist/cli/build/patches/ast/optional-deps.d.ts +13 -0
- package/dist/cli/build/patches/ast/optional-deps.js +31 -0
- package/dist/cli/build/patches/ast/optional-deps.spec.d.ts +1 -0
- package/dist/cli/build/patches/ast/optional-deps.spec.js +89 -0
- package/dist/cli/build/patches/ast/util.d.ts +50 -0
- package/dist/cli/build/patches/ast/util.js +65 -0
- package/dist/cli/build/patches/ast/util.spec.d.ts +1 -0
- package/dist/cli/build/patches/ast/util.spec.js +43 -0
- package/dist/cli/build/patches/ast/vercel-og.d.ts +23 -0
- package/dist/cli/build/patches/ast/vercel-og.js +58 -0
- package/dist/cli/build/patches/ast/vercel-og.spec.d.ts +1 -0
- package/dist/cli/build/patches/ast/vercel-og.spec.js +22 -0
- package/dist/cli/build/patches/investigated/copy-package-cli-files.d.ts +4 -3
- package/dist/cli/build/patches/investigated/copy-package-cli-files.js +8 -5
- package/dist/cli/build/patches/investigated/index.d.ts +1 -0
- package/dist/cli/build/patches/investigated/index.js +1 -0
- package/dist/cli/build/patches/investigated/patch-cache.d.ts +2 -2
- package/dist/cli/build/patches/investigated/patch-cache.js +7 -6
- package/dist/cli/build/patches/investigated/patch-require.d.ts +1 -4
- package/dist/cli/build/patches/investigated/patch-require.js +1 -4
- package/dist/cli/build/patches/investigated/patch-vercel-og-library.d.ts +7 -0
- package/dist/cli/build/patches/investigated/patch-vercel-og-library.js +39 -0
- package/dist/cli/build/patches/investigated/patch-vercel-og-library.spec.d.ts +1 -0
- package/dist/cli/build/patches/investigated/patch-vercel-og-library.spec.js +50 -0
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/index.d.ts +2 -5
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/index.js +6 -6
- package/dist/cli/build/patches/to-investigate/inline-eval-manifest.d.ts +2 -2
- package/dist/cli/build/patches/to-investigate/inline-eval-manifest.js +21 -17
- package/dist/cli/build/patches/to-investigate/inline-middleware-manifest-require.d.ts +2 -2
- package/dist/cli/build/patches/to-investigate/inline-middleware-manifest-require.js +4 -2
- package/dist/cli/build/patches/to-investigate/inline-next-require.d.ts +2 -2
- package/dist/cli/build/patches/to-investigate/inline-next-require.js +16 -12
- package/dist/cli/build/patches/to-investigate/patch-find-dir.d.ts +3 -6
- package/dist/cli/build/patches/to-investigate/patch-find-dir.js +11 -11
- package/dist/cli/build/patches/to-investigate/patch-read-file.d.ts +3 -3
- package/dist/cli/build/patches/to-investigate/patch-read-file.js +15 -16
- package/dist/cli/build/patches/to-investigate/wrangler-deps.d.ts +2 -2
- package/dist/cli/build/patches/to-investigate/wrangler-deps.js +36 -67
- package/dist/cli/build/utils/create-config-files.d.ts +1 -1
- package/dist/cli/build/utils/create-config-files.js +2 -2
- package/dist/cli/project-options.d.ts +7 -0
- package/dist/cli/project-options.js +1 -0
- package/package.json +8 -6
- package/templates/defaults/wrangler.json +1 -0
- package/dist/api/get-cloudflare-context.js +0 -42
- package/dist/cli/config.d.ts +0 -42
- package/dist/cli/config.js +0 -92
package/dist/cli/config.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { readdirSync, statSync } from "node:fs";
|
|
2
|
-
import { join, relative } from "node:path";
|
|
3
|
-
const PACKAGE_NAME = "@opennextjs/cloudflare";
|
|
4
|
-
/**
|
|
5
|
-
* Computes the configuration.
|
|
6
|
-
*
|
|
7
|
-
* @param projectOpts The options for the project
|
|
8
|
-
* @returns The configuration, see `Config`
|
|
9
|
-
*/
|
|
10
|
-
export function getConfig(projectOpts) {
|
|
11
|
-
const sourceDirDotNext = join(projectOpts.sourceDir, ".next");
|
|
12
|
-
const dotNext = join(projectOpts.outputDir, ".next");
|
|
13
|
-
const appPath = getNextjsApplicationPath(dotNext).replace(/\/$/, "");
|
|
14
|
-
const standaloneRoot = join(dotNext, "standalone");
|
|
15
|
-
const standaloneApp = join(standaloneRoot, appPath);
|
|
16
|
-
const standaloneAppDotNext = join(standaloneApp, ".next");
|
|
17
|
-
const standaloneAppServer = join(standaloneAppDotNext, "server");
|
|
18
|
-
const nodeModules = join(standaloneApp, "node_modules");
|
|
19
|
-
const internalPackage = join(nodeModules, ...PACKAGE_NAME.split("/"));
|
|
20
|
-
const internalTemplates = join(internalPackage, "cli", "templates");
|
|
21
|
-
return {
|
|
22
|
-
build: {
|
|
23
|
-
skipNextBuild: projectOpts.skipNextBuild,
|
|
24
|
-
shouldMinify: projectOpts.minify,
|
|
25
|
-
},
|
|
26
|
-
paths: {
|
|
27
|
-
source: {
|
|
28
|
-
root: projectOpts.sourceDir,
|
|
29
|
-
dotNext: sourceDirDotNext,
|
|
30
|
-
standaloneRoot: join(sourceDirDotNext, "standalone"),
|
|
31
|
-
},
|
|
32
|
-
output: {
|
|
33
|
-
root: projectOpts.outputDir,
|
|
34
|
-
assets: join(projectOpts.outputDir, "assets"),
|
|
35
|
-
dotNext,
|
|
36
|
-
standaloneRoot,
|
|
37
|
-
standaloneApp,
|
|
38
|
-
standaloneAppDotNext,
|
|
39
|
-
standaloneAppServer,
|
|
40
|
-
},
|
|
41
|
-
internal: {
|
|
42
|
-
package: internalPackage,
|
|
43
|
-
templates: internalTemplates,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
internalPackageName: PACKAGE_NAME,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export function containsDotNextDir(folder) {
|
|
50
|
-
try {
|
|
51
|
-
return statSync(join(folder, ".next")).isDirectory();
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* It basically tries to find the path that the application is under inside the `.next/standalone` directory, using the `.next/server` directory
|
|
59
|
-
* presence as the condition that needs to be met.
|
|
60
|
-
*
|
|
61
|
-
* For example:
|
|
62
|
-
* When I build the api application the `.next/server` directory is located in:
|
|
63
|
-
* `<dotNextDir>/standalone/next-apps/api/.next/server`
|
|
64
|
-
* and the function here given the `dotNextDir` returns `next-apps/api`
|
|
65
|
-
*/
|
|
66
|
-
function getNextjsApplicationPath(dotNextDir) {
|
|
67
|
-
const serverPath = findServerParentPath(dotNextDir);
|
|
68
|
-
if (!serverPath) {
|
|
69
|
-
throw new Error(`Unexpected Error: no \`.next/server\` folder could be found in \`${serverPath}\``);
|
|
70
|
-
}
|
|
71
|
-
return relative(join(dotNextDir, "standalone"), serverPath);
|
|
72
|
-
}
|
|
73
|
-
function findServerParentPath(parentPath) {
|
|
74
|
-
try {
|
|
75
|
-
if (statSync(join(parentPath, ".next", "server")).isDirectory()) {
|
|
76
|
-
return parentPath;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
/* empty */
|
|
81
|
-
}
|
|
82
|
-
const folders = readdirSync(parentPath);
|
|
83
|
-
for (const folder of folders) {
|
|
84
|
-
const subFolder = join(parentPath, folder);
|
|
85
|
-
if (statSync(join(parentPath, folder)).isDirectory()) {
|
|
86
|
-
const dirServerPath = findServerParentPath(subFolder);
|
|
87
|
-
if (dirServerPath) {
|
|
88
|
-
return dirServerPath;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|