@vercel/remix-builder 5.1.0 → 5.1.2

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.
Files changed (2) hide show
  1. package/dist/index.js +479 -72
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -2816,6 +2816,396 @@ var require_dist = __commonJS({
2816
2816
  }
2817
2817
  });
2818
2818
 
2819
+ // ../../node_modules/.pnpm/path-to-regexp@6.3.0/node_modules/path-to-regexp/dist/index.js
2820
+ var require_dist2 = __commonJS({
2821
+ "../../node_modules/.pnpm/path-to-regexp@6.3.0/node_modules/path-to-regexp/dist/index.js"(exports) {
2822
+ "use strict";
2823
+ Object.defineProperty(exports, "__esModule", { value: true });
2824
+ exports.pathToRegexp = exports.tokensToRegexp = exports.regexpToFunction = exports.match = exports.tokensToFunction = exports.compile = exports.parse = void 0;
2825
+ function lexer(str) {
2826
+ var tokens = [];
2827
+ var i = 0;
2828
+ while (i < str.length) {
2829
+ var char = str[i];
2830
+ if (char === "*" || char === "+" || char === "?") {
2831
+ tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
2832
+ continue;
2833
+ }
2834
+ if (char === "\\") {
2835
+ tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
2836
+ continue;
2837
+ }
2838
+ if (char === "{") {
2839
+ tokens.push({ type: "OPEN", index: i, value: str[i++] });
2840
+ continue;
2841
+ }
2842
+ if (char === "}") {
2843
+ tokens.push({ type: "CLOSE", index: i, value: str[i++] });
2844
+ continue;
2845
+ }
2846
+ if (char === ":") {
2847
+ var name = "";
2848
+ var j = i + 1;
2849
+ while (j < str.length) {
2850
+ var code = str.charCodeAt(j);
2851
+ if (
2852
+ // `0-9`
2853
+ code >= 48 && code <= 57 || // `A-Z`
2854
+ code >= 65 && code <= 90 || // `a-z`
2855
+ code >= 97 && code <= 122 || // `_`
2856
+ code === 95
2857
+ ) {
2858
+ name += str[j++];
2859
+ continue;
2860
+ }
2861
+ break;
2862
+ }
2863
+ if (!name)
2864
+ throw new TypeError("Missing parameter name at ".concat(i));
2865
+ tokens.push({ type: "NAME", index: i, value: name });
2866
+ i = j;
2867
+ continue;
2868
+ }
2869
+ if (char === "(") {
2870
+ var count = 1;
2871
+ var pattern = "";
2872
+ var j = i + 1;
2873
+ if (str[j] === "?") {
2874
+ throw new TypeError('Pattern cannot start with "?" at '.concat(j));
2875
+ }
2876
+ while (j < str.length) {
2877
+ if (str[j] === "\\") {
2878
+ pattern += str[j++] + str[j++];
2879
+ continue;
2880
+ }
2881
+ if (str[j] === ")") {
2882
+ count--;
2883
+ if (count === 0) {
2884
+ j++;
2885
+ break;
2886
+ }
2887
+ } else if (str[j] === "(") {
2888
+ count++;
2889
+ if (str[j + 1] !== "?") {
2890
+ throw new TypeError("Capturing groups are not allowed at ".concat(j));
2891
+ }
2892
+ }
2893
+ pattern += str[j++];
2894
+ }
2895
+ if (count)
2896
+ throw new TypeError("Unbalanced pattern at ".concat(i));
2897
+ if (!pattern)
2898
+ throw new TypeError("Missing pattern at ".concat(i));
2899
+ tokens.push({ type: "PATTERN", index: i, value: pattern });
2900
+ i = j;
2901
+ continue;
2902
+ }
2903
+ tokens.push({ type: "CHAR", index: i, value: str[i++] });
2904
+ }
2905
+ tokens.push({ type: "END", index: i, value: "" });
2906
+ return tokens;
2907
+ }
2908
+ function parse(str, options) {
2909
+ if (options === void 0) {
2910
+ options = {};
2911
+ }
2912
+ var tokens = lexer(str);
2913
+ var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a, _b = options.delimiter, delimiter = _b === void 0 ? "/#?" : _b;
2914
+ var result = [];
2915
+ var key = 0;
2916
+ var i = 0;
2917
+ var path = "";
2918
+ var tryConsume = function(type) {
2919
+ if (i < tokens.length && tokens[i].type === type)
2920
+ return tokens[i++].value;
2921
+ };
2922
+ var mustConsume = function(type) {
2923
+ var value2 = tryConsume(type);
2924
+ if (value2 !== void 0)
2925
+ return value2;
2926
+ var _a2 = tokens[i], nextType = _a2.type, index = _a2.index;
2927
+ throw new TypeError("Unexpected ".concat(nextType, " at ").concat(index, ", expected ").concat(type));
2928
+ };
2929
+ var consumeText = function() {
2930
+ var result2 = "";
2931
+ var value2;
2932
+ while (value2 = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR")) {
2933
+ result2 += value2;
2934
+ }
2935
+ return result2;
2936
+ };
2937
+ var isSafe = function(value2) {
2938
+ for (var _i = 0, delimiter_1 = delimiter; _i < delimiter_1.length; _i++) {
2939
+ var char2 = delimiter_1[_i];
2940
+ if (value2.indexOf(char2) > -1)
2941
+ return true;
2942
+ }
2943
+ return false;
2944
+ };
2945
+ var safePattern = function(prefix2) {
2946
+ var prev = result[result.length - 1];
2947
+ var prevText = prefix2 || (prev && typeof prev === "string" ? prev : "");
2948
+ if (prev && !prevText) {
2949
+ throw new TypeError('Must have text between two parameters, missing text after "'.concat(prev.name, '"'));
2950
+ }
2951
+ if (!prevText || isSafe(prevText))
2952
+ return "[^".concat(escapeString(delimiter), "]+?");
2953
+ return "(?:(?!".concat(escapeString(prevText), ")[^").concat(escapeString(delimiter), "])+?");
2954
+ };
2955
+ while (i < tokens.length) {
2956
+ var char = tryConsume("CHAR");
2957
+ var name = tryConsume("NAME");
2958
+ var pattern = tryConsume("PATTERN");
2959
+ if (name || pattern) {
2960
+ var prefix = char || "";
2961
+ if (prefixes.indexOf(prefix) === -1) {
2962
+ path += prefix;
2963
+ prefix = "";
2964
+ }
2965
+ if (path) {
2966
+ result.push(path);
2967
+ path = "";
2968
+ }
2969
+ result.push({
2970
+ name: name || key++,
2971
+ prefix,
2972
+ suffix: "",
2973
+ pattern: pattern || safePattern(prefix),
2974
+ modifier: tryConsume("MODIFIER") || ""
2975
+ });
2976
+ continue;
2977
+ }
2978
+ var value = char || tryConsume("ESCAPED_CHAR");
2979
+ if (value) {
2980
+ path += value;
2981
+ continue;
2982
+ }
2983
+ if (path) {
2984
+ result.push(path);
2985
+ path = "";
2986
+ }
2987
+ var open = tryConsume("OPEN");
2988
+ if (open) {
2989
+ var prefix = consumeText();
2990
+ var name_1 = tryConsume("NAME") || "";
2991
+ var pattern_1 = tryConsume("PATTERN") || "";
2992
+ var suffix = consumeText();
2993
+ mustConsume("CLOSE");
2994
+ result.push({
2995
+ name: name_1 || (pattern_1 ? key++ : ""),
2996
+ pattern: name_1 && !pattern_1 ? safePattern(prefix) : pattern_1,
2997
+ prefix,
2998
+ suffix,
2999
+ modifier: tryConsume("MODIFIER") || ""
3000
+ });
3001
+ continue;
3002
+ }
3003
+ mustConsume("END");
3004
+ }
3005
+ return result;
3006
+ }
3007
+ exports.parse = parse;
3008
+ function compile(str, options) {
3009
+ return tokensToFunction(parse(str, options), options);
3010
+ }
3011
+ exports.compile = compile;
3012
+ function tokensToFunction(tokens, options) {
3013
+ if (options === void 0) {
3014
+ options = {};
3015
+ }
3016
+ var reFlags = flags(options);
3017
+ var _a = options.encode, encode = _a === void 0 ? function(x) {
3018
+ return x;
3019
+ } : _a, _b = options.validate, validate = _b === void 0 ? true : _b;
3020
+ var matches = tokens.map(function(token) {
3021
+ if (typeof token === "object") {
3022
+ return new RegExp("^(?:".concat(token.pattern, ")$"), reFlags);
3023
+ }
3024
+ });
3025
+ return function(data) {
3026
+ var path = "";
3027
+ for (var i = 0; i < tokens.length; i++) {
3028
+ var token = tokens[i];
3029
+ if (typeof token === "string") {
3030
+ path += token;
3031
+ continue;
3032
+ }
3033
+ var value = data ? data[token.name] : void 0;
3034
+ var optional = token.modifier === "?" || token.modifier === "*";
3035
+ var repeat = token.modifier === "*" || token.modifier === "+";
3036
+ if (Array.isArray(value)) {
3037
+ if (!repeat) {
3038
+ throw new TypeError('Expected "'.concat(token.name, '" to not repeat, but got an array'));
3039
+ }
3040
+ if (value.length === 0) {
3041
+ if (optional)
3042
+ continue;
3043
+ throw new TypeError('Expected "'.concat(token.name, '" to not be empty'));
3044
+ }
3045
+ for (var j = 0; j < value.length; j++) {
3046
+ var segment = encode(value[j], token);
3047
+ if (validate && !matches[i].test(segment)) {
3048
+ throw new TypeError('Expected all "'.concat(token.name, '" to match "').concat(token.pattern, '", but got "').concat(segment, '"'));
3049
+ }
3050
+ path += token.prefix + segment + token.suffix;
3051
+ }
3052
+ continue;
3053
+ }
3054
+ if (typeof value === "string" || typeof value === "number") {
3055
+ var segment = encode(String(value), token);
3056
+ if (validate && !matches[i].test(segment)) {
3057
+ throw new TypeError('Expected "'.concat(token.name, '" to match "').concat(token.pattern, '", but got "').concat(segment, '"'));
3058
+ }
3059
+ path += token.prefix + segment + token.suffix;
3060
+ continue;
3061
+ }
3062
+ if (optional)
3063
+ continue;
3064
+ var typeOfMessage = repeat ? "an array" : "a string";
3065
+ throw new TypeError('Expected "'.concat(token.name, '" to be ').concat(typeOfMessage));
3066
+ }
3067
+ return path;
3068
+ };
3069
+ }
3070
+ exports.tokensToFunction = tokensToFunction;
3071
+ function match(str, options) {
3072
+ var keys = [];
3073
+ var re = pathToRegexp2(str, keys, options);
3074
+ return regexpToFunction(re, keys, options);
3075
+ }
3076
+ exports.match = match;
3077
+ function regexpToFunction(re, keys, options) {
3078
+ if (options === void 0) {
3079
+ options = {};
3080
+ }
3081
+ var _a = options.decode, decode = _a === void 0 ? function(x) {
3082
+ return x;
3083
+ } : _a;
3084
+ return function(pathname) {
3085
+ var m = re.exec(pathname);
3086
+ if (!m)
3087
+ return false;
3088
+ var path = m[0], index = m.index;
3089
+ var params = /* @__PURE__ */ Object.create(null);
3090
+ var _loop_1 = function(i2) {
3091
+ if (m[i2] === void 0)
3092
+ return "continue";
3093
+ var key = keys[i2 - 1];
3094
+ if (key.modifier === "*" || key.modifier === "+") {
3095
+ params[key.name] = m[i2].split(key.prefix + key.suffix).map(function(value) {
3096
+ return decode(value, key);
3097
+ });
3098
+ } else {
3099
+ params[key.name] = decode(m[i2], key);
3100
+ }
3101
+ };
3102
+ for (var i = 1; i < m.length; i++) {
3103
+ _loop_1(i);
3104
+ }
3105
+ return { path, index, params };
3106
+ };
3107
+ }
3108
+ exports.regexpToFunction = regexpToFunction;
3109
+ function escapeString(str) {
3110
+ return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
3111
+ }
3112
+ function flags(options) {
3113
+ return options && options.sensitive ? "" : "i";
3114
+ }
3115
+ function regexpToRegexp(path, keys) {
3116
+ if (!keys)
3117
+ return path;
3118
+ var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
3119
+ var index = 0;
3120
+ var execResult = groupsRegex.exec(path.source);
3121
+ while (execResult) {
3122
+ keys.push({
3123
+ // Use parenthesized substring match if available, index otherwise
3124
+ name: execResult[1] || index++,
3125
+ prefix: "",
3126
+ suffix: "",
3127
+ modifier: "",
3128
+ pattern: ""
3129
+ });
3130
+ execResult = groupsRegex.exec(path.source);
3131
+ }
3132
+ return path;
3133
+ }
3134
+ function arrayToRegexp(paths, keys, options) {
3135
+ var parts = paths.map(function(path) {
3136
+ return pathToRegexp2(path, keys, options).source;
3137
+ });
3138
+ return new RegExp("(?:".concat(parts.join("|"), ")"), flags(options));
3139
+ }
3140
+ function stringToRegexp(path, keys, options) {
3141
+ return tokensToRegexp(parse(path, options), keys, options);
3142
+ }
3143
+ function tokensToRegexp(tokens, keys, options) {
3144
+ if (options === void 0) {
3145
+ options = {};
3146
+ }
3147
+ var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
3148
+ return x;
3149
+ } : _d, _e = options.delimiter, delimiter = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
3150
+ var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
3151
+ var delimiterRe = "[".concat(escapeString(delimiter), "]");
3152
+ var route = start ? "^" : "";
3153
+ for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
3154
+ var token = tokens_1[_i];
3155
+ if (typeof token === "string") {
3156
+ route += escapeString(encode(token));
3157
+ } else {
3158
+ var prefix = escapeString(encode(token.prefix));
3159
+ var suffix = escapeString(encode(token.suffix));
3160
+ if (token.pattern) {
3161
+ if (keys)
3162
+ keys.push(token);
3163
+ if (prefix || suffix) {
3164
+ if (token.modifier === "+" || token.modifier === "*") {
3165
+ var mod = token.modifier === "*" ? "?" : "";
3166
+ route += "(?:".concat(prefix, "((?:").concat(token.pattern, ")(?:").concat(suffix).concat(prefix, "(?:").concat(token.pattern, "))*)").concat(suffix, ")").concat(mod);
3167
+ } else {
3168
+ route += "(?:".concat(prefix, "(").concat(token.pattern, ")").concat(suffix, ")").concat(token.modifier);
3169
+ }
3170
+ } else {
3171
+ if (token.modifier === "+" || token.modifier === "*") {
3172
+ throw new TypeError('Can not repeat "'.concat(token.name, '" without a prefix and suffix'));
3173
+ }
3174
+ route += "(".concat(token.pattern, ")").concat(token.modifier);
3175
+ }
3176
+ } else {
3177
+ route += "(?:".concat(prefix).concat(suffix, ")").concat(token.modifier);
3178
+ }
3179
+ }
3180
+ }
3181
+ if (end) {
3182
+ if (!strict)
3183
+ route += "".concat(delimiterRe, "?");
3184
+ route += !options.endsWith ? "$" : "(?=".concat(endsWithRe, ")");
3185
+ } else {
3186
+ var endToken = tokens[tokens.length - 1];
3187
+ var isEndDelimited = typeof endToken === "string" ? delimiterRe.indexOf(endToken[endToken.length - 1]) > -1 : endToken === void 0;
3188
+ if (!strict) {
3189
+ route += "(?:".concat(delimiterRe, "(?=").concat(endsWithRe, "))?");
3190
+ }
3191
+ if (!isEndDelimited) {
3192
+ route += "(?=".concat(delimiterRe, "|").concat(endsWithRe, ")");
3193
+ }
3194
+ }
3195
+ return new RegExp(route, flags(options));
3196
+ }
3197
+ exports.tokensToRegexp = tokensToRegexp;
3198
+ function pathToRegexp2(path, keys, options) {
3199
+ if (path instanceof RegExp)
3200
+ return regexpToRegexp(path, keys);
3201
+ if (Array.isArray(path))
3202
+ return arrayToRegexp(path, keys, options);
3203
+ return stringToRegexp(path, keys, options);
3204
+ }
3205
+ exports.pathToRegexp = pathToRegexp2;
3206
+ }
3207
+ });
3208
+
2819
3209
  // src/index.ts
