Skip to content

Commit e4cdd60

Browse files
committed
fixup: lint
1 parent 5dca0cd commit e4cdd60

File tree

3 files changed

+63
-75
lines changed

3 files changed

+63
-75
lines changed
Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,27 @@
11
{
2-
"compilerOptions": {
3-
"target": "ES2017",
4-
"lib": [
5-
"dom",
6-
"dom.iterable",
7-
"esnext"
8-
],
9-
"allowJs": true,
10-
"skipLibCheck": true,
11-
"strict": true,
12-
"noEmit": true,
13-
"esModuleInterop": true,
14-
"module": "esnext",
15-
"moduleResolution": "bundler",
16-
"resolveJsonModule": true,
17-
"isolatedModules": true,
18-
"jsx": "react-jsx",
19-
"incremental": true,
20-
"plugins": [
21-
{
22-
"name": "next"
23-
}
24-
],
25-
"paths": {
26-
"@/*": [
27-
"./src/*"
28-
]
29-
}
30-
},
31-
"include": [
32-
"next-env.d.ts",
33-
"**/*.ts",
34-
"**/*.tsx",
35-
".next/types/**/*.ts",
36-
".next/dev/types/**/*.ts"
37-
],
38-
"exclude": [
39-
"node_modules"
40-
]
2+
"compilerOptions": {
3+
"target": "ES2017",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"strict": true,
8+
"noEmit": true,
9+
"esModuleInterop": true,
10+
"module": "esnext",
11+
"moduleResolution": "bundler",
12+
"resolveJsonModule": true,
13+
"isolatedModules": true,
14+
"jsx": "react-jsx",
15+
"incremental": true,
16+
"plugins": [
17+
{
18+
"name": "next"
19+
}
20+
],
21+
"paths": {
22+
"@/*": ["./src/*"]
23+
}
24+
},
25+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", ".next/dev/types/**/*.ts"],
26+
"exclude": ["node_modules"]
4127
}

packages/cloudflare/src/cli/build/open-next/createServerBundle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ import type { Plugin } from "esbuild";
2727

2828
import { getOpenNextConfig } from "../../../api/config.js";
2929
import { patchResRevalidate } from "../patches/plugins/res-revalidate.js";
30+
import { inlineChunksPatch } from "../patches/plugins/turbopack.js";
3031
import { patchUseCacheIO } from "../patches/plugins/use-cache.js";
3132
import { normalizePath } from "../utils/index.js";
3233
import { copyWorkerdPackages } from "../utils/workerd.js";
33-
import { inlineChunksPatch } from "../patches/plugins/turbopack.js";
3434

3535
interface CodeCustomization {
3636
// These patches are meant to apply on user and next generated code
@@ -289,8 +289,8 @@ async function generateBundle(
289289
alias: {
290290
...(isBundled
291291
? {
292-
"next/dist/server/next-server.js": "./next-server.runtime.prod.js",
293-
}
292+
"next/dist/server/next-server.js": "./next-server.runtime.prod.js",
293+
}
294294
: {}),
295295
},
296296
},
Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { patchCode } from "@opennextjs/aws/build/patch/astCodePatcher.js";
2-
import type { CodePatcher } from "@opennextjs/aws/build/patch/codePatcher";
2+
import type { CodePatcher } from "@opennextjs/aws/build/patch/codePatcher.js";
33
import { getCrossPlatformPathRegex } from "@opennextjs/aws/utils/regex.js";
44

55
const inlineChunksRule = `
@@ -11,49 +11,51 @@ fix:
1111
`;
1212

1313
export const inlineChunksPatch: CodePatcher = {
14-
name: "inline-turbopack-chunks",
15-
patches: [
16-
{
17-
versions: ">=16.0.0",
18-
pathFilter: getCrossPlatformPathRegex(
19-
String.raw`\[turbopack\]_runtime\.js$`,
20-
{
21-
escape: false,
22-
}
23-
),
24-
contentFilter: /loadRuntimeChunkPath/,
25-
patchCode: async ({ code, tracedFiles }) => {
26-
const patched = patchCode(code, inlineChunksRule);
14+
name: "inline-turbopack-chunks",
15+
patches: [
16+
{
17+
versions: ">=16.0.0",
18+
pathFilter: getCrossPlatformPathRegex(String.raw`\[turbopack\]_runtime\.js$`, {
19+
escape: false,
20+
}),
21+
contentFilter: /loadRuntimeChunkPath/,
22+
patchCode: async ({ code, tracedFiles }) => {
23+
const patched = patchCode(code, inlineChunksRule);
2724

28-
return `${patched}\n${inlineChunksFn(tracedFiles)}`;
29-
},
30-
},
31-
],
25+
return `${patched}\n${inlineChunksFn(tracedFiles)}`;
26+
},
27+
},
28+
],
3229
};
3330

3431
function getInlinableChunks(tracedFiles: string[]) {
35-
const chunks = new Set<string>();
36-
for (const file of tracedFiles) {
37-
if (file.includes(".next/server/chunks/") && !file.includes("[turbopack]_runtime.js")) {
38-
chunks.add(file);
39-
}
40-
}
41-
return chunks;
32+
const chunks = new Set<string>();
33+
for (const file of tracedFiles) {
34+
if (file.includes(".next/server/chunks/") && !file.includes("[turbopack]_runtime.js")) {
35+
chunks.add(file);
36+
}
37+
}
38+
return chunks;
4239
}
4340

4441
function inlineChunksFn(tracedFiles: string[]) {
45-
// From the outputs, we extract every chunks
46-
const chunks = getInlinableChunks(tracedFiles);
47-
return `
42+
// From the outputs, we extract every chunks
43+
const chunks = getInlinableChunks(tracedFiles);
44+
return `
4845
function requireChunk(chunkPath) {
4946
switch(chunkPath) {
50-
${Array.from(chunks).map(chunk => ` case "${
51-
// we only want the path after /path/to/.next/
52-
chunk.replace(/.*\.next\//, "")
53-
}": return require("${chunk}");`).join("\n")}
47+
${Array.from(chunks)
48+
.map(
49+
(chunk) =>
50+
` case "${
51+
// we only want the path after /path/to/.next/
52+
chunk.replace(/.*\.next\//, "")
53+
}": return require("${chunk}");`
54+
)
55+
.join("\n")}
5456
default:
5557
throw new Error(\`Not found \${chunkPath}\`);
5658
}
5759
}
5860
`;
59-
}
61+
}

0 commit comments

Comments
 (0)