@opennextjs/cloudflare 0.4.5 → 0.4.7
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/kv-cache.d.ts +22 -0
- package/dist/api/kv-cache.js +123 -0
- package/dist/api/kvCache.d.ts +3 -20
- package/dist/api/kvCache.js +3 -106
- package/dist/cli/build/bundle-server.js +12 -17
- package/dist/cli/build/open-next/copyCacheAssets.js +1 -1
- package/dist/cli/build/patches/ast/webpack-runtime.d.ts +23 -0
- package/dist/cli/build/patches/ast/webpack-runtime.js +57 -0
- package/dist/cli/build/patches/ast/webpack-runtime.spec.js +57 -0
- package/dist/cli/build/patches/investigated/index.d.ts +0 -1
- package/dist/cli/build/patches/investigated/index.js +0 -1
- package/dist/cli/build/patches/plugins/content-updater.d.ts +34 -0
- package/dist/cli/build/patches/plugins/content-updater.js +52 -0
- package/dist/cli/build/patches/plugins/load-instrumentation.d.ts +6 -0
- package/dist/cli/build/patches/plugins/load-instrumentation.js +20 -0
- package/dist/cli/build/patches/plugins/load-instrumentation.spec.js +45 -0
- package/dist/cli/build/patches/plugins/require-hook.d.ts +3 -0
- package/dist/cli/build/patches/plugins/require-hook.js +13 -0
- package/dist/cli/build/patches/plugins/require-page.d.ts +2 -5
- package/dist/cli/build/patches/plugins/require-page.js +30 -29
- package/dist/cli/build/patches/plugins/require.d.ts +2 -5
- package/dist/cli/build/patches/plugins/require.js +36 -43
- package/dist/cli/build/patches/to-investigate/index.d.ts +0 -1
- package/dist/cli/build/patches/to-investigate/index.js +0 -1
- package/dist/cli/build/utils/ensure-cf-config.js +7 -2
- package/dist/cli/build/utils/index.d.ts +0 -1
- package/dist/cli/build/utils/index.js +0 -1
- package/package.json +3 -4
- package/templates/defaults/open-next.config.ts +1 -1
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/get-chunk-installation-identifiers.d.ts +0 -13
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/get-chunk-installation-identifiers.js +0 -82
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/get-chunk-installation-identifiers.test.js +0 -20
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/get-file-content-with-updated-webpack-f-require-code.d.ts +0 -19
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/get-file-content-with-updated-webpack-f-require-code.js +0 -76
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/get-file-content-with-updated-webpack-f-require-code.test.js +0 -23
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/get-updated-webpack-chunks-file-content.d.ts +0 -14
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/get-updated-webpack-chunks-file-content.js +0 -22
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/get-updated-webpack-chunks-file-content.test.d.ts +0 -1
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/get-updated-webpack-chunks-file-content.test.js +0 -15
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/index.d.ts +0 -5
- package/dist/cli/build/patches/investigated/update-webpack-chunks-file/index.js +0 -22
- package/dist/cli/build/patches/to-investigate/patch-load-instrumentation-module.d.ts +0 -14
- package/dist/cli/build/patches/to-investigate/patch-load-instrumentation-module.js +0 -34
- package/dist/cli/build/utils/ts-parse-file.d.ts +0 -8
- package/dist/cli/build/utils/ts-parse-file.js +0 -12
- /package/dist/cli/build/patches/{investigated/update-webpack-chunks-file/get-chunk-installation-identifiers.test.d.ts → ast/webpack-runtime.spec.d.ts} +0 -0
- /package/dist/cli/build/patches/{investigated/update-webpack-chunks-file/get-file-content-with-updated-webpack-f-require-code.test.d.ts → plugins/load-instrumentation.spec.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { describe, expect, test } from "vitest";
|
|
3
|
-
import { getUpdatedWebpackChunksFileContent } from "./get-updated-webpack-chunks-file-content.js";
|
|
4
|
-
describe("getUpdatedWebpackChunksFileContent", () => {
|
|
5
|
-
test("returns the updated content of a webpack runtime chunks unminified file", async () => {
|
|
6
|
-
const fileContent = await readFile(`${import.meta.dirname}/test-fixtures/unminified-webpacks-file.js`, "utf8");
|
|
7
|
-
const updatedContent = await getUpdatedWebpackChunksFileContent(fileContent, ["658"]);
|
|
8
|
-
expect(updatedContent).toMatchFileSnapshot("./test-snapshots/unminified-webpacks-file.js");
|
|
9
|
-
});
|
|
10
|
-
test("returns the updated content of a webpack runtime chunks minified file", async () => {
|
|
11
|
-
const fileContent = await readFile(`${import.meta.dirname}/test-fixtures/minified-webpacks-file.js`, "utf8");
|
|
12
|
-
const updatedContent = await getUpdatedWebpackChunksFileContent(fileContent, ["658"]);
|
|
13
|
-
expect(updatedContent).toMatchFileSnapshot("./test-snapshots/minified-webpacks-file.js");
|
|
14
|
-
});
|
|
15
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { getPackagePath } from "@opennextjs/aws/build/helper.js";
|
|
4
|
-
import { getUpdatedWebpackChunksFileContent } from "./get-updated-webpack-chunks-file-content.js";
|
|
5
|
-
/**
|
|
6
|
-
* Fixes the webpack-runtime.js file by removing its webpack dynamic requires.
|
|
7
|
-
*/
|
|
8
|
-
export async function updateWebpackChunksFile(buildOpts) {
|
|
9
|
-
console.log("# updateWebpackChunksFile");
|
|
10
|
-
const { outputDir } = buildOpts;
|
|
11
|
-
const dotNextServerDir = join(outputDir, "server-functions/default", getPackagePath(buildOpts), ".next/server");
|
|
12
|
-
const webpackRuntimeFile = join(dotNextServerDir, "webpack-runtime.js");
|
|
13
|
-
const fileContent = readFileSync(webpackRuntimeFile, "utf-8");
|
|
14
|
-
const chunks = readdirSync(join(dotNextServerDir, "chunks"))
|
|
15
|
-
.filter((chunk) => /^\d+\.js$/.test(chunk))
|
|
16
|
-
.map((chunk) => {
|
|
17
|
-
console.log(` - chunk ${chunk}`);
|
|
18
|
-
return chunk.replace(/\.js$/, "");
|
|
19
|
-
});
|
|
20
|
-
const updatedFileContent = await getUpdatedWebpackChunksFileContent(fileContent, chunks);
|
|
21
|
-
writeFileSync(webpackRuntimeFile, updatedFileContent);
|
|
22
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `loadInstrumentationModule` method (source: https://github.com/vercel/next.js/blob/5b7833e3/packages/next/src/server/next-server.ts#L301)
|
|
3
|
-
* calls `module.findSourceMap` (https://nodejs.org/api/module.html#modulefindsourcemappath) which we haven't implemented causing a runtime error.
|
|
4
|
-
*
|
|
5
|
-
* To solve this issue this function gets all the `loadInstrumentationModule` declarations found in the file and removes all the statements
|
|
6
|
-
* from their bodies (making them no-op methods).
|
|
7
|
-
*
|
|
8
|
-
* Instrumentation is a Next.js feature for monitoring and logging (see: https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation),
|
|
9
|
-
* the removal of this method's logic most likely breaks this feature (see: https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation),
|
|
10
|
-
* so this function is likely temporary and something that we'll have to fix in the future.
|
|
11
|
-
*
|
|
12
|
-
* TODO: investigate and re-enable instrumentation (https://github.com/opennextjs/opennextjs-cloudflare/issues/171)
|
|
13
|
-
*/
|
|
14
|
-
export declare function patchLoadInstrumentationModule(code: string): string;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as ts from "ts-morph";
|
|
2
|
-
import { tsParseFile } from "../../utils/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* The `loadInstrumentationModule` method (source: https://github.com/vercel/next.js/blob/5b7833e3/packages/next/src/server/next-server.ts#L301)
|
|
5
|
-
* calls `module.findSourceMap` (https://nodejs.org/api/module.html#modulefindsourcemappath) which we haven't implemented causing a runtime error.
|
|
6
|
-
*
|
|
7
|
-
* To solve this issue this function gets all the `loadInstrumentationModule` declarations found in the file and removes all the statements
|
|
8
|
-
* from their bodies (making them no-op methods).
|
|
9
|
-
*
|
|
10
|
-
* Instrumentation is a Next.js feature for monitoring and logging (see: https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation),
|
|
11
|
-
* the removal of this method's logic most likely breaks this feature (see: https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation),
|
|
12
|
-
* so this function is likely temporary and something that we'll have to fix in the future.
|
|
13
|
-
*
|
|
14
|
-
* TODO: investigate and re-enable instrumentation (https://github.com/opennextjs/opennextjs-cloudflare/issues/171)
|
|
15
|
-
*/
|
|
16
|
-
export function patchLoadInstrumentationModule(code) {
|
|
17
|
-
const file = tsParseFile(code);
|
|
18
|
-
const loadInstrumentationModuleDeclarations = file
|
|
19
|
-
.getDescendantsOfKind(ts.SyntaxKind.MethodDeclaration)
|
|
20
|
-
.filter((methodDeclaration) => {
|
|
21
|
-
if (methodDeclaration.getName() !== "loadInstrumentationModule") {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
const methodModifierKinds = methodDeclaration.getModifiers().map((modifier) => modifier.getKind());
|
|
25
|
-
if (methodModifierKinds.length !== 1 || methodModifierKinds[0] !== ts.SyntaxKind.AsyncKeyword) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
return true;
|
|
29
|
-
});
|
|
30
|
-
loadInstrumentationModuleDeclarations.forEach((loadInstrumentationModuleDeclaration) => {
|
|
31
|
-
loadInstrumentationModuleDeclaration.setBodyText("");
|
|
32
|
-
});
|
|
33
|
-
return file.print();
|
|
34
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as ts from "ts-morph";
|
|
2
|
-
/**
|
|
3
|
-
* Parses a javascript file using ts-morph.
|
|
4
|
-
*
|
|
5
|
-
* @param fileContent the content of the file to parse
|
|
6
|
-
* @returns the parsed result
|
|
7
|
-
*/
|
|
8
|
-
export function tsParseFile(fileContent) {
|
|
9
|
-
const project = new ts.Project();
|
|
10
|
-
const sourceFile = project.createSourceFile("file.js", fileContent);
|
|
11
|
-
return sourceFile;
|
|
12
|
-
}
|
|
File without changes
|