@opennextjs/cloudflare 0.0.0-88fe982 → 0.0.0-953d0b1
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 +60 -13
- package/dist/api/chunk-VTBEIZPQ.mjs +32 -0
- package/dist/api/get-cloudflare-context.d.mts +26 -0
- package/dist/api/get-cloudflare-context.mjs +6 -0
- package/dist/api/index.d.mts +1 -0
- package/dist/api/index.mjs +6 -0
- package/dist/cli/cache-handler.mjs +48 -0
- package/dist/cli/chunk-UJCSKKID.mjs +30 -0
- package/dist/{index.mjs → cli/index.mjs} +353 -330
- package/dist/{templates → cli/templates}/shims/node-fs.ts +1 -1
- package/dist/{templates → cli/templates}/worker.ts +57 -34
- package/package.json +26 -6
- /package/dist/{templates → cli/templates}/shims/empty.ts +0 -0
- /package/dist/{templates → cli/templates}/shims/env.ts +0 -0
- /package/dist/{templates → cli/templates}/shims/throw.ts +0 -0
|
@@ -1,32 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
-
mod
|
|
25
|
-
));
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
__commonJS,
|
|
4
|
+
__toESM
|
|
5
|
+
} from "./chunk-UJCSKKID.mjs";
|
|
26
6
|
|
|
27
|
-
//
|
|
7
|
+
// ../../node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js
|
|
28
8
|
var require_balanced_match = __commonJS({
|
|
29
|
-
"
|
|
9
|
+
"../../node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports, module) {
|
|
30
10
|
"use strict";
|
|
31
11
|
module.exports = balanced;
|
|
32
12
|
function balanced(a, b, str) {
|
|
@@ -82,9 +62,9 @@ var require_balanced_match = __commonJS({
|
|
|
82
62
|
}
|
|
83
63
|
});
|
|
84
64
|
|
|
85
|
-
//
|
|
65
|
+
// ../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js
|
|
86
66
|
var require_brace_expansion = __commonJS({
|
|
87
|
-
"
|
|
67
|
+
"../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js"(exports, module) {
|
|
88
68
|
"use strict";
|
|
89
69
|
var balanced = require_balanced_match();
|
|
90
70
|
module.exports = expandTop;
|
|
@@ -233,62 +213,73 @@ var require_brace_expansion = __commonJS({
|
|
|
233
213
|
}
|
|
234
214
|
});
|
|
235
215
|
|
|
236
|
-
// src/
|
|
237
|
-
import {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
function getArgs() {
|
|
244
|
-
const {
|
|
245
|
-
values: { skipBuild: skipBuild2, output }
|
|
246
|
-
} = parseArgs({
|
|
247
|
-
options: {
|
|
248
|
-
skipBuild: {
|
|
249
|
-
type: "boolean",
|
|
250
|
-
short: "s",
|
|
251
|
-
default: false
|
|
252
|
-
},
|
|
253
|
-
output: {
|
|
254
|
-
type: "string",
|
|
255
|
-
short: "o"
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
allowPositionals: false
|
|
259
|
-
});
|
|
260
|
-
const outputDir2 = output ? resolve(output) : void 0;
|
|
261
|
-
if (outputDir2) {
|
|
262
|
-
assertDirArg(outputDir2, "output", true);
|
|
216
|
+
// src/cli/config.ts
|
|
217
|
+
import path, { relative } from "node:path";
|
|
218
|
+
import { readdirSync, statSync } from "node:fs";
|
|
219
|
+
var PACKAGE_NAME = "@opennextjs/cloudflare";
|
|
220
|
+
var UserConfig = {
|
|
221
|
+
cache: {
|
|
222
|
+
bindingName: "NEXT_CACHE_WORKERS_KV"
|
|
263
223
|
}
|
|
224
|
+
};
|
|
225
|
+
function getConfig(appDir, outputDir2) {
|
|
226
|
+
const dotNext = path.join(outputDir2, ".next");
|
|
227
|
+
const appPath = getNextjsApplicationPath(dotNext).replace(/\/$/, "");
|
|
228
|
+
const standaloneApp = path.join(dotNext, "standalone", appPath);
|
|
229
|
+
const standaloneAppDotNext = path.join(standaloneApp, ".next");
|
|
230
|
+
const standaloneAppServer = path.join(standaloneAppDotNext, "server");
|
|
231
|
+
const nodeModules = path.join(standaloneApp, "node_modules");
|
|
232
|
+
const internalPackage = path.join(nodeModules, ...PACKAGE_NAME.split("/"));
|
|
264
233
|
return {
|
|
265
|
-
|
|
266
|
-
|
|
234
|
+
paths: {
|
|
235
|
+
nextApp: appDir,
|
|
236
|
+
builderOutput: outputDir2,
|
|
237
|
+
dotNext,
|
|
238
|
+
standaloneApp,
|
|
239
|
+
standaloneAppDotNext,
|
|
240
|
+
standaloneAppServer,
|
|
241
|
+
internalPackage
|
|
242
|
+
},
|
|
243
|
+
cache: {
|
|
244
|
+
kvBindingName: UserConfig.cache.bindingName
|
|
245
|
+
},
|
|
246
|
+
internalPackageName: PACKAGE_NAME
|
|
267
247
|
};
|
|
268
248
|
}
|
|
269
|
-
function
|
|
270
|
-
let dirStats;
|
|
249
|
+
function containsDotNextDir(folder) {
|
|
271
250
|
try {
|
|
272
|
-
|
|
251
|
+
return statSync(path.join(folder, ".next")).isDirectory();
|
|
273
252
|
} catch {
|
|
274
|
-
|
|
275
|
-
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function getNextjsApplicationPath(dotNextDir) {
|
|
257
|
+
const serverPath = findServerParentPath(dotNextDir);
|
|
258
|
+
if (!serverPath) {
|
|
259
|
+
throw new Error(`Unexpected Error: no \`.next/server\` folder could be found in \`${serverPath}\``);
|
|
260
|
+
}
|
|
261
|
+
return relative(path.join(dotNextDir, "standalone"), serverPath);
|
|
262
|
+
}
|
|
263
|
+
function findServerParentPath(parentPath) {
|
|
264
|
+
try {
|
|
265
|
+
if (statSync(path.join(parentPath, ".next", "server")).isDirectory()) {
|
|
266
|
+
return parentPath;
|
|
276
267
|
}
|
|
277
|
-
|
|
278
|
-
return;
|
|
268
|
+
} catch {
|
|
279
269
|
}
|
|
280
|
-
|
|
281
|
-
|
|
270
|
+
const folders = readdirSync(parentPath);
|
|
271
|
+
for (const folder of folders) {
|
|
272
|
+
const subFolder = path.join(parentPath, folder);
|
|
273
|
+
if (statSync(path.join(parentPath, folder)).isDirectory()) {
|
|
274
|
+
const dirServerPath = findServerParentPath(subFolder);
|
|
275
|
+
if (dirServerPath) {
|
|
276
|
+
return dirServerPath;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
282
279
|
}
|
|
283
280
|
}
|
|
284
281
|
|
|
285
|
-
// src/
|
|
286
|
-
import { existsSync as existsSync3 } from "node:fs";
|
|
287
|
-
|
|
288
|
-
// src/build/build.ts
|
|
289
|
-
import { rm } from "node:fs/promises";
|
|
290
|
-
|
|
291
|
-
// src/build/build-next-app.ts
|
|
282
|
+
// src/cli/build/build-next-app.ts
|
|
292
283
|
import { execSync } from "node:child_process";
|
|
293
284
|
function buildNextjsApp(nextAppDir2) {
|
|
294
285
|
runNextBuildCommand("pnpm", nextAppDir2);
|
|
@@ -307,34 +298,28 @@ function runNextBuildCommand(packager, nextAppDir2) {
|
|
|
307
298
|
});
|
|
308
299
|
}
|
|
309
300
|
|
|
310
|
-
// src/build/build-worker.ts
|
|
301
|
+
// src/cli/build/build-worker.ts
|
|
311
302
|
import { build } from "esbuild";
|
|
312
|
-
import { readFileSync as readFileSync4 } from "node:fs";
|
|
313
303
|
import { cp, readFile, writeFile } from "node:fs/promises";
|
|
304
|
+
import { existsSync as existsSync3, readFileSync as readFileSync4 } from "node:fs";
|
|
314
305
|
|
|
315
|
-
// src/build/patches/investigated/
|
|
316
|
-
function patchRequire(code) {
|
|
317
|
-
console.log("# patchRequire");
|
|
318
|
-
return code.replace(/__require\d?\(/g, "require(").replace(/__require\d?\./g, "require.");
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// src/build/patches/investigated/copy-templates.ts
|
|
322
|
-
import path from "node:path";
|
|
306
|
+
// src/cli/build/patches/investigated/copy-package-cli-files.ts
|
|
323
307
|
import { cpSync } from "node:fs";
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
308
|
+
import path2 from "node:path";
|
|
309
|
+
function copyPackageCliFiles(packageDistDir2, config) {
|
|
310
|
+
console.log("# copyPackageTemplateFiles");
|
|
311
|
+
const sourceDir = path2.join(packageDistDir2, "cli");
|
|
312
|
+
const destinationDir = path2.join(config.paths.internalPackage, "cli");
|
|
313
|
+
cpSync(sourceDir, destinationDir, { recursive: true });
|
|
329
314
|
}
|
|
330
315
|
|
|
331
|
-
// src/build/
|
|
332
|
-
import {
|
|
316
|
+
// src/cli/build/build-worker.ts
|
|
317
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
333
318
|
|
|
334
|
-
//
|
|
319
|
+
// ../../node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/index.js
|
|
335
320
|
var import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
|
336
321
|
|
|
337
|
-
//
|
|
322
|
+
// ../../node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
338
323
|
var MAX_PATTERN_LENGTH = 1024 * 64;
|
|
339
324
|
var assertValidPattern = (pattern) => {
|
|
340
325
|
if (typeof pattern !== "string") {
|
|
@@ -345,7 +330,7 @@ var assertValidPattern = (pattern) => {
|
|
|
345
330
|
}
|
|
346
331
|
};
|
|
347
332
|
|
|
348
|
-
//
|
|
333
|
+
// ../../node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/brace-expressions.js
|
|
349
334
|
var posixClasses = {
|
|
350
335
|
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
|
351
336
|
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
|
@@ -454,12 +439,12 @@ var parseClass = (glob2, position) => {
|
|
|
454
439
|
return [comb, uflag, endPos - pos, true];
|
|
455
440
|
};
|
|
456
441
|
|
|
457
|
-
//
|
|
442
|
+
// ../../node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/unescape.js
|
|
458
443
|
var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
459
444
|
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
|
460
445
|
};
|
|
461
446
|
|
|
462
|
-
//
|
|
447
|
+
// ../../node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/ast.js
|
|
463
448
|
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
|
|
464
449
|
var isExtglobType = (c) => types.has(c);
|
|
465
450
|
var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
@@ -938,12 +923,12 @@ var AST = class _AST {
|
|
|
938
923
|
}
|
|
939
924
|
};
|
|
940
925
|
|
|
941
|
-
//
|
|
926
|
+
// ../../node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/escape.js
|
|
942
927
|
var escape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
943
928
|
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
944
929
|
};
|
|
945
930
|
|
|
946
|
-
//
|
|
931
|
+
// ../../node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/index.js
|
|
947
932
|
var minimatch = (p, pattern, options = {}) => {
|
|
948
933
|
assertValidPattern(pattern);
|
|
949
934
|
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
@@ -1002,11 +987,11 @@ var qmarksTestNoExtDot = ([$0]) => {
|
|
|
1002
987
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
1003
988
|
};
|
|
1004
989
|
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
1005
|
-
var
|
|
990
|
+
var path3 = {
|
|
1006
991
|
win32: { sep: "\\" },
|
|
1007
992
|
posix: { sep: "/" }
|
|
1008
993
|
};
|
|
1009
|
-
var sep = defaultPlatform === "win32" ?
|
|
994
|
+
var sep = defaultPlatform === "win32" ? path3.win32.sep : path3.posix.sep;
|
|
1010
995
|
minimatch.sep = sep;
|
|
1011
996
|
var GLOBSTAR = Symbol("globstar **");
|
|
1012
997
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -1661,10 +1646,10 @@ minimatch.Minimatch = Minimatch;
|
|
|
1661
1646
|
minimatch.escape = escape;
|
|
1662
1647
|
minimatch.unescape = unescape;
|
|
1663
1648
|
|
|
1664
|
-
//
|
|
1649
|
+
// ../../node_modules/.pnpm/glob@11.0.0/node_modules/glob/dist/esm/glob.js
|
|
1665
1650
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
1666
1651
|
|
|
1667
|
-
//
|
|
1652
|
+
// ../../node_modules/.pnpm/lru-cache@11.0.0/node_modules/lru-cache/dist/esm/index.js
|
|
1668
1653
|
var perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
|
|
1669
1654
|
var warned = /* @__PURE__ */ new Set();
|
|
1670
1655
|
var PROCESS = typeof process === "object" && !!process ? process : {};
|
|
@@ -3033,14 +3018,14 @@ var LRUCache = class _LRUCache {
|
|
|
3033
3018
|
}
|
|
3034
3019
|
};
|
|
3035
3020
|
|
|
3036
|
-
//
|
|
3021
|
+
// ../../node_modules/.pnpm/path-scurry@2.0.0/node_modules/path-scurry/dist/esm/index.js
|
|
3037
3022
|
import { posix, win32 } from "node:path";
|
|
3038
3023
|
import { fileURLToPath } from "node:url";
|
|
3039
|
-
import { lstatSync, readdir as readdirCB, readdirSync, readlinkSync, realpathSync as rps } from "fs";
|
|
3024
|
+
import { lstatSync, readdir as readdirCB, readdirSync as readdirSync2, readlinkSync, realpathSync as rps } from "fs";
|
|
3040
3025
|
import * as actualFS from "node:fs";
|
|
3041
3026
|
import { lstat, readdir, readlink, realpath } from "node:fs/promises";
|
|
3042
3027
|
|
|
3043
|
-
//
|
|
3028
|
+
// ../../node_modules/.pnpm/minipass@7.1.2/node_modules/minipass/dist/esm/index.js
|
|
3044
3029
|
import { EventEmitter } from "node:events";
|
|
3045
3030
|
import Stream from "node:stream";
|
|
3046
3031
|
import { StringDecoder } from "node:string_decoder";
|
|
@@ -3918,12 +3903,12 @@ var Minipass = class extends EventEmitter {
|
|
|
3918
3903
|
}
|
|
3919
3904
|
};
|
|
3920
3905
|
|
|
3921
|
-
//
|
|
3906
|
+
// ../../node_modules/.pnpm/path-scurry@2.0.0/node_modules/path-scurry/dist/esm/index.js
|
|
3922
3907
|
var realpathSync = rps.native;
|
|
3923
3908
|
var defaultFS = {
|
|
3924
3909
|
lstatSync,
|
|
3925
3910
|
readdir: readdirCB,
|
|
3926
|
-
readdirSync,
|
|
3911
|
+
readdirSync: readdirSync2,
|
|
3927
3912
|
readlinkSync,
|
|
3928
3913
|
realpathSync,
|
|
3929
3914
|
promises: {
|
|
@@ -4183,12 +4168,12 @@ var PathBase = class {
|
|
|
4183
4168
|
/**
|
|
4184
4169
|
* Get the Path object referenced by the string path, resolved from this Path
|
|
4185
4170
|
*/
|
|
4186
|
-
resolve(
|
|
4187
|
-
if (!
|
|
4171
|
+
resolve(path13) {
|
|
4172
|
+
if (!path13) {
|
|
4188
4173
|
return this;
|
|
4189
4174
|
}
|
|
4190
|
-
const rootPath = this.getRootString(
|
|
4191
|
-
const dir =
|
|
4175
|
+
const rootPath = this.getRootString(path13);
|
|
4176
|
+
const dir = path13.substring(rootPath.length);
|
|
4192
4177
|
const dirParts = dir.split(this.splitSep);
|
|
4193
4178
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
4194
4179
|
return result;
|
|
@@ -4940,8 +4925,8 @@ var PathWin32 = class _PathWin32 extends PathBase {
|
|
|
4940
4925
|
/**
|
|
4941
4926
|
* @internal
|
|
4942
4927
|
*/
|
|
4943
|
-
getRootString(
|
|
4944
|
-
return win32.parse(
|
|
4928
|
+
getRootString(path13) {
|
|
4929
|
+
return win32.parse(path13).root;
|
|
4945
4930
|
}
|
|
4946
4931
|
/**
|
|
4947
4932
|
* @internal
|
|
@@ -4987,8 +4972,8 @@ var PathPosix = class _PathPosix extends PathBase {
|
|
|
4987
4972
|
/**
|
|
4988
4973
|
* @internal
|
|
4989
4974
|
*/
|
|
4990
|
-
getRootString(
|
|
4991
|
-
return
|
|
4975
|
+
getRootString(path13) {
|
|
4976
|
+
return path13.startsWith("/") ? "/" : "";
|
|
4992
4977
|
}
|
|
4993
4978
|
/**
|
|
4994
4979
|
* @internal
|
|
@@ -5077,11 +5062,11 @@ var PathScurryBase = class {
|
|
|
5077
5062
|
/**
|
|
5078
5063
|
* Get the depth of a provided path, string, or the cwd
|
|
5079
5064
|
*/
|
|
5080
|
-
depth(
|
|
5081
|
-
if (typeof
|
|
5082
|
-
|
|
5065
|
+
depth(path13 = this.cwd) {
|
|
5066
|
+
if (typeof path13 === "string") {
|
|
5067
|
+
path13 = this.cwd.resolve(path13);
|
|
5083
5068
|
}
|
|
5084
|
-
return
|
|
5069
|
+
return path13.depth();
|
|
5085
5070
|
}
|
|
5086
5071
|
/**
|
|
5087
5072
|
* Return the cache of child entries. Exposed so subclasses can create
|
|
@@ -5568,9 +5553,9 @@ var PathScurryBase = class {
|
|
|
5568
5553
|
process2();
|
|
5569
5554
|
return results;
|
|
5570
5555
|
}
|
|
5571
|
-
chdir(
|
|
5556
|
+
chdir(path13 = this.cwd) {
|
|
5572
5557
|
const oldCwd = this.cwd;
|
|
5573
|
-
this.cwd = typeof
|
|
5558
|
+
this.cwd = typeof path13 === "string" ? this.cwd.resolve(path13) : path13;
|
|
5574
5559
|
this.cwd[setAsCwd](oldCwd);
|
|
5575
5560
|
}
|
|
5576
5561
|
};
|
|
@@ -5644,7 +5629,7 @@ var PathScurryDarwin = class extends PathScurryPosix {
|
|
|
5644
5629
|
var Path = process.platform === "win32" ? PathWin32 : PathPosix;
|
|
5645
5630
|
var PathScurry = process.platform === "win32" ? PathScurryWin32 : process.platform === "darwin" ? PathScurryDarwin : PathScurryPosix;
|
|
5646
5631
|
|
|
5647
|
-
//
|
|
5632
|
+
// ../../node_modules/.pnpm/glob@11.0.0/node_modules/glob/dist/esm/pattern.js
|
|
5648
5633
|
var isPatternList = (pl) => pl.length >= 1;
|
|
5649
5634
|
var isGlobList = (gl) => gl.length >= 1;
|
|
5650
5635
|
var Pattern = class _Pattern {
|
|
@@ -5809,7 +5794,7 @@ var Pattern = class _Pattern {
|
|
|
5809
5794
|
}
|
|
5810
5795
|
};
|
|
5811
5796
|
|
|
5812
|
-
//
|
|
5797
|
+
// ../../node_modules/.pnpm/glob@11.0.0/node_modules/glob/dist/esm/ignore.js
|
|
5813
5798
|
var defaultPlatform2 = typeof process === "object" && process && typeof process.platform === "string" ? process.platform : "linux";
|
|
5814
5799
|
var Ignore = class {
|
|
5815
5800
|
relative;
|
|
@@ -5896,7 +5881,7 @@ var Ignore = class {
|
|
|
5896
5881
|
}
|
|
5897
5882
|
};
|
|
5898
5883
|
|
|
5899
|
-
//
|
|
5884
|
+
// ../../node_modules/.pnpm/glob@11.0.0/node_modules/glob/dist/esm/processor.js
|
|
5900
5885
|
var HasWalkedCache = class _HasWalkedCache {
|
|
5901
5886
|
store;
|
|
5902
5887
|
constructor(store = /* @__PURE__ */ new Map()) {
|
|
@@ -5926,8 +5911,8 @@ var MatchRecord = class {
|
|
|
5926
5911
|
}
|
|
5927
5912
|
// match, absolute, ifdir
|
|
5928
5913
|
entries() {
|
|
5929
|
-
return [...this.store.entries()].map(([
|
|
5930
|
-
|
|
5914
|
+
return [...this.store.entries()].map(([path13, n]) => [
|
|
5915
|
+
path13,
|
|
5931
5916
|
!!(n & 2),
|
|
5932
5917
|
!!(n & 1)
|
|
5933
5918
|
]);
|
|
@@ -6117,7 +6102,7 @@ var Processor = class _Processor {
|
|
|
6117
6102
|
}
|
|
6118
6103
|
};
|
|
6119
6104
|
|
|
6120
|
-
//
|
|
6105
|
+
// ../../node_modules/.pnpm/glob@11.0.0/node_modules/glob/dist/esm/walker.js
|
|
6121
6106
|
var makeIgnore = (ignore, opts) => typeof ignore === "string" ? new Ignore([ignore], opts) : Array.isArray(ignore) ? new Ignore(ignore, opts) : ignore;
|
|
6122
6107
|
var GlobUtil = class {
|
|
6123
6108
|
path;
|
|
@@ -6132,9 +6117,9 @@ var GlobUtil = class {
|
|
|
6132
6117
|
signal;
|
|
6133
6118
|
maxDepth;
|
|
6134
6119
|
includeChildMatches;
|
|
6135
|
-
constructor(patterns,
|
|
6120
|
+
constructor(patterns, path13, opts) {
|
|
6136
6121
|
this.patterns = patterns;
|
|
6137
|
-
this.path =
|
|
6122
|
+
this.path = path13;
|
|
6138
6123
|
this.opts = opts;
|
|
6139
6124
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
6140
6125
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -6153,11 +6138,11 @@ var GlobUtil = class {
|
|
|
6153
6138
|
});
|
|
6154
6139
|
}
|
|
6155
6140
|
}
|
|
6156
|
-
#ignored(
|
|
6157
|
-
return this.seen.has(
|
|
6141
|
+
#ignored(path13) {
|
|
6142
|
+
return this.seen.has(path13) || !!this.#ignore?.ignored?.(path13);
|
|
6158
6143
|
}
|
|
6159
|
-
#childrenIgnored(
|
|
6160
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
6144
|
+
#childrenIgnored(path13) {
|
|
6145
|
+
return !!this.#ignore?.childrenIgnored?.(path13);
|
|
6161
6146
|
}
|
|
6162
6147
|
// backpressure mechanism
|
|
6163
6148
|
pause() {
|
|
@@ -6372,8 +6357,8 @@ var GlobUtil = class {
|
|
|
6372
6357
|
};
|
|
6373
6358
|
var GlobWalker = class extends GlobUtil {
|
|
6374
6359
|
matches = /* @__PURE__ */ new Set();
|
|
6375
|
-
constructor(patterns,
|
|
6376
|
-
super(patterns,
|
|
6360
|
+
constructor(patterns, path13, opts) {
|
|
6361
|
+
super(patterns, path13, opts);
|
|
6377
6362
|
}
|
|
6378
6363
|
matchEmit(e) {
|
|
6379
6364
|
this.matches.add(e);
|
|
@@ -6410,8 +6395,8 @@ var GlobWalker = class extends GlobUtil {
|
|
|
6410
6395
|
};
|
|
6411
6396
|
var GlobStream = class extends GlobUtil {
|
|
6412
6397
|
results;
|
|
6413
|
-
constructor(patterns,
|
|
6414
|
-
super(patterns,
|
|
6398
|
+
constructor(patterns, path13, opts) {
|
|
6399
|
+
super(patterns, path13, opts);
|
|
6415
6400
|
this.results = new Minipass({
|
|
6416
6401
|
signal: this.signal,
|
|
6417
6402
|
objectMode: true
|
|
@@ -6444,7 +6429,7 @@ var GlobStream = class extends GlobUtil {
|
|
|
6444
6429
|
}
|
|
6445
6430
|
};
|
|
6446
6431
|
|
|
6447
|
-
//
|
|
6432
|
+
// ../../node_modules/.pnpm/glob@11.0.0/node_modules/glob/dist/esm/glob.js
|
|
6448
6433
|
var defaultPlatform3 = typeof process === "object" && process && typeof process.platform === "string" ? process.platform : "linux";
|
|
6449
6434
|
var Glob = class {
|
|
6450
6435
|
absolute;
|
|
@@ -6644,7 +6629,7 @@ var Glob = class {
|
|
|
6644
6629
|
}
|
|
6645
6630
|
};
|
|
6646
6631
|
|
|
6647
|
-
//
|
|
6632
|
+
// ../../node_modules/.pnpm/glob@11.0.0/node_modules/glob/dist/esm/has-magic.js
|
|
6648
6633
|
var hasMagic = (pattern, options = {}) => {
|
|
6649
6634
|
if (!Array.isArray(pattern)) {
|
|
6650
6635
|
pattern = [pattern];
|
|
@@ -6656,7 +6641,7 @@ var hasMagic = (pattern, options = {}) => {
|
|
|
6656
6641
|
return false;
|
|
6657
6642
|
};
|
|
6658
6643
|
|
|
6659
|
-
//
|
|
6644
|
+
// ../../node_modules/.pnpm/glob@11.0.0/node_modules/glob/dist/esm/index.js
|
|
6660
6645
|
function globStreamSync(pattern, options = {}) {
|
|
6661
6646
|
return new Glob(pattern, options).streamSync();
|
|
6662
6647
|
}
|
|
@@ -6704,60 +6689,44 @@ var glob = Object.assign(glob_, {
|
|
|
6704
6689
|
});
|
|
6705
6690
|
glob.glob = glob;
|
|
6706
6691
|
|
|
6707
|
-
// src/build/patches/to-investigate/
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
const manifestJsons = globSync(`${nextjsAppPaths.standaloneAppDotNextDir}/**/*-manifest.json`).map(
|
|
6717
|
-
(file) => file.replace(nextjsAppPaths.standaloneAppDir + "/", "")
|
|
6718
|
-
);
|
|
6719
|
-
code = code.replace(
|
|
6720
|
-
/function loadManifest\((.+?), .+?\) {/,
|
|
6692
|
+
// src/cli/build/patches/to-investigate/inline-eval-manifest.ts
|
|
6693
|
+
import path4 from "node:path";
|
|
6694
|
+
function inlineEvalManifest(code, config) {
|
|
6695
|
+
console.log("# inlineEvalManifest");
|
|
6696
|
+
const manifestJss = globSync(
|
|
6697
|
+
path4.join(config.paths.standaloneAppDotNext, "**", "*_client-reference-manifest.js")
|
|
6698
|
+
).map((file) => file.replace(`${config.paths.standaloneApp}/`, ""));
|
|
6699
|
+
return code.replace(
|
|
6700
|
+
/function evalManifest\((.+?), .+?\) {/,
|
|
6721
6701
|
`$&
|
|
6722
|
-
|
|
6723
|
-
(
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6702
|
+
${manifestJss.map(
|
|
6703
|
+
(manifestJs) => `
|
|
6704
|
+
if ($1.endsWith("${manifestJs}")) {
|
|
6705
|
+
require("${path4.join(config.paths.standaloneApp, manifestJs)}");
|
|
6706
|
+
return {
|
|
6707
|
+
__RSC_MANIFEST: {
|
|
6708
|
+
"${manifestJs.replace(".next/server/app", "").replace("_client-reference-manifest.js", "")}": globalThis.__RSC_MANIFEST["${manifestJs.replace(".next/server/app", "").replace("_client-reference-manifest.js", "")}"],
|
|
6709
|
+
},
|
|
6710
|
+
};
|
|
6711
|
+
}
|
|
6712
|
+
`
|
|
6728
6713
|
).join("\n")}
|
|
6729
|
-
|
|
6730
|
-
`
|
|
6731
|
-
);
|
|
6732
|
-
return code;
|
|
6733
|
-
}
|
|
6734
|
-
|
|
6735
|
-
// src/build/patches/to-investigate/patch-find-dir.ts
|
|
6736
|
-
import { existsSync } from "node:fs";
|
|
6737
|
-
function patchFindDir(code, nextjsAppPaths) {
|
|
6738
|
-
console.log("# patchFindDir");
|
|
6739
|
-
return code.replace(
|
|
6740
|
-
"function findDir(dir, name) {",
|
|
6741
|
-
`function findDir(dir, name) {
|
|
6742
|
-
if (dir.endsWith(".next/server")) {
|
|
6743
|
-
if (name === "app") return ${existsSync(`${nextjsAppPaths.standaloneAppServerDir}/app`)};
|
|
6744
|
-
if (name === "pages") return ${existsSync(`${nextjsAppPaths.standaloneAppServerDir}/pages`)};
|
|
6745
|
-
}
|
|
6746
|
-
throw new Error("Unknown findDir call: " + dir + " " + name);
|
|
6714
|
+
throw new Error("Unknown evalManifest: " + $1);
|
|
6747
6715
|
`
|
|
6748
6716
|
);
|
|
6749
6717
|
}
|
|
6750
6718
|
|
|
6751
|
-
// src/build/patches/to-investigate/inline-next-require.ts
|
|
6752
|
-
import {
|
|
6753
|
-
|
|
6719
|
+
// src/cli/build/patches/to-investigate/inline-next-require.ts
|
|
6720
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
6721
|
+
import path5 from "node:path";
|
|
6722
|
+
function inlineNextRequire(code, config) {
|
|
6754
6723
|
console.log("# inlineNextRequire");
|
|
6755
|
-
const pagesManifestFile =
|
|
6756
|
-
const appPathsManifestFile =
|
|
6757
|
-
const pagesManifestFiles =
|
|
6724
|
+
const pagesManifestFile = path5.join(config.paths.standaloneAppServer, "pages-manifest.json");
|
|
6725
|
+
const appPathsManifestFile = path5.join(config.paths.standaloneAppServer, "app-paths-manifest.json");
|
|
6726
|
+
const pagesManifestFiles = existsSync(pagesManifestFile) ? Object.values(JSON.parse(readFileSync(pagesManifestFile, "utf-8"))).map(
|
|
6758
6727
|
(file) => ".next/server/" + file
|
|
6759
6728
|
) : [];
|
|
6760
|
-
const appPathsManifestFiles =
|
|
6729
|
+
const appPathsManifestFiles = existsSync(appPathsManifestFile) ? Object.values(JSON.parse(readFileSync(appPathsManifestFile, "utf-8"))).map(
|
|
6761
6730
|
(file) => ".next/server/" + file
|
|
6762
6731
|
) : [];
|
|
6763
6732
|
const allManifestFiles = pagesManifestFiles.concat(appPathsManifestFiles);
|
|
@@ -6769,14 +6738,14 @@ function inlineNextRequire(code, nextjsAppPaths) {
|
|
|
6769
6738
|
${htmlPages.map(
|
|
6770
6739
|
(htmlPage) => `
|
|
6771
6740
|
if (pagePath.endsWith("${htmlPage}")) {
|
|
6772
|
-
return ${JSON.stringify(
|
|
6741
|
+
return ${JSON.stringify(readFileSync(path5.join(config.paths.standaloneApp, htmlPage), "utf-8"))};
|
|
6773
6742
|
}
|
|
6774
6743
|
`
|
|
6775
6744
|
).join("\n")}
|
|
6776
6745
|
${pageModules.map(
|
|
6777
6746
|
(module) => `
|
|
6778
6747
|
if (pagePath.endsWith("${module}")) {
|
|
6779
|
-
return require("${
|
|
6748
|
+
return require("${path5.join(config.paths.standaloneApp, module)}");
|
|
6780
6749
|
}
|
|
6781
6750
|
`
|
|
6782
6751
|
).join("\n")}
|
|
@@ -6785,40 +6754,88 @@ function inlineNextRequire(code, nextjsAppPaths) {
|
|
|
6785
6754
|
);
|
|
6786
6755
|
}
|
|
6787
6756
|
|
|
6788
|
-
// src/build/patches/
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6757
|
+
// src/cli/build/patches/investigated/patch-cache.ts
|
|
6758
|
+
import path6 from "node:path";
|
|
6759
|
+
function patchCache(code, config) {
|
|
6760
|
+
console.log("# patchCached");
|
|
6761
|
+
const cacheHandler = path6.join(config.paths.internalPackage, "cli", "cache-handler.mjs");
|
|
6762
|
+
const patchedCode = code.replace(
|
|
6763
|
+
"const { cacheHandler } = this.nextConfig;",
|
|
6764
|
+
`const cacheHandler = null;
|
|
6765
|
+
CacheHandler = (await import('${cacheHandler}')).default;
|
|
6766
|
+
CacheHandler.maybeKVNamespace = process.env["${config.cache.kvBindingName}"];
|
|
6767
|
+
`
|
|
6768
|
+
);
|
|
6769
|
+
if (patchedCode === code) {
|
|
6770
|
+
throw new Error("Cache patch not applied");
|
|
6771
|
+
}
|
|
6772
|
+
return patchedCode;
|
|
6773
|
+
}
|
|
6774
|
+
|
|
6775
|
+
// src/cli/build/patches/to-investigate/patch-find-dir.ts
|
|
6776
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
6777
|
+
import path7 from "node:path";
|
|
6778
|
+
function patchFindDir(code, config) {
|
|
6779
|
+
console.log("# patchFindDir");
|
|
6794
6780
|
return code.replace(
|
|
6795
|
-
|
|
6781
|
+
"function findDir(dir, name) {",
|
|
6782
|
+
`function findDir(dir, name) {
|
|
6783
|
+
if (dir.endsWith(".next/server")) {
|
|
6784
|
+
if (name === "app") {
|
|
6785
|
+
return ${existsSync2(`${path7.join(config.paths.standaloneAppServer, "app")}`)};
|
|
6786
|
+
}
|
|
6787
|
+
if (name === "pages") {
|
|
6788
|
+
return ${existsSync2(`${path7.join(config.paths.standaloneAppServer, "pages")}`)};
|
|
6789
|
+
}
|
|
6790
|
+
}
|
|
6791
|
+
throw new Error("Unknown findDir call: " + dir + " " + name);
|
|
6792
|
+
`
|
|
6793
|
+
);
|
|
6794
|
+
}
|
|
6795
|
+
|
|
6796
|
+
// src/cli/build/patches/to-investigate/patch-read-file.ts
|
|
6797
|
+
import path8 from "node:path";
|
|
6798
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
6799
|
+
function patchReadFile(code, config) {
|
|
6800
|
+
console.log("# patchReadFile");
|
|
6801
|
+
code = code.replace(
|
|
6802
|
+
"getBuildId() {",
|
|
6803
|
+
`getBuildId() {
|
|
6804
|
+
return ${JSON.stringify(readFileSync2(path8.join(config.paths.standaloneAppDotNext, "BUILD_ID"), "utf-8"))};
|
|
6805
|
+
`
|
|
6806
|
+
);
|
|
6807
|
+
const manifestJsons = globSync(path8.join(config.paths.standaloneAppDotNext, "**", "*-manifest.json")).map(
|
|
6808
|
+
(file) => file.replace(config.paths.standaloneApp + "/", "")
|
|
6809
|
+
);
|
|
6810
|
+
code = code.replace(
|
|
6811
|
+
/function loadManifest\((.+?), .+?\) {/,
|
|
6796
6812
|
`$&
|
|
6797
|
-
|
|
6798
|
-
(
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
"${manifestJs.replace(".next/server/app", "").replace("_client-reference-manifest.js", "")}": globalThis.__RSC_MANIFEST["${manifestJs.replace(".next/server/app", "").replace("_client-reference-manifest.js", "")}"],
|
|
6804
|
-
},
|
|
6805
|
-
};
|
|
6806
|
-
}
|
|
6807
|
-
`
|
|
6813
|
+
${manifestJsons.map(
|
|
6814
|
+
(manifestJson) => `
|
|
6815
|
+
if ($1.endsWith("${manifestJson}")) {
|
|
6816
|
+
return ${readFileSync2(path8.join(config.paths.standaloneApp, manifestJson), "utf-8")};
|
|
6817
|
+
}
|
|
6818
|
+
`
|
|
6808
6819
|
).join("\n")}
|
|
6809
|
-
|
|
6810
|
-
|
|
6820
|
+
throw new Error("Unknown loadManifest: " + $1);
|
|
6821
|
+
`
|
|
6811
6822
|
);
|
|
6823
|
+
return code;
|
|
6812
6824
|
}
|
|
6813
6825
|
|
|
6814
|
-
// src/build/patches/
|
|
6815
|
-
|
|
6826
|
+
// src/cli/build/patches/investigated/patch-require.ts
|
|
6827
|
+
function patchRequire(code) {
|
|
6828
|
+
console.log("# patchRequire");
|
|
6829
|
+
return code.replace(/__require\d?\(/g, "require(").replace(/__require\d?\./g, "require.");
|
|
6830
|
+
}
|
|
6831
|
+
|
|
6832
|
+
// src/cli/build/patches/to-investigate/wrangler-deps.ts
|
|
6816
6833
|
import fs, { writeFileSync } from "node:fs";
|
|
6817
|
-
|
|
6834
|
+
import path9 from "node:path";
|
|
6835
|
+
function patchWranglerDeps(config) {
|
|
6818
6836
|
console.log("# patchWranglerDeps");
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
paths.standaloneAppDir,
|
|
6837
|
+
const pagesRuntimeFile = path9.join(
|
|
6838
|
+
config.paths.standaloneApp,
|
|
6822
6839
|
"node_modules",
|
|
6823
6840
|
"next",
|
|
6824
6841
|
"dist",
|
|
@@ -6828,8 +6845,8 @@ function patchWranglerDeps(paths) {
|
|
|
6828
6845
|
);
|
|
6829
6846
|
const patchedPagesRuntime = fs.readFileSync(pagesRuntimeFile, "utf-8").replace(`e.exports=require("critters")`, `e.exports={}`);
|
|
6830
6847
|
fs.writeFileSync(pagesRuntimeFile, patchedPagesRuntime);
|
|
6831
|
-
const tracerFile =
|
|
6832
|
-
paths.
|
|
6848
|
+
const tracerFile = path9.join(
|
|
6849
|
+
config.paths.standaloneApp,
|
|
6833
6850
|
"node_modules",
|
|
6834
6851
|
"next",
|
|
6835
6852
|
"dist",
|
|
@@ -6842,10 +6859,13 @@ function patchWranglerDeps(paths) {
|
|
|
6842
6859
|
writeFileSync(tracerFile, pacthedTracer);
|
|
6843
6860
|
}
|
|
6844
6861
|
|
|
6845
|
-
// src/build/
|
|
6846
|
-
import
|
|
6862
|
+
// src/cli/build/build-worker.ts
|
|
6863
|
+
import path11 from "node:path";
|
|
6864
|
+
|
|
6865
|
+
// src/cli/build/patches/investigated/update-webpack-chunks-file/index.ts
|
|
6866
|
+
import { readFileSync as readFileSync3, readdirSync as readdirSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
6847
6867
|
|
|
6848
|
-
// src/build/patches/investigated/update-webpack-chunks-file/get-chunk-installation-identifiers.ts
|
|
6868
|
+
// src/cli/build/patches/investigated/update-webpack-chunks-file/get-chunk-installation-identifiers.ts
|
|
6849
6869
|
import * as ts from "ts-morph";
|
|
6850
6870
|
async function getChunkInstallationIdentifiers(sourceFile) {
|
|
6851
6871
|
const installChunkDeclaration = getInstallChunkDeclaration(sourceFile);
|
|
@@ -6891,7 +6911,7 @@ function getInstalledChunksDeclaration(sourceFile, installChunkDeclaration) {
|
|
|
6891
6911
|
return installedChunksDeclaration;
|
|
6892
6912
|
}
|
|
6893
6913
|
|
|
6894
|
-
// src/build/patches/investigated/update-webpack-chunks-file/get-file-content-with-updated-webpack-f-require-code.ts
|
|
6914
|
+
// src/cli/build/patches/investigated/update-webpack-chunks-file/get-file-content-with-updated-webpack-f-require-code.ts
|
|
6895
6915
|
import * as ts2 from "ts-morph";
|
|
6896
6916
|
async function getFileContentWithUpdatedWebpackFRequireCode(sourceFile, { installedChunks, installChunk }, chunks) {
|
|
6897
6917
|
const webpackFRequireFunction = sourceFile.getDescendantsOfKind(ts2.SyntaxKind.ArrowFunction).find((arrowFunction) => {
|
|
@@ -6935,7 +6955,7 @@ if(${chunkId} === ${chunk}) return ${installChunk}(require("./chunks/${chunk}.js
|
|
|
6935
6955
|
return sourceFile.print();
|
|
6936
6956
|
}
|
|
6937
6957
|
|
|
6938
|
-
// src/build/utils/ts-parse-file.ts
|
|
6958
|
+
// src/cli/build/utils/ts-parse-file.ts
|
|
6939
6959
|
import * as ts3 from "ts-morph";
|
|
6940
6960
|
function tsParseFile(fileContent) {
|
|
6941
6961
|
const project = new ts3.Project();
|
|
@@ -6943,7 +6963,7 @@ function tsParseFile(fileContent) {
|
|
|
6943
6963
|
return sourceFile;
|
|
6944
6964
|
}
|
|
6945
6965
|
|
|
6946
|
-
// src/build/patches/investigated/update-webpack-chunks-file/get-updated-webpack-chunks-file-content.ts
|
|
6966
|
+
// src/cli/build/patches/investigated/update-webpack-chunks-file/get-updated-webpack-chunks-file-content.ts
|
|
6947
6967
|
async function getUpdatedWebpackChunksFileContent(fileContent, chunks) {
|
|
6948
6968
|
const tsSourceFile = tsParseFile(fileContent);
|
|
6949
6969
|
const chunkInstallationIdentifiers = await getChunkInstallationIdentifiers(tsSourceFile);
|
|
@@ -6955,12 +6975,13 @@ async function getUpdatedWebpackChunksFileContent(fileContent, chunks) {
|
|
|
6955
6975
|
return updatedFileContent;
|
|
6956
6976
|
}
|
|
6957
6977
|
|
|
6958
|
-
// src/build/patches/investigated/update-webpack-chunks-file/index.ts
|
|
6959
|
-
|
|
6978
|
+
// src/cli/build/patches/investigated/update-webpack-chunks-file/index.ts
|
|
6979
|
+
import path10 from "node:path";
|
|
6980
|
+
async function updateWebpackChunksFile(config) {
|
|
6960
6981
|
console.log("# updateWebpackChunksFile");
|
|
6961
|
-
const webpackRuntimeFile =
|
|
6982
|
+
const webpackRuntimeFile = path10.join(config.paths.standaloneAppServer, "webpack-runtime.js");
|
|
6962
6983
|
const fileContent = readFileSync3(webpackRuntimeFile, "utf-8");
|
|
6963
|
-
const chunks =
|
|
6984
|
+
const chunks = readdirSync3(path10.join(config.paths.standaloneAppServer, "chunks")).filter((chunk) => /^\d+\.js$/.test(chunk)).map((chunk) => {
|
|
6964
6985
|
console.log(` - chunk ${chunk}`);
|
|
6965
6986
|
return chunk.replace(/\.js$/, "");
|
|
6966
6987
|
});
|
|
@@ -6968,18 +6989,35 @@ async function updateWebpackChunksFile(nextjsAppPaths) {
|
|
|
6968
6989
|
writeFileSync2(webpackRuntimeFile, updatedFileContent);
|
|
6969
6990
|
}
|
|
6970
6991
|
|
|
6971
|
-
// src/build/build-worker.ts
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6992
|
+
// src/cli/build/build-worker.ts
|
|
6993
|
+
var packageDistDir = path11.join(path11.dirname(fileURLToPath3(import.meta.url)), "..");
|
|
6994
|
+
async function buildWorker(config) {
|
|
6995
|
+
console.log(`\x1B[35m\u2699\uFE0F Copying files...
|
|
6996
|
+
\x1B[0m`);
|
|
6997
|
+
await cp(
|
|
6998
|
+
path11.join(config.paths.dotNext, "static"),
|
|
6999
|
+
path11.join(config.paths.builderOutput, "assets", "_next", "static"),
|
|
7000
|
+
{
|
|
7001
|
+
recursive: true
|
|
7002
|
+
}
|
|
7003
|
+
);
|
|
7004
|
+
const publicDir = path11.join(config.paths.nextApp, "public");
|
|
7005
|
+
if (existsSync3(publicDir)) {
|
|
7006
|
+
await cp(publicDir, path11.join(config.paths.builderOutput, "assets"), {
|
|
7007
|
+
recursive: true
|
|
7008
|
+
});
|
|
7009
|
+
}
|
|
7010
|
+
copyPackageCliFiles(packageDistDir, config);
|
|
7011
|
+
const templateDir = path11.join(config.paths.internalPackage, "cli", "templates");
|
|
7012
|
+
const workerEntrypoint = path11.join(templateDir, "worker.ts");
|
|
7013
|
+
const workerOutputFile = path11.join(config.paths.builderOutput, "index.mjs");
|
|
7014
|
+
const nextConfigStr = readFileSync4(path11.join(config.paths.standaloneApp, "/server.js"), "utf8")?.match(
|
|
6977
7015
|
/const nextConfig = ({.+?})\n/
|
|
6978
7016
|
)?.[1] ?? {};
|
|
6979
7017
|
console.log(`\x1B[35m\u2699\uFE0F Bundling the worker file...
|
|
6980
7018
|
\x1B[0m`);
|
|
6981
|
-
patchWranglerDeps(
|
|
6982
|
-
updateWebpackChunksFile(
|
|
7019
|
+
patchWranglerDeps(config);
|
|
7020
|
+
updateWebpackChunksFile(config);
|
|
6983
7021
|
await build({
|
|
6984
7022
|
entryPoints: [workerEntrypoint],
|
|
6985
7023
|
bundle: true,
|
|
@@ -6992,15 +7030,15 @@ async function buildWorker(outputDir2, nextjsAppPaths, templateSrcDir) {
|
|
|
6992
7030
|
// Note: we apply an empty shim to next/dist/compiled/ws because it generates two `eval`s:
|
|
6993
7031
|
// eval("require")("bufferutil");
|
|
6994
7032
|
// eval("require")("utf-8-validate");
|
|
6995
|
-
"next/dist/compiled/ws":
|
|
7033
|
+
"next/dist/compiled/ws": path11.join(templateDir, "shims", "empty.ts"),
|
|
6996
7034
|
// Note: we apply an empty shim to next/dist/compiled/edge-runtime since (amongst others) it generated the following `eval`:
|
|
6997
7035
|
// eval(getModuleCode)(module, module.exports, throwingRequire, params.context, ...Object.values(params.scopedContext));
|
|
6998
7036
|
// which comes from https://github.com/vercel/edge-runtime/blob/6e96b55f/packages/primitives/src/primitives/load.js#L57-L63
|
|
6999
7037
|
// QUESTION: Why did I encountered this but mhart didn't?
|
|
7000
|
-
"next/dist/compiled/edge-runtime":
|
|
7038
|
+
"next/dist/compiled/edge-runtime": path11.join(templateDir, "shims", "empty.ts"),
|
|
7001
7039
|
// `@next/env` is a library Next.js uses for loading dotenv files, for obvious reasons we need to stub it here
|
|
7002
7040
|
// source: https://github.com/vercel/next.js/tree/0ac10d79720/packages/next-env
|
|
7003
|
-
"@next/env":
|
|
7041
|
+
"@next/env": path11.join(templateDir, "shims", "env.ts")
|
|
7004
7042
|
},
|
|
7005
7043
|
define: {
|
|
7006
7044
|
// config file used by Next.js, see: https://github.com/vercel/next.js/blob/68a7128/packages/next/src/build/utils.ts#L2137-L2139
|
|
@@ -7034,22 +7072,21 @@ async function buildWorker(outputDir2, nextjsAppPaths, templateSrcDir) {
|
|
|
7034
7072
|
// Do not crash on cache not supported
|
|
7035
7073
|
// https://github.com/cloudflare/workerd/pull/2434
|
|
7036
7074
|
// compatibility flag "cache_option_enabled" -> does not support "force-cache"
|
|
7037
|
-
let isPatchedAlready = globalThis.fetch.__nextPatched;
|
|
7038
7075
|
const curFetch = globalThis.fetch;
|
|
7039
7076
|
globalThis.fetch = (input, init) => {
|
|
7040
|
-
|
|
7041
|
-
|
|
7077
|
+
if (init) {
|
|
7078
|
+
delete init.cache;
|
|
7079
|
+
}
|
|
7042
7080
|
return curFetch(input, init);
|
|
7043
7081
|
};
|
|
7044
7082
|
import { Readable } from 'node:stream';
|
|
7045
|
-
globalThis.fetch.__nextPatched = isPatchedAlready;
|
|
7046
7083
|
fetch = globalThis.fetch;
|
|
7047
7084
|
const CustomRequest = class extends globalThis.Request {
|
|
7048
7085
|
constructor(input, init) {
|
|
7049
|
-
console.log("CustomRequest", input);
|
|
7050
7086
|
if (init) {
|
|
7051
7087
|
delete init.cache;
|
|
7052
7088
|
if (init.body?.__node_stream__ === true) {
|
|
7089
|
+
// https://github.com/cloudflare/workerd/issues/2746
|
|
7053
7090
|
init.body = Readable.toWeb(init.body);
|
|
7054
7091
|
}
|
|
7055
7092
|
}
|
|
@@ -7058,127 +7095,113 @@ const CustomRequest = class extends globalThis.Request {
|
|
|
7058
7095
|
};
|
|
7059
7096
|
globalThis.Request = CustomRequest;
|
|
7060
7097
|
Request = globalThis.Request;
|
|
7061
|
-
|
|
7098
|
+
`
|
|
7062
7099
|
}
|
|
7063
7100
|
});
|
|
7064
|
-
await updateWorkerBundledCode(workerOutputFile,
|
|
7065
|
-
console.log(`\x1B[35m\u2699\uFE0F Copying asset files...
|
|
7066
|
-
\x1B[0m`);
|
|
7067
|
-
await cp(`${nextjsAppPaths.dotNextDir}/static`, `${outputDir2}/assets/_next/static`, {
|
|
7068
|
-
recursive: true
|
|
7069
|
-
});
|
|
7101
|
+
await updateWorkerBundledCode(workerOutputFile, config);
|
|
7070
7102
|
console.log(`\x1B[35mWorker saved in \`${workerOutputFile}\` \u{1F680}
|
|
7071
7103
|
\x1B[0m`);
|
|
7072
7104
|
}
|
|
7073
|
-
async function updateWorkerBundledCode(workerOutputFile,
|
|
7105
|
+
async function updateWorkerBundledCode(workerOutputFile, config) {
|
|
7074
7106
|
const originalCode = await readFile(workerOutputFile, "utf8");
|
|
7075
7107
|
let patchedCode = originalCode;
|
|
7076
7108
|
patchedCode = patchRequire(patchedCode);
|
|
7077
|
-
patchedCode = patchReadFile(patchedCode,
|
|
7078
|
-
patchedCode = inlineNextRequire(patchedCode,
|
|
7079
|
-
patchedCode = patchFindDir(patchedCode,
|
|
7080
|
-
patchedCode = inlineEvalManifest(patchedCode,
|
|
7109
|
+
patchedCode = patchReadFile(patchedCode, config);
|
|
7110
|
+
patchedCode = inlineNextRequire(patchedCode, config);
|
|
7111
|
+
patchedCode = patchFindDir(patchedCode, config);
|
|
7112
|
+
patchedCode = inlineEvalManifest(patchedCode, config);
|
|
7113
|
+
patchedCode = patchCache(patchedCode, config);
|
|
7081
7114
|
await writeFile(workerOutputFile, patchedCode);
|
|
7082
7115
|
}
|
|
7083
7116
|
function createFixRequiresESBuildPlugin(templateDir) {
|
|
7084
7117
|
return {
|
|
7085
7118
|
name: "replaceRelative",
|
|
7086
7119
|
setup(build3) {
|
|
7087
|
-
build3.onResolve({ filter: /^\.\/require-hook$/ }, (
|
|
7088
|
-
path:
|
|
7120
|
+
build3.onResolve({ filter: /^\.\/require-hook$/ }, () => ({
|
|
7121
|
+
path: path11.join(templateDir, "shims", "empty.ts")
|
|
7089
7122
|
}));
|
|
7090
|
-
build3.onResolve({ filter: /\.\/lib\/node-fs-methods$/ }, (
|
|
7091
|
-
path:
|
|
7123
|
+
build3.onResolve({ filter: /\.\/lib\/node-fs-methods$/ }, () => ({
|
|
7124
|
+
path: path11.join(templateDir, "shims", "empty.ts")
|
|
7092
7125
|
}));
|
|
7093
7126
|
}
|
|
7094
7127
|
};
|
|
7095
7128
|
}
|
|
7096
7129
|
|
|
7097
|
-
// src/
|
|
7098
|
-
import {
|
|
7099
|
-
import
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7130
|
+
// src/cli/build/index.ts
|
|
7131
|
+
import { cpSync as cpSync2 } from "node:fs";
|
|
7132
|
+
import path12 from "node:path";
|
|
7133
|
+
import { rm } from "node:fs/promises";
|
|
7134
|
+
async function build2(appDir, opts) {
|
|
7135
|
+
if (!opts.skipBuild) {
|
|
7136
|
+
buildNextjsApp(appDir);
|
|
7137
|
+
}
|
|
7138
|
+
if (!containsDotNextDir(appDir)) {
|
|
7139
|
+
throw new Error(`.next folder not found in ${appDir}`);
|
|
7140
|
+
}
|
|
7141
|
+
const outputDir2 = path12.resolve(opts.outputDir ?? appDir, ".worker-next");
|
|
7142
|
+
await cleanDirectory(outputDir2);
|
|
7143
|
+
cpSync2(path12.join(appDir, ".next"), path12.join(outputDir2, ".next"), { recursive: true });
|
|
7144
|
+
const config = getConfig(appDir, outputDir2);
|
|
7145
|
+
await buildWorker(config);
|
|
7146
|
+
}
|
|
7147
|
+
async function cleanDirectory(path13) {
|
|
7148
|
+
return await rm(path13, { recursive: true, force: true });
|
|
7149
|
+
}
|
|
7150
|
+
|
|
7151
|
+
// src/cli/index.ts
|
|
7152
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
7153
|
+
|
|
7154
|
+
// src/cli/args.ts
|
|
7155
|
+
import { mkdirSync, statSync as statSync2 } from "node:fs";
|
|
7156
|
+
import { parseArgs } from "node:util";
|
|
7157
|
+
import { resolve } from "node:path";
|
|
7158
|
+
function getArgs() {
|
|
7159
|
+
const {
|
|
7160
|
+
values: { skipBuild: skipBuild2, output }
|
|
7161
|
+
} = parseArgs({
|
|
7162
|
+
options: {
|
|
7163
|
+
skipBuild: {
|
|
7164
|
+
type: "boolean",
|
|
7165
|
+
short: "s",
|
|
7166
|
+
default: false
|
|
7167
|
+
},
|
|
7168
|
+
output: {
|
|
7169
|
+
type: "string",
|
|
7170
|
+
short: "o"
|
|
7171
|
+
}
|
|
7172
|
+
},
|
|
7173
|
+
allowPositionals: false
|
|
7174
|
+
});
|
|
7175
|
+
const outputDir2 = output ? resolve(output) : void 0;
|
|
7176
|
+
if (outputDir2) {
|
|
7177
|
+
assertDirArg(outputDir2, "output", true);
|
|
7178
|
+
}
|
|
7104
7179
|
return {
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
standaloneAppDir,
|
|
7108
|
-
standaloneAppDotNextDir: path4.join(standaloneAppDir, ".next"),
|
|
7109
|
-
standaloneAppServerDir: path4.join(standaloneAppDir, ".next", "server")
|
|
7180
|
+
outputDir: outputDir2,
|
|
7181
|
+
skipBuild: skipBuild2 || ["1", "true", "yes"].includes(String(process.env.SKIP_NEXT_APP_BUILD))
|
|
7110
7182
|
};
|
|
7111
7183
|
}
|
|
7112
|
-
function
|
|
7113
|
-
|
|
7184
|
+
function assertDirArg(path13, argName, make) {
|
|
7185
|
+
let dirStats;
|
|
7114
7186
|
try {
|
|
7115
|
-
|
|
7116
|
-
if (!dirStats.isDirectory()) throw new Error();
|
|
7187
|
+
dirStats = statSync2(path13);
|
|
7117
7188
|
} catch {
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
return dotNextDirPath;
|
|
7121
|
-
}
|
|
7122
|
-
function getNextjsApplicationPath(dotNextDir) {
|
|
7123
|
-
const serverPath = findServerParentPath(dotNextDir);
|
|
7124
|
-
if (!serverPath) {
|
|
7125
|
-
throw new Error(`Unexpected Error: no \`.next/server\` folder could be found in \`${serverPath}\``);
|
|
7126
|
-
}
|
|
7127
|
-
return relative(`${dotNextDir}/standalone`, serverPath);
|
|
7128
|
-
function findServerParentPath(path6) {
|
|
7129
|
-
try {
|
|
7130
|
-
if (statSync2(`${path6}/.next/server`).isDirectory()) {
|
|
7131
|
-
return path6;
|
|
7132
|
-
}
|
|
7133
|
-
} catch {
|
|
7134
|
-
}
|
|
7135
|
-
const files = readdirSync3(path6);
|
|
7136
|
-
for (const file of files) {
|
|
7137
|
-
if (statSync2(`${path6}/${file}`).isDirectory()) {
|
|
7138
|
-
const dirServerPath = findServerParentPath(`${path6}/${file}`);
|
|
7139
|
-
if (dirServerPath) {
|
|
7140
|
-
return dirServerPath;
|
|
7141
|
-
}
|
|
7142
|
-
}
|
|
7189
|
+
if (!make) {
|
|
7190
|
+
throw new Error(`Error: the provided${argName ? ` "${argName}"` : ""} input is not a valid path`);
|
|
7143
7191
|
}
|
|
7192
|
+
mkdirSync(path13);
|
|
7193
|
+
return;
|
|
7144
7194
|
}
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
// src/build/build.ts
|
|
7148
|
-
import path5 from "node:path";
|
|
7149
|
-
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
7150
|
-
import { cpSync as cpSync2, rmSync } from "node:fs";
|
|
7151
|
-
var SAVE_DIR = ".save.next";
|
|
7152
|
-
async function build2(inputNextAppDir, opts) {
|
|
7153
|
-
if (!opts.skipBuild) {
|
|
7154
|
-
buildNextjsApp(inputNextAppDir);
|
|
7155
|
-
rmSync(`${inputNextAppDir}/${SAVE_DIR}`, {
|
|
7156
|
-
recursive: true,
|
|
7157
|
-
force: true
|
|
7158
|
-
});
|
|
7159
|
-
cpSync2(`${inputNextAppDir}/.next`, `${inputNextAppDir}/${SAVE_DIR}`, {
|
|
7160
|
-
recursive: true
|
|
7161
|
-
});
|
|
7162
|
-
} else {
|
|
7163
|
-
rmSync(`${inputNextAppDir}/.next`, { recursive: true, force: true });
|
|
7164
|
-
cpSync2(`${inputNextAppDir}/${SAVE_DIR}`, `${inputNextAppDir}/.next`, {
|
|
7165
|
-
recursive: true
|
|
7166
|
-
});
|
|
7195
|
+
if (!dirStats.isDirectory()) {
|
|
7196
|
+
throw new Error(`Error: the provided${argName ? ` "${argName}"` : ""} input is not a directory`);
|
|
7167
7197
|
}
|
|
7168
|
-
const outputDir2 = `${opts.outputDir ?? inputNextAppDir}/.worker-next`;
|
|
7169
|
-
await cleanDirectory(outputDir2);
|
|
7170
|
-
const nextjsAppPaths = getNextjsAppPaths(inputNextAppDir);
|
|
7171
|
-
const templateDir = path5.join(path5.dirname(fileURLToPath3(import.meta.url)), "templates");
|
|
7172
|
-
await buildWorker(outputDir2, nextjsAppPaths, templateDir);
|
|
7173
|
-
}
|
|
7174
|
-
async function cleanDirectory(path6) {
|
|
7175
|
-
return await rm(path6, { recursive: true, force: true });
|
|
7176
7198
|
}
|
|
7177
7199
|
|
|
7178
|
-
// src/index.ts
|
|
7200
|
+
// src/cli/index.ts
|
|
7201
|
+
import { resolve as resolve2 } from "node:path";
|
|
7179
7202
|
var nextAppDir = resolve2(".");
|
|
7180
7203
|
console.log(`Building the Next.js app in the current folder (${nextAppDir})`);
|
|
7181
|
-
if (!["js", "cjs", "mjs", "ts"].some((ext2) =>
|
|
7204
|
+
if (!["js", "cjs", "mjs", "ts"].some((ext2) => existsSync4(`./next.config.${ext2}`))) {
|
|
7182
7205
|
throw new Error("Error: Not in a Next.js app project");
|
|
7183
7206
|
}
|
|
7184
7207
|
var { skipBuild, outputDir } = getArgs();
|