2820
3210
  var src_exports = {};
2821
3211
  __export(src_exports, {
@@ -2837,9 +3227,40 @@ var import_semver = __toESM(require_semver2());
2837
3227
  var import_fs = require("fs");
2838
3228
  var import_path = require("path");
2839
3229
  var import_path_to_regexp = __toESM(require_dist());
3230
+ var import_path_to_regexp_updated = __toESM(require_dist2());
2840
3231
  var import_build_utils = require("@vercel/build-utils");
2841
3232
  var import_build_utils2 = require("@vercel/build-utils");
2842
3233
  var import_module = require("module");
3234
+ function pathToRegexp(callerId, path, keys, options) {
3235
+ const currentRegExp = (0, import_path_to_regexp.pathToRegexp)(path, keys, options);
3236
+ try {
3237
+ const currentKeys = keys;
3238
+ const newKeys = [];
3239
+ const newRegExp = (0, import_path_to_regexp_updated.pathToRegexp)(path, newKeys, options);
3240
+ const isDiffRegExp = currentRegExp.toString() !== newRegExp.toString();
3241
+ if (process.env.FORCE_PATH_TO_REGEXP_LOG || isDiffRegExp) {
3242
+ const message = JSON.stringify({
3243
+ path,
3244
+ currentRegExp: currentRegExp.toString(),
3245
+ newRegExp: newRegExp.toString()
3246
+ });
3247
+ console.error(`[vc] PATH TO REGEXP PATH DIFF @ #${callerId}: ${message}`);
3248
+ }
3249
+ const isDiffKeys = keys?.toString() !== newKeys?.toString();
3250
+ if (process.env.FORCE_PATH_TO_REGEXP_LOG || isDiffKeys) {
3251
+ const message = JSON.stringify({
3252
+ isDiffKeys,
3253
+ currentKeys,
3254
+ newKeys
3255
+ });
3256
+ console.error(`[vc] PATH TO REGEXP KEYS DIFF @ #${callerId}: ${message}`);
3257
+ }
3258
+ } catch (err) {
3259
+ const error = err;
3260
+ console.error(`[vc] PATH TO REGEXP ERROR @ #${callerId}: ${error.message}`);
3261
+ }
3262
+ return currentRegExp;
3263
+ }
2843
3264
  var require_ = (0, import_module.createRequire)(__filename);
2844
3265
  var SPLAT_PATH = "/:params*";
2845
3266
  var entryExts = [".js", ".jsx", ".ts", ".tsx"];
@@ -2950,7 +3371,7 @@ function getPathFromRoute(route, routes) {
2950
3371
  }
2951
3372
  function getRegExpFromPath(rePath) {
2952
3373
  const keys = [];
2953
- const re = (0, import_path_to_regexp.pathToRegexp)(rePath, keys);
3374
+ const re = pathToRegexp("923", rePath, keys);
2954
3375
  return keys.length > 0 ? re : false;
2955
3376
  }
2956
3377
  async function chdirAndReadConfig(remixRunDevPath, dir, packageJsonPath) {
@@ -3143,6 +3564,8 @@ var REMIX_FRAMEWORK_SETTINGS = {
3143
3564
  primaryPackageName: "@remix-run/dev",
3144
3565
  buildCommand: "remix build",
3145
3566
  buildResultFilePath: ".vercel/remix-build-result.json",
3567
+ slug: "remix",
3568
+ sourceSearchValue: "@remix-run/dev/server-build",
3146
3569
  createRenderFunction({
3147
3570
  nodeVersion,
3148
3571
  entrypointDir,
@@ -3177,6 +3600,8 @@ var REACT_ROUTER_FRAMEWORK_SETTINGS = {
3177
3600
  primaryPackageName: "react-router",
3178
3601
  buildCommand: "react-router build",
3179
3602
  buildResultFilePath: ".vercel/react-router-build-result.json",
3603
+ slug: "react-router",
3604
+ sourceSearchValue: "ENTRYPOINT_PLACEHOLDER",
3180
3605
  createRenderFunction({
3181
3606
  nodeVersion,
3182
3607
  entrypointDir,
@@ -3405,6 +3830,43 @@ var build = async ({
3405
3830
  });
3406
3831
  return { routes, output, framework: { version: frameworkVersion } };
3407
3832
  };
3833
+ async function edgeReadFile(fsPath) {
3834
+ let source;
3835
+ try {
3836
+ source = await import_fs2.promises.readFile(fsPath);
3837
+ } catch (err) {
3838
+ if (err.code === "ENOENT" || err.code === "EISDIR") {
3839
+ return null;
3840
+ }
3841
+ throw err;
3842
+ }
3843
+ if ((0, import_path2.basename)(fsPath) === "package.json") {
3844
+ const pkgJson = JSON.parse(source.toString());
3845
+ for (const prop of ["browser", "module"]) {
3846
+ const val = pkgJson[prop];
3847
+ if (typeof val === "string") {
3848
+ pkgJson.main = val;
3849
+ source = JSON.stringify(pkgJson);
3850
+ break;
3851
+ }
3852
+ }
3853
+ }
3854
+ return source;
3855
+ }
3856
+ var EDGE_TRACE_CONDITIONS = [
3857
+ "edge-light",
3858
+ "browser",
3859
+ "module",
3860
+ "import",
3861
+ "require"
3862
+ ];
3863
+ var COMMON_NODE_FUNCTION_OPTIONS = {
3864
+ shouldAddHelpers: false,
3865
+ shouldAddSourcemapSupport: false,
3866
+ operationType: "SSR",
3867
+ supportsResponseStreaming: true
3868
+ };
3869
+ var COMMON_EDGE_FUNCTION_OPTIONS = { deploymentTarget: "v8-worker" };
3408
3870
  async function createRenderReactRouterFunction(nodeVersion, entrypointDir, rootDir, serverBuildPath, serverEntryPoint, frameworkVersion, config) {
3409
3871
  const isEdgeFunction = config.runtime === "edge";
3410
3872
  const files = {};
@@ -3418,7 +3880,7 @@ async function createRenderReactRouterFunction(nodeVersion, entrypointDir, rootD
3418
3880
  await import_fs2.promises.writeFile(
3419
3881
  handlerPath,
3420
3882
  reactRouterServerSrc.replace(
3421
- "ENTRYPOINT_PLACEHOLDER",
3883
+ REACT_ROUTER_FRAMEWORK_SETTINGS.sourceSearchValue,
3422
3884
  `./${baseServerBuildPath}.js`
3423
3885
  )
3424
3886
  );
@@ -3426,30 +3888,8 @@ async function createRenderReactRouterFunction(nodeVersion, entrypointDir, rootD
3426
3888
  let conditions;
3427
3889
  let readFile;
3428
3890
  if (isEdgeFunction) {
3429
- conditions = ["edge-light", "browser", "module", "import", "require"];
3430
- readFile = async (fsPath) => {
3431
- let source;
3432
- try {
3433
- source = await import_fs2.promises.readFile(fsPath);
3434
- } catch (err) {
3435
- if (err.code === "ENOENT" || err.code === "EISDIR") {
3436
- return null;
3437
- }
3438
- throw err;
3439
- }
3440
- if ((0, import_path2.basename)(fsPath) === "package.json") {
3441
- const pkgJson = JSON.parse(source.toString());
3442
- for (const prop of ["browser", "module"]) {
3443
- const val = pkgJson[prop];
3444
- if (typeof val === "string") {
3445
- pkgJson.main = val;
3446
- source = JSON.stringify(pkgJson);
3447
- break;
3448
- }
3449
- }
3450
- }
3451
- return source;
3452
- };
3891
+ conditions = EDGE_TRACE_CONDITIONS;
3892
+ readFile = edgeReadFile;
3453
3893
  }
3454
3894
  const trace = await (0, import_nft.nodeFileTrace)([handlerPath], {
3455
3895
  base: rootDir,
@@ -3464,30 +3904,27 @@ async function createRenderReactRouterFunction(nodeVersion, entrypointDir, rootD
3464
3904
  let fn;
3465
3905
  if (isEdgeFunction) {
3466
3906
  fn = new import_build_utils3.EdgeFunction({
3907
+ ...COMMON_EDGE_FUNCTION_OPTIONS,
3467
3908
  files,
3468
- deploymentTarget: "v8-worker",
3469
3909
  entrypoint: handler,
3470
3910
  regions: config.regions,
3471
3911
  framework: {
3472
- slug: "react-router",
3912
+ slug: REACT_ROUTER_FRAMEWORK_SETTINGS.slug,
3473
3913
  version: frameworkVersion
3474
3914
  }
3475
3915
  });
3476
3916
  } else {
3477
3917
  fn = new import_build_utils3.NodejsLambda({
3918
+ ...COMMON_NODE_FUNCTION_OPTIONS,
3478
3919
  files,
3479
3920
  handler,
3480
3921
  runtime: nodeVersion.runtime,
3481
- shouldAddHelpers: false,
3482
- shouldAddSourcemapSupport: false,
3483
- operationType: "SSR",
3484
- supportsResponseStreaming: true,
3485
3922
  useWebApi: true,
3486
3923
  regions: config.regions,
3487
3924
  memory: config.memory,
3488
3925
  maxDuration: config.maxDuration,
3489
3926
  framework: {
3490
- slug: "react-router",
3927
+ slug: REACT_ROUTER_FRAMEWORK_SETTINGS.slug,
3491
3928
  version: frameworkVersion
3492
3929
  }
3493
3930
  });
@@ -3506,7 +3943,7 @@ async function createRenderNodeFunction(nodeVersion, entrypointDir, rootDir, ser
3506
3943
  await import_fs2.promises.writeFile(
3507
3944
  handlerPath,
3508
3945
  nodeServerSrc.replace(
3509
- "@remix-run/dev/server-build",
3946
+ REMIX_FRAMEWORK_SETTINGS.sourceSearchValue,
3510
3947
  `./${baseServerBuildPath}.js`
3511
3948
  )
3512
3949
  );
@@ -3520,18 +3957,15 @@ async function createRenderNodeFunction(nodeVersion, entrypointDir, rootDir, ser
3520
3957
  files[file] = await import_build_utils3.FileFsRef.fromFsPath({ fsPath: (0, import_path2.join)(rootDir, file) });
3521
3958
  }
3522
3959
  const fn = new import_build_utils3.NodejsLambda({
3960
+ ...COMMON_NODE_FUNCTION_OPTIONS,
3523
3961
  files,
3524
3962
  handler,
3525
3963
  runtime: nodeVersion.runtime,
3526
- shouldAddHelpers: false,
3527
- shouldAddSourcemapSupport: false,
3528
- operationType: "SSR",
3529
- supportsResponseStreaming: true,
3530
3964
  regions: config.regions,
3531
3965
  memory: config.memory,
3532
3966
  maxDuration: config.maxDuration,
3533
3967
  framework: {
3534
- slug: "remix",
3968
+ slug: REMIX_FRAMEWORK_SETTINGS.slug,
3535
3969
  version: frameworkVersion
3536
3970
  }
3537
3971
  });
@@ -3549,55 +3983,28 @@ async function createRenderEdgeFunction(entrypointDir, rootDir, serverBuildPath,
3549
3983
  await import_fs2.promises.writeFile(
3550
3984
  handlerPath,
3551
3985
  edgeServerSrc.replace(
3552
- "@remix-run/dev/server-build",
3986
+ REMIX_FRAMEWORK_SETTINGS.sourceSearchValue,
3553
3987
  `./${baseServerBuildPath}.js`
3554
3988
  )
3555
3989
  );
3556
3990
  }
3557
- let remixRunVercelPkgJson;
3558
3991
  const trace = await (0, import_nft.nodeFileTrace)([handlerPath], {
3559
3992
  base: rootDir,
3560
3993
  processCwd: entrypointDir,
3561
- conditions: ["edge-light", "browser", "module", "import", "require"],
3562
- async readFile(fsPath) {
3563
- let source;
3564
- try {
3565
- source = await import_fs2.promises.readFile(fsPath);
3566
- } catch (err) {
3567
- if (err.code === "ENOENT" || err.code === "EISDIR") {
3568
- return null;
3569
- }
3570
- throw err;
3571
- }
3572
- if ((0, import_path2.basename)(fsPath) === "package.json") {
3573
- const pkgJson = JSON.parse(source.toString());
3574
- for (const prop of ["browser", "module"]) {
3575
- const val = pkgJson[prop];
3576
- if (typeof val === "string") {
3577
- pkgJson.main = val;
3578
- source = JSON.stringify(pkgJson);
3579
- break;
3580
- }
3581
- }
3582
- }
3583
- return source;
3584
- }
3994
+ conditions: EDGE_TRACE_CONDITIONS,
3995
+ readFile: edgeReadFile
3585
3996
  });
3586
3997
  logNftWarnings(trace.warnings, "@remix-run/server-runtime");
3587
3998
  for (const file of trace.fileList) {
3588
- if (remixRunVercelPkgJson && file.endsWith(`@remix-run${import_path2.sep}vercel${import_path2.sep}package.json`)) {
3589
- files[file] = new import_build_utils3.FileBlob({ data: remixRunVercelPkgJson });
3590
- } else {
3591
- files[file] = await import_build_utils3.FileFsRef.fromFsPath({ fsPath: (0, import_path2.join)(rootDir, file) });
3592
- }
3999
+ files[file] = await import_build_utils3.FileFsRef.fromFsPath({ fsPath: (0, import_path2.join)(rootDir, file) });
3593
4000
  }
3594
4001
  const fn = new import_build_utils3.EdgeFunction({
4002
+ ...COMMON_EDGE_FUNCTION_OPTIONS,
3595
4003
  files,
3596
- deploymentTarget: "v8-worker",
3597
4004
  entrypoint: handler,
3598
4005
  regions: config.regions,
3599
4006
  framework: {
3600
- slug: "remix",
4007
+ slug: REMIX_FRAMEWORK_SETTINGS.slug,
3601
4008
  version: frameworkVersion
3602
4009
  }
3603
4010
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/remix-builder",
3
- "version": "5.1.0",
3
+ "version": "5.1.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "homepage": "https://vercel.com/docs",
@@ -24,10 +24,11 @@
24
24
  "@types/jest": "27.5.1",
25
25
  "@types/node": "14.18.33",
26
26
  "@types/semver": "7.3.13",
27
- "@vercel/build-utils": "9.1.0",
27
+ "@vercel/build-utils": "9.1.1",
28
28
  "glob": "10.3.16",
29
29
  "jest-junit": "16.0.0",
30
30
  "path-to-regexp": "6.2.1",
31
+ "path-to-regexp-updated": "npm:path-to-regexp@6.3.0",
31
32
  "semver": "7.5.2",
32
33
  "vitest": "2.0.1"
33
34
  },