@opennextjs/cloudflare 0.3.2 → 0.3.3
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,3 +4,10 @@ import { Config } from "../config.js";
|
|
|
4
4
|
* Bundle the Open Next server.
|
|
5
5
|
*/
|
|
6
6
|
export declare function bundleServer(config: Config, openNextOptions: BuildOptions): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Gets the path of the worker.js file generated by the build process
|
|
9
|
+
*
|
|
10
|
+
* @param openNextOptions the open-next build options
|
|
11
|
+
* @returns the path of the worker.js file that the build process generates
|
|
12
|
+
*/
|
|
13
|
+
export declare function getOutputWorkerPath(openNextOptions: BuildOptions): string;
|
|
@@ -82,7 +82,7 @@ fetch = globalThis.fetch;
|
|
|
82
82
|
const CustomRequest = class extends globalThis.Request {
|
|
83
83
|
constructor(input, init) {
|
|
84
84
|
if (init) {
|
|
85
|
-
init.cache
|
|
85
|
+
delete init.cache;
|
|
86
86
|
// https://github.com/cloudflare/workerd/issues/2746
|
|
87
87
|
// https://github.com/cloudflare/workerd/issues/3245
|
|
88
88
|
Object.defineProperty(init, "body", {
|
|
@@ -106,7 +106,7 @@ globalThis.__BUILD_TIMESTAMP_MS__ = ${Date.now()};
|
|
|
106
106
|
const packagePosixPath = packagePath.split(path.sep).join(path.posix.sep);
|
|
107
107
|
fs.writeFileSync(path.join(outputPath, "handler.mjs"), `export * from "./${packagePosixPath}/handler.mjs";`);
|
|
108
108
|
}
|
|
109
|
-
console.log(`\x1b[35mWorker saved in \`${
|
|
109
|
+
console.log(`\x1b[35mWorker saved in \`${getOutputWorkerPath(openNextOptions)}\` 🚀\n\x1b[0m`);
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
* This function applies string replacements on the bundled worker code necessary to get it to run in workerd
|
|
@@ -185,3 +185,12 @@ async function patchCodeWithValidations(code, patches) {
|
|
|
185
185
|
console.log(`All ${patches.length} patches applied\n`);
|
|
186
186
|
return patchedCode;
|
|
187
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Gets the path of the worker.js file generated by the build process
|
|
190
|
+
*
|
|
191
|
+
* @param openNextOptions the open-next build options
|
|
192
|
+
* @returns the path of the worker.js file that the build process generates
|
|
193
|
+
*/
|
|
194
|
+
export function getOutputWorkerPath(openNextOptions) {
|
|
195
|
+
return path.join(openNextOptions.outputDir, "worker.js");
|
|
196
|
+
}
|
|
@@ -3,4 +3,4 @@ import { Config } from "../../../config.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Copies the template files present in the cloudflare adapter package into the standalone node_modules folder
|
|
5
5
|
*/
|
|
6
|
-
export declare function copyPackageCliFiles(packageDistDir: string, config: Config,
|
|
6
|
+
export declare function copyPackageCliFiles(packageDistDir: string, config: Config, openNextOptions: BuildOptions): void;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { getOutputWorkerPath } from "../../bundle-server.js";
|
|
3
4
|
/**
|
|
4
5
|
* Copies the template files present in the cloudflare adapter package into the standalone node_modules folder
|
|
5
6
|
*/
|
|
6
|
-
export function copyPackageCliFiles(packageDistDir, config,
|
|
7
|
+
export function copyPackageCliFiles(packageDistDir, config, openNextOptions) {
|
|
7
8
|
console.log("# copyPackageTemplateFiles");
|
|
8
9
|
const sourceDir = path.join(packageDistDir, "cli");
|
|
9
10
|
const destinationDir = path.join(config.paths.internal.package, "cli");
|
|
10
11
|
fs.cpSync(sourceDir, destinationDir, { recursive: true });
|
|
11
|
-
fs.copyFileSync(path.join(packageDistDir, "cli", "templates", "worker.js"),
|
|
12
|
+
fs.copyFileSync(path.join(packageDistDir, "cli", "templates", "worker.js"), getOutputWorkerPath(openNextOptions));
|
|
12
13
|
}
|