@opennextjs/cloudflare 0.3.6 → 0.3.8
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/dist/api/get-cloudflare-context.js +4 -1
- package/dist/cli/build/bundle-server.js +3 -3
- package/dist/cli/build/open-next/createServerBundle.js +3 -5
- package/dist/cli/build/patches/investigated/patch-cache.js +2 -1
- package/dist/cli/build/patches/to-investigate/wrangler-deps.js +1 -1
- package/package.json +2 -2
|
@@ -28,7 +28,10 @@ async function getCloudflareContextInNextDev() {
|
|
|
28
28
|
// Note: we never want wrangler to be bundled in the Next.js app, that's why the import below looks like it does
|
|
29
29
|
const { getPlatformProxy } = await import(
|
|
30
30
|
/* webpackIgnore: true */ `${"__wrangler".replaceAll("_", "")}`);
|
|
31
|
-
const { env, cf, ctx } = await getPlatformProxy(
|
|
31
|
+
const { env, cf, ctx } = await getPlatformProxy({
|
|
32
|
+
// This allows the selection of a wrangler environment while running in next dev mode
|
|
33
|
+
environment: process.env.NEXT_DEV_WRANGLER_ENV,
|
|
34
|
+
});
|
|
32
35
|
global[cloudflareContextInNextDevSymbol] = {
|
|
33
36
|
env,
|
|
34
37
|
cf: cf,
|
|
@@ -4,6 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { build } from "esbuild";
|
|
6
6
|
import * as patches from "./patches/index.js";
|
|
7
|
+
import { normalizePath } from "./utils/index.js";
|
|
7
8
|
/** The dist directory of the Cloudflare adapter package */
|
|
8
9
|
const packageDistDir = path.join(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
9
10
|
/**
|
|
@@ -103,8 +104,7 @@ globalThis.__BUILD_TIMESTAMP_MS__ = ${Date.now()};
|
|
|
103
104
|
await updateWorkerBundledCode(openNextServerBundle, config, openNextOptions);
|
|
104
105
|
const isMonorepo = monorepoRoot !== appPath;
|
|
105
106
|
if (isMonorepo) {
|
|
106
|
-
|
|
107
|
-
fs.writeFileSync(path.join(outputPath, "handler.mjs"), `export * from "./${packagePosixPath}/handler.mjs";`);
|
|
107
|
+
fs.writeFileSync(path.join(outputPath, "handler.mjs"), `export * from "./${normalizePath(packagePath)}/handler.mjs";`);
|
|
108
108
|
}
|
|
109
109
|
console.log(`\x1b[35mWorker saved in \`${getOutputWorkerPath(openNextOptions)}\` 🚀\n\x1b[0m`);
|
|
110
110
|
}
|
|
@@ -156,7 +156,7 @@ function createFixRequiresESBuildPlugin(config) {
|
|
|
156
156
|
name: "replaceRelative",
|
|
157
157
|
setup(build) {
|
|
158
158
|
// Note: we (empty) shim require-hook modules as they generate problematic code that uses requires
|
|
159
|
-
build.onResolve({ filter:
|
|
159
|
+
build.onResolve({ filter: /^\.(\/|\\)require-hook$/ }, () => ({
|
|
160
160
|
path: path.join(config.paths.internal.templates, "shims", "empty.js"),
|
|
161
161
|
}));
|
|
162
162
|
},
|
|
@@ -13,6 +13,7 @@ import { minifyAll } from "@opennextjs/aws/minimize-js.js";
|
|
|
13
13
|
import { openNextEdgePlugins } from "@opennextjs/aws/plugins/edge.js";
|
|
14
14
|
import { openNextReplacementPlugin } from "@opennextjs/aws/plugins/replacement.js";
|
|
15
15
|
import { openNextResolvePlugin } from "@opennextjs/aws/plugins/resolve.js";
|
|
16
|
+
import { normalizePath } from "../utils/index.js";
|
|
16
17
|
export async function createServerBundle(options) {
|
|
17
18
|
const { config } = options;
|
|
18
19
|
const foundRoutes = new Set();
|
|
@@ -147,7 +148,7 @@ async function generateBundle(name, options, fnOptions) {
|
|
|
147
148
|
outfile: path.join(outputPath, packagePath, `index.${outfileExt}`),
|
|
148
149
|
banner: {
|
|
149
150
|
js: [
|
|
150
|
-
`globalThis.monorepoPackagePath = "${packagePath}";`,
|
|
151
|
+
`globalThis.monorepoPackagePath = "${normalizePath(packagePath)}";`,
|
|
151
152
|
name === "default" ? "" : `globalThis.fnName = "${name}";`,
|
|
152
153
|
].join(""),
|
|
153
154
|
},
|
|
@@ -201,10 +202,7 @@ function addMonorepoEntrypoint(outputPath, packagePath) {
|
|
|
201
202
|
// the Lambda function to be able to find the handler at
|
|
202
203
|
// the root of the bundle. We will create a dummy `index.mjs`
|
|
203
204
|
// that re-exports the real handler.
|
|
204
|
-
|
|
205
|
-
// Always use posix path for import path
|
|
206
|
-
const packagePosixPath = packagePath.split(path.sep).join(path.posix.sep);
|
|
207
|
-
fs.writeFileSync(path.join(outputPath, "index.mjs"), `export * from "./${packagePosixPath}/index.mjs";`);
|
|
205
|
+
fs.writeFileSync(path.join(outputPath, "index.mjs"), `export * from "./${normalizePath(packagePath)}/index.mjs";`);
|
|
208
206
|
}
|
|
209
207
|
async function minifyServerBundle(outputDir) {
|
|
210
208
|
logger.info("Minimizing server function...");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { normalizePath } from "../../utils/index.js";
|
|
2
3
|
/**
|
|
3
4
|
* Sets up the OpenNext cache handler in a Next.js build.
|
|
4
5
|
*
|
|
@@ -17,6 +18,6 @@ export async function patchCache(code, openNextOptions) {
|
|
|
17
18
|
const packagePath = path.relative(monorepoRoot, appBuildOutputPath);
|
|
18
19
|
const cacheFile = path.join(outputPath, packagePath, "cache.cjs");
|
|
19
20
|
return code.replace("const { cacheHandler } = this.nextConfig;", `const cacheHandler = null;
|
|
20
|
-
CacheHandler = require('${cacheFile}').default;
|
|
21
|
+
CacheHandler = require('${normalizePath(cacheFile)}').default;
|
|
21
22
|
`);
|
|
22
23
|
}
|
|
@@ -139,7 +139,7 @@ function patchRequireReactDomServerEdge(config) {
|
|
|
139
139
|
ReactDOMServer = require('react-dom/server.browser');
|
|
140
140
|
}
|
|
141
141
|
${parameterName}.exports = ReactDOMServer;
|
|
142
|
-
|
|
142
|
+
`.replace(/\ns*/g, " "));
|
|
143
143
|
});
|
|
144
144
|
const updatedCode = file.print();
|
|
145
145
|
writeFileSync(pagesRuntimeFile, updatedCode);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opennextjs/cloudflare",
|
|
3
3
|
"description": "Cloudflare builder for next apps",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"opennextjs-cloudflare": "dist/cli/index.js"
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@dotenvx/dotenvx": "1.31.0",
|
|
65
|
-
"@opennextjs/aws": "https://pkg.pr.new/@opennextjs/aws@
|
|
65
|
+
"@opennextjs/aws": "https://pkg.pr.new/@opennextjs/aws@695",
|
|
66
66
|
"glob": "^11.0.0",
|
|
67
67
|
"ts-morph": "^23.0.0",
|
|
68
68
|
"enquirer": "^2.4.1"
|