@vercel/remix-builder 5.0.2 → 5.1.1
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/defaults/server-node.mjs +5 -1
- package/defaults/server-react-router.mjs +3 -0
- package/dist/index.js +623 -45
- package/package.json +3 -2
package/defaults/server-node.mjs
CHANGED
|
@@ -8,9 +8,13 @@ import * as build from '@remix-run/dev/server-build';
|
|
|
8
8
|
|
|
9
9
|
installGlobals({
|
|
10
10
|
nativeFetch:
|
|
11
|
+
// Explicit opt-in to native fetch via runtime env var
|
|
11
12
|
(parseInt(process.versions.node, 10) >= 20 &&
|
|
12
13
|
process.env.VERCEL_REMIX_NATIVE_FETCH === '1') ||
|
|
13
|
-
|
|
14
|
+
// `unstable_singleFetch` future flag added in Remix v2.9.0
|
|
15
|
+
build.future.unstable_singleFetch ||
|
|
16
|
+
// `v3_singleFetch` future flag stabilized in Remix v2.13.0
|
|
17
|
+
build.future.v3_singleFetch,
|
|
14
18
|
});
|
|
15
19
|
|
|
16
20
|
const handleRequest = createRemixRequestHandler(
|
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 = (
|
|
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) {
|
|
@@ -3066,17 +3487,15 @@ function hasScript(scriptName, pkg) {
|
|
|
3066
3487
|
const scripts = pkg?.scripts || {};
|
|
3067
3488
|
return typeof scripts[scriptName] === "string";
|
|
3068
3489
|
}
|
|
3069
|
-
async function
|
|
3070
|
-
const resolvedPath = require_.resolve(
|
|
3490
|
+
async function getPackageVersion(name, dir, base) {
|
|
3491
|
+
const resolvedPath = require_.resolve(name, { paths: [dir] });
|
|
3071
3492
|
const pkgPath = await (0, import_build_utils2.walkParentDirs)({
|
|
3072
3493
|
base,
|
|
3073
3494
|
start: (0, import_path.dirname)(resolvedPath),
|
|
3074
3495
|
filename: "package.json"
|
|
3075
3496
|
});
|
|
3076
3497
|
if (!pkgPath) {
|
|
3077
|
-
throw new Error(
|
|
3078
|
-
`Failed to find \`package.json\` file for "@remix-run/dev"`
|
|
3079
|
-
);
|
|
3498
|
+
throw new Error(`Failed to find \`package.json\` file for "${name}"`);
|
|
3080
3499
|
}
|
|
3081
3500
|
const { version: version2 } = JSON.parse(
|
|
3082
3501
|
await import_fs.promises.readFile(pkgPath, "utf8")
|
|
@@ -3137,6 +3556,80 @@ var nodeServerSrcPromise = import_fs2.promises.readFile(
|
|
|
3137
3556
|
(0, import_path2.join)(DEFAULTS_PATH, "server-node.mjs"),
|
|
3138
3557
|
"utf-8"
|
|
3139
3558
|
);
|
|
3559
|
+
var reactRouterServerSrcPromise = import_fs2.promises.readFile(
|
|
3560
|
+
(0, import_path2.join)(DEFAULTS_PATH, "server-react-router.mjs"),
|
|
3561
|
+
"utf-8"
|
|
3562
|
+
);
|
|
3563
|
+
var REMIX_FRAMEWORK_SETTINGS = {
|
|
3564
|
+
primaryPackageName: "@remix-run/dev",
|
|
3565
|
+
buildCommand: "remix build",
|
|
3566
|
+
buildResultFilePath: ".vercel/remix-build-result.json",
|
|
3567
|
+
createRenderFunction({
|
|
3568
|
+
nodeVersion,
|
|
3569
|
+
entrypointDir,
|
|
3570
|
+
rootDir,
|
|
3571
|
+
serverBuildPath,
|
|
3572
|
+
serverEntryPoint,
|
|
3573
|
+
frameworkVersion,
|
|
3574
|
+
config
|
|
3575
|
+
}) {
|
|
3576
|
+
if (config.runtime === "edge") {
|
|
3577
|
+
return createRenderEdgeFunction(
|
|
3578
|
+
entrypointDir,
|
|
3579
|
+
rootDir,
|
|
3580
|
+
serverBuildPath,
|
|
3581
|
+
serverEntryPoint,
|
|
3582
|
+
frameworkVersion,
|
|
3583
|
+
config
|
|
3584
|
+
);
|
|
3585
|
+
}
|
|
3586
|
+
return createRenderNodeFunction(
|
|
3587
|
+
nodeVersion,
|
|
3588
|
+
entrypointDir,
|
|
3589
|
+
rootDir,
|
|
3590
|
+
serverBuildPath,
|
|
3591
|
+
serverEntryPoint,
|
|
3592
|
+
frameworkVersion,
|
|
3593
|
+
config
|
|
3594
|
+
);
|
|
3595
|
+
}
|
|
3596
|
+
};
|
|
3597
|
+
var REACT_ROUTER_FRAMEWORK_SETTINGS = {
|
|
3598
|
+
primaryPackageName: "react-router",
|
|
3599
|
+
buildCommand: "react-router build",
|
|
3600
|
+
buildResultFilePath: ".vercel/react-router-build-result.json",
|
|
3601
|
+
createRenderFunction({
|
|
3602
|
+
nodeVersion,
|
|
3603
|
+
entrypointDir,
|
|
3604
|
+
rootDir,
|
|
3605
|
+
serverBuildPath,
|
|
3606
|
+
serverEntryPoint,
|
|
3607
|
+
frameworkVersion,
|
|
3608
|
+
config
|
|
3609
|
+
}) {
|
|
3610
|
+
return createRenderReactRouterFunction(
|
|
3611
|
+
nodeVersion,
|
|
3612
|
+
entrypointDir,
|
|
3613
|
+
rootDir,
|
|
3614
|
+
serverBuildPath,
|
|
3615
|
+
serverEntryPoint,
|
|
3616
|
+
frameworkVersion,
|
|
3617
|
+
config
|
|
3618
|
+
);
|
|
3619
|
+
}
|
|
3620
|
+
};
|
|
3621
|
+
function determineFrameworkSettings(workPath) {
|
|
3622
|
+
const isReactRouter = findConfig(workPath, "react-router.config", [
|
|
3623
|
+
".js",
|
|
3624
|
+
".ts",
|
|
3625
|
+
".mjs",
|
|
3626
|
+
".mts"
|
|
3627
|
+
]);
|
|
3628
|
+
if (isReactRouter) {
|
|
3629
|
+
return REACT_ROUTER_FRAMEWORK_SETTINGS;
|
|
3630
|
+
}
|
|
3631
|
+
return REMIX_FRAMEWORK_SETTINGS;
|
|
3632
|
+
}
|
|
3140
3633
|
var build = async ({
|
|
3141
3634
|
entrypoint,
|
|
3142
3635
|
workPath,
|
|
@@ -3147,6 +3640,7 @@ var build = async ({
|
|
|
3147
3640
|
const { installCommand, buildCommand } = config;
|
|
3148
3641
|
const mountpoint = (0, import_path2.dirname)(entrypoint);
|
|
3149
3642
|
const entrypointFsDirname = (0, import_path2.join)(workPath, mountpoint);
|
|
3643
|
+
const frameworkSettings = determineFrameworkSettings(workPath);
|
|
3150
3644
|
const nodeVersion = await (0, import_build_utils3.getNodeVersion)(
|
|
3151
3645
|
entrypointFsDirname,
|
|
3152
3646
|
void 0,
|
|
@@ -3185,7 +3679,11 @@ var build = async ({
|
|
|
3185
3679
|
} else {
|
|
3186
3680
|
await (0, import_build_utils3.runNpmInstall)(entrypointFsDirname, [], spawnOpts, meta, nodeVersion);
|
|
3187
3681
|
}
|
|
3188
|
-
const
|
|
3682
|
+
const frameworkVersion = await getPackageVersion(
|
|
3683
|
+
frameworkSettings.primaryPackageName,
|
|
3684
|
+
entrypointFsDirname,
|
|
3685
|
+
repoRootPath
|
|
3686
|
+
);
|
|
3189
3687
|
if (buildCommand) {
|
|
3190
3688
|
(0, import_build_utils3.debug)(`Executing build command "${buildCommand}"`);
|
|
3191
3689
|
await (0, import_build_utils3.execCommand)(buildCommand, {
|
|
@@ -3204,28 +3702,28 @@ var build = async ({
|
|
|
3204
3702
|
(0, import_build_utils3.debug)(`Executing "build" script`);
|
|
3205
3703
|
await (0, import_build_utils3.runPackageJsonScript)(entrypointFsDirname, "build", spawnOpts);
|
|
3206
3704
|
} else {
|
|
3207
|
-
await (0, import_build_utils3.execCommand)(
|
|
3705
|
+
await (0, import_build_utils3.execCommand)(frameworkSettings.buildCommand, {
|
|
3208
3706
|
...spawnOpts,
|
|
3209
3707
|
cwd: entrypointFsDirname
|
|
3210
3708
|
});
|
|
3211
3709
|
}
|
|
3212
3710
|
}
|
|
3213
|
-
const
|
|
3711
|
+
const buildResultJsonPath = (0, import_path2.join)(
|
|
3214
3712
|
entrypointFsDirname,
|
|
3215
|
-
|
|
3713
|
+
frameworkSettings.buildResultFilePath
|
|
3216
3714
|
);
|
|
3217
|
-
let
|
|
3715
|
+
let buildResult;
|
|
3218
3716
|
try {
|
|
3219
|
-
const
|
|
3220
|
-
|
|
3717
|
+
const buildResultContents = (0, import_fs2.readFileSync)(buildResultJsonPath, "utf8");
|
|
3718
|
+
buildResult = JSON.parse(buildResultContents);
|
|
3221
3719
|
} catch (err) {
|
|
3222
3720
|
if (!(0, import_error_utils.isErrnoException)(err) || err.code !== "ENOENT") {
|
|
3223
3721
|
throw err;
|
|
3224
3722
|
}
|
|
3225
|
-
const
|
|
3226
|
-
if ((0, import_fs2.statSync)(
|
|
3723
|
+
const buildDirectory2 = (0, import_path2.join)(entrypointFsDirname, "build");
|
|
3724
|
+
if ((0, import_fs2.statSync)(buildDirectory2).isDirectory()) {
|
|
3227
3725
|
console.warn("WARN: The `vercelPreset()` Preset was not detected.");
|
|
3228
|
-
|
|
3726
|
+
buildResult = {
|
|
3229
3727
|
buildManifest: {
|
|
3230
3728
|
routes: {
|
|
3231
3729
|
root: {
|
|
@@ -3244,15 +3742,15 @@ var build = async ({
|
|
|
3244
3742
|
}
|
|
3245
3743
|
},
|
|
3246
3744
|
remixConfig: {
|
|
3247
|
-
buildDirectory
|
|
3745
|
+
buildDirectory: buildDirectory2
|
|
3248
3746
|
}
|
|
3249
3747
|
};
|
|
3250
3748
|
const serverPath = "build/server/index.js";
|
|
3251
3749
|
if ((0, import_fs2.existsSync)((0, import_path2.join)(entrypointFsDirname, serverPath))) {
|
|
3252
|
-
|
|
3750
|
+
buildResult.buildManifest.routeIdToServerBundleId = {
|
|
3253
3751
|
"routes/_index": ""
|
|
3254
3752
|
};
|
|
3255
|
-
|
|
3753
|
+
buildResult.buildManifest.serverBundles = {
|
|
3256
3754
|
"": {
|
|
3257
3755
|
id: "",
|
|
3258
3756
|
file: serverPath,
|
|
@@ -3262,36 +3760,27 @@ var build = async ({
|
|
|
3262
3760
|
}
|
|
3263
3761
|
}
|
|
3264
3762
|
}
|
|
3265
|
-
if (!
|
|
3763
|
+
if (!buildResult) {
|
|
3266
3764
|
throw new Error(
|
|
3267
3765
|
"Could not determine build output directory. Please configure the `vercelPreset()` Preset from the `@vercel/remix` npm package"
|
|
3268
3766
|
);
|
|
3269
3767
|
}
|
|
3270
|
-
const { buildManifest,
|
|
3271
|
-
const
|
|
3768
|
+
const { buildManifest, viteConfig } = buildResult;
|
|
3769
|
+
const buildDirectory = "remixConfig" in buildResult ? buildResult.remixConfig.buildDirectory : buildResult.reactRouterConfig.buildDirectory;
|
|
3770
|
+
const staticDir = (0, import_path2.join)(buildDirectory, "client");
|
|
3272
3771
|
const serverBundles = Object.values(buildManifest.serverBundles ?? {});
|
|
3273
3772
|
const [staticFiles, ...functions] = await Promise.all([
|
|
3274
3773
|
(0, import_build_utils3.glob)("**", staticDir),
|
|
3275
3774
|
...serverBundles.map((bundle) => {
|
|
3276
|
-
|
|
3277
|
-
return createRenderEdgeFunction(
|
|
3278
|
-
entrypointFsDirname,
|
|
3279
|
-
repoRootPath,
|
|
3280
|
-
(0, import_path2.join)(entrypointFsDirname, bundle.file),
|
|
3281
|
-
void 0,
|
|
3282
|
-
remixVersion,
|
|
3283
|
-
bundle.config
|
|
3284
|
-
);
|
|
3285
|
-
}
|
|
3286
|
-
return createRenderNodeFunction(
|
|
3775
|
+
return frameworkSettings.createRenderFunction({
|
|
3287
3776
|
nodeVersion,
|
|
3288
|
-
entrypointFsDirname,
|
|
3289
|
-
repoRootPath,
|
|
3290
|
-
(0, import_path2.join)(entrypointFsDirname, bundle.file),
|
|
3291
|
-
void 0,
|
|
3292
|
-
|
|
3293
|
-
bundle.config
|
|
3294
|
-
);
|
|
3777
|
+
entrypointDir: entrypointFsDirname,
|
|
3778
|
+
rootDir: repoRootPath,
|
|
3779
|
+
serverBuildPath: (0, import_path2.join)(entrypointFsDirname, bundle.file),
|
|
3780
|
+
serverEntryPoint: void 0,
|
|
3781
|
+
frameworkVersion,
|
|
3782
|
+
config: bundle.config
|
|
3783
|
+
});
|
|
3295
3784
|
})
|
|
3296
3785
|
]);
|
|
3297
3786
|
const functionsMap = /* @__PURE__ */ new Map();
|
|
@@ -3335,9 +3824,98 @@ var build = async ({
|
|
|
3335
3824
|
src: "/(.*)",
|
|
3336
3825
|
dest: "/"
|
|
3337
3826
|
});
|
|
3338
|
-
return { routes, output, framework: { version:
|
|
3827
|
+
return { routes, output, framework: { version: frameworkVersion } };
|
|
3339
3828
|
};
|
|
3340
|
-
async function
|
|
3829
|
+
async function createRenderReactRouterFunction(nodeVersion, entrypointDir, rootDir, serverBuildPath, serverEntryPoint, frameworkVersion, config) {
|
|
3830
|
+
const isEdgeFunction = config.runtime === "edge";
|
|
3831
|
+
const files = {};
|
|
3832
|
+
let handler = (0, import_path2.relative)(rootDir, serverBuildPath);
|
|
3833
|
+
let handlerPath = (0, import_path2.join)(rootDir, handler);
|
|
3834
|
+
if (!serverEntryPoint) {
|
|
3835
|
+
const baseServerBuildPath = (0, import_path2.basename)(serverBuildPath, ".js");
|
|
3836
|
+
handler = (0, import_path2.join)((0, import_path2.dirname)(handler), `server-${baseServerBuildPath}.mjs`);
|
|
3837
|
+
handlerPath = (0, import_path2.join)(rootDir, handler);
|
|
3838
|
+
const reactRouterServerSrc = await reactRouterServerSrcPromise;
|
|
3839
|
+
await import_fs2.promises.writeFile(
|
|
3840
|
+
handlerPath,
|
|
3841
|
+
reactRouterServerSrc.replace(
|
|
3842
|
+
"ENTRYPOINT_PLACEHOLDER",
|
|
3843
|
+
`./${baseServerBuildPath}.js`
|
|
3844
|
+
)
|
|
3845
|
+
);
|
|
3846
|
+
}
|
|
3847
|
+
let conditions;
|
|
3848
|
+
let readFile;
|
|
3849
|
+
if (isEdgeFunction) {
|
|
3850
|
+
conditions = ["edge-light", "browser", "module", "import", "require"];
|
|
3851
|
+
readFile = async (fsPath) => {
|
|
3852
|
+
let source;
|
|
3853
|
+
try {
|
|
3854
|
+
source = await import_fs2.promises.readFile(fsPath);
|
|
3855
|
+
} catch (err) {
|
|
3856
|
+
if (err.code === "ENOENT" || err.code === "EISDIR") {
|
|
3857
|
+
return null;
|
|
3858
|
+
}
|
|
3859
|
+
throw err;
|
|
3860
|
+
}
|
|
3861
|
+
if ((0, import_path2.basename)(fsPath) === "package.json") {
|
|
3862
|
+
const pkgJson = JSON.parse(source.toString());
|
|
3863
|
+
for (const prop of ["browser", "module"]) {
|
|
3864
|
+
const val = pkgJson[prop];
|
|
3865
|
+
if (typeof val === "string") {
|
|
3866
|
+
pkgJson.main = val;
|
|
3867
|
+
source = JSON.stringify(pkgJson);
|
|
3868
|
+
break;
|
|
3869
|
+
}
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3872
|
+
return source;
|
|
3873
|
+
};
|
|
3874
|
+
}
|
|
3875
|
+
const trace = await (0, import_nft.nodeFileTrace)([handlerPath], {
|
|
3876
|
+
base: rootDir,
|
|
3877
|
+
processCwd: entrypointDir,
|
|
3878
|
+
conditions,
|
|
3879
|
+
readFile
|
|
3880
|
+
});
|
|
3881
|
+
logNftWarnings(trace.warnings, "react-router");
|
|
3882
|
+
for (const file of trace.fileList) {
|
|
3883
|
+
files[file] = await import_build_utils3.FileFsRef.fromFsPath({ fsPath: (0, import_path2.join)(rootDir, file) });
|
|
3884
|
+
}
|
|
3885
|
+
let fn;
|
|
3886
|
+
if (isEdgeFunction) {
|
|
3887
|
+
fn = new import_build_utils3.EdgeFunction({
|
|
3888
|
+
files,
|
|
3889
|
+
deploymentTarget: "v8-worker",
|
|
3890
|
+
entrypoint: handler,
|
|
3891
|
+
regions: config.regions,
|
|
3892
|
+
framework: {
|
|
3893
|
+
slug: "react-router",
|
|
3894
|
+
version: frameworkVersion
|
|
3895
|
+
}
|
|
3896
|
+
});
|
|
3897
|
+
} else {
|
|
3898
|
+
fn = new import_build_utils3.NodejsLambda({
|
|
3899
|
+
files,
|
|
3900
|
+
handler,
|
|
3901
|
+
runtime: nodeVersion.runtime,
|
|
3902
|
+
shouldAddHelpers: false,
|
|
3903
|
+
shouldAddSourcemapSupport: false,
|
|
3904
|
+
operationType: "SSR",
|
|
3905
|
+
supportsResponseStreaming: true,
|
|
3906
|
+
useWebApi: true,
|
|
3907
|
+
regions: config.regions,
|
|
3908
|
+
memory: config.memory,
|
|
3909
|
+
maxDuration: config.maxDuration,
|
|
3910
|
+
framework: {
|
|
3911
|
+
slug: "react-router",
|
|
3912
|
+
version: frameworkVersion
|
|
3913
|
+
}
|
|
3914
|
+
});
|
|
3915
|
+
}
|
|
3916
|
+
return fn;
|
|
3917
|
+
}
|
|
3918
|
+
async function createRenderNodeFunction(nodeVersion, entrypointDir, rootDir, serverBuildPath, serverEntryPoint, frameworkVersion, config) {
|
|
3341
3919
|
const files = {};
|
|
3342
3920
|
let handler = (0, import_path2.relative)(rootDir, serverBuildPath);
|
|
3343
3921
|
let handlerPath = (0, import_path2.join)(rootDir, handler);
|
|
@@ -3375,12 +3953,12 @@ async function createRenderNodeFunction(nodeVersion, entrypointDir, rootDir, ser
|
|
|
3375
3953
|
maxDuration: config.maxDuration,
|
|
3376
3954
|
framework: {
|
|
3377
3955
|
slug: "remix",
|
|
3378
|
-
version:
|
|
3956
|
+
version: frameworkVersion
|
|
3379
3957
|
}
|
|
3380
3958
|
});
|
|
3381
3959
|
return fn;
|
|
3382
3960
|
}
|
|
3383
|
-
async function createRenderEdgeFunction(entrypointDir, rootDir, serverBuildPath, serverEntryPoint,
|
|
3961
|
+
async function createRenderEdgeFunction(entrypointDir, rootDir, serverBuildPath, serverEntryPoint, frameworkVersion, config) {
|
|
3384
3962
|
const files = {};
|
|
3385
3963
|
let handler = (0, import_path2.relative)(rootDir, serverBuildPath);
|
|
3386
3964
|
let handlerPath = (0, import_path2.join)(rootDir, handler);
|
|
@@ -3441,7 +4019,7 @@ async function createRenderEdgeFunction(entrypointDir, rootDir, serverBuildPath,
|
|
|
3441
4019
|
regions: config.regions,
|
|
3442
4020
|
framework: {
|
|
3443
4021
|
slug: "remix",
|
|
3444
|
-
version:
|
|
4022
|
+
version: frameworkVersion
|
|
3445
4023
|
}
|
|
3446
4024
|
});
|
|
3447
4025
|
return fn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/remix-builder",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
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.0
|
|
27
|
+
"@vercel/build-utils": "9.1.0",
|
|
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
|
},
|