@netlify/edge-bundler 11.2.0 → 11.2.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.
package/dist/node/bridge.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ declare class DenoBridge {
|
|
|
52
52
|
}>;
|
|
53
53
|
getEnvironmentVariables(inputEnv?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
54
54
|
run(args: string[], { env: inputEnv, extendEnv, rejectOnExitCode, stderr, stdout }?: RunOptions): Promise<import("execa").ExecaReturnValue<string>>;
|
|
55
|
-
runInBackground(args: string[], ref?: ProcessRef, { env: inputEnv, extendEnv, stderr, stdout }?: RunOptions): Promise<void>;
|
|
55
|
+
runInBackground(args: string[], ref?: ProcessRef, { env: inputEnv, extendEnv, pipeOutput, stderr, stdout }?: RunOptions): Promise<void>;
|
|
56
56
|
}
|
|
57
57
|
export { DENO_VERSION_RANGE, DenoBridge };
|
|
58
58
|
export type { DenoOptions, OnAfterDownloadHook, OnBeforeDownloadHook, ProcessRef };
|
package/dist/node/bridge.js
CHANGED
|
@@ -151,11 +151,11 @@ class DenoBridge {
|
|
|
151
151
|
}
|
|
152
152
|
// Runs the Deno CLI in the background, assigning a reference of the child
|
|
153
153
|
// process to a `ps` property in the `ref` argument, if one is supplied.
|
|
154
|
-
async runInBackground(args, ref, { env: inputEnv, extendEnv = true, stderr, stdout } = {}) {
|
|
154
|
+
async runInBackground(args, ref, { env: inputEnv, extendEnv = true, pipeOutput, stderr, stdout } = {}) {
|
|
155
155
|
const { path: binaryPath } = await this.getBinaryPath();
|
|
156
156
|
const env = this.getEnvironmentVariables(inputEnv);
|
|
157
157
|
const options = { env, extendEnv };
|
|
158
|
-
const ps = DenoBridge.runWithBinary(binaryPath, args, { options, stderr, stdout });
|
|
158
|
+
const ps = DenoBridge.runWithBinary(binaryPath, args, { options, pipeOutput, stderr, stdout });
|
|
159
159
|
if (ref !== undefined) {
|
|
160
160
|
// eslint-disable-next-line no-param-reassign
|
|
161
161
|
ref.ps = ps;
|
|
@@ -17,5 +17,10 @@ type DeclarationWithPattern = BaseDeclaration & {
|
|
|
17
17
|
};
|
|
18
18
|
export type Declaration = DeclarationWithPath | DeclarationWithPattern;
|
|
19
19
|
export declare const mergeDeclarations: (tomlDeclarations: Declaration[], userFunctionsConfig: Record<string, FunctionConfig>, internalFunctionsConfig: Record<string, FunctionConfig>, deployConfigDeclarations: Declaration[], _featureFlags?: FeatureFlags) => Declaration[];
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Normalizes a regular expression, ensuring it has a leading `^` and trailing
|
|
22
|
+
* `$` characters. It also converts the regular expression from PCRE to RE2 if
|
|
23
|
+
* needed.
|
|
24
|
+
*/
|
|
25
|
+
export declare const parsePattern: (pattern: string, pcreRegexpEngine: boolean) => string;
|
|
21
26
|
export {};
|
package/dist/node/declaration.js
CHANGED
|
@@ -66,15 +66,29 @@ const createDeclarationsFromFunctionConfigs = (functionConfigs, functionsVisited
|
|
|
66
66
|
}
|
|
67
67
|
return declarations;
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Normalizes a regular expression, ensuring it has a leading `^` and trailing
|
|
71
|
+
* `$` characters. It also converts the regular expression from PCRE to RE2 if
|
|
72
|
+
* needed.
|
|
73
|
+
*/
|
|
74
|
+
export const parsePattern = (pattern, pcreRegexpEngine) => {
|
|
72
75
|
let enclosedPattern = pattern;
|
|
73
|
-
if (!pattern.startsWith('^'))
|
|
76
|
+
if (!pattern.startsWith('^')) {
|
|
74
77
|
enclosedPattern = `^${enclosedPattern}`;
|
|
75
|
-
|
|
78
|
+
}
|
|
79
|
+
if (!pattern.endsWith('$')) {
|
|
76
80
|
enclosedPattern = `${enclosedPattern}$`;
|
|
81
|
+
}
|
|
77
82
|
const regexp = new RegExp(enclosedPattern);
|
|
83
|
+
const regexpString = pcreRegexpEngine ? regexp.toString() : transformPCRERegexp(regexp);
|
|
84
|
+
// Strip leading and forward slashes.
|
|
85
|
+
return regexpString.slice(1, -1);
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Transforms a PCRE regular expression into a RE2 expression, compatible
|
|
89
|
+
* with the Go engine used in our edge nodes.
|
|
90
|
+
*/
|
|
91
|
+
const transformPCRERegexp = (regexp) => {
|
|
78
92
|
const newRegexp = regexpAST.transform(regexp, {
|
|
79
93
|
Assertion(path) {
|
|
80
94
|
// Lookaheads are not supported. If we find one, throw an error.
|
|
@@ -95,6 +109,5 @@ export const parsePattern = (pattern) => {
|
|
|
95
109
|
}
|
|
96
110
|
},
|
|
97
111
|
});
|
|
98
|
-
|
|
99
|
-
return newRegexp.toString().slice(1, -1);
|
|
112
|
+
return newRegexp.toString();
|
|
100
113
|
};
|
|
@@ -117,18 +117,18 @@ test('netlify.toml-defined excludedPath are respected', () => {
|
|
|
117
117
|
test('Does not escape front slashes in a regex pattern if they are already escaped', () => {
|
|
118
118
|
const regexPattern = '^(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/([^/.]{1,}))\\/shows(?:\\/(.*))(.json)?[\\/#\\?]?$';
|
|
119
119
|
const expected = '^(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/([^/.]{1,}))\\/shows(?:\\/(.*))(.json)?[\\/#\\?]?$';
|
|
120
|
-
|
|
121
|
-
expect(
|
|
120
|
+
expect(parsePattern(regexPattern, false)).toEqual(expected);
|
|
121
|
+
expect(parsePattern(regexPattern, true)).toEqual(expected);
|
|
122
122
|
});
|
|
123
123
|
test('Escapes front slashes in a regex pattern', () => {
|
|
124
124
|
const regexPattern = '^(?:/(_next/data/[^/]{1,}))?(?:/([^/.]{1,}))/shows(?:/(.*))(.json)?[/#\\?]?$';
|
|
125
125
|
const expected = '^(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/([^/.]{1,}))\\/shows(?:\\/(.*))(.json)?[/#\\?]?$';
|
|
126
|
-
|
|
127
|
-
expect(
|
|
126
|
+
expect(parsePattern(regexPattern, false)).toEqual(expected);
|
|
127
|
+
expect(parsePattern(regexPattern, true)).toEqual(expected);
|
|
128
128
|
});
|
|
129
129
|
test('Ensures pattern match on the whole path', () => {
|
|
130
130
|
const regexPattern = '/foo/.*/bar';
|
|
131
131
|
const expected = '^\\/foo\\/.*\\/bar$';
|
|
132
|
-
|
|
133
|
-
expect(
|
|
132
|
+
expect(parsePattern(regexPattern, false)).toEqual(expected);
|
|
133
|
+
expect(parsePattern(regexPattern, true)).toEqual(expected);
|
|
134
134
|
});
|
package/dist/node/manifest.js
CHANGED
|
@@ -137,11 +137,8 @@ const pathToRegularExpression = (path) => {
|
|
|
137
137
|
};
|
|
138
138
|
const getRegularExpression = (declaration, pcreRegexpEngine) => {
|
|
139
139
|
if ('pattern' in declaration) {
|
|
140
|
-
if (pcreRegexpEngine) {
|
|
141
|
-
return declaration.pattern;
|
|
142
|
-
}
|
|
143
140
|
try {
|
|
144
|
-
return parsePattern(declaration.pattern);
|
|
141
|
+
return parsePattern(declaration.pattern, pcreRegexpEngine);
|
|
145
142
|
}
|
|
146
143
|
catch (error) {
|
|
147
144
|
throw wrapBundleError(new Error(`Could not parse path declaration of function '${declaration.function}': ${error.message}`));
|
|
@@ -154,12 +151,9 @@ const getExcludedRegularExpressions = (declaration, pcreRegexpEngine) => {
|
|
|
154
151
|
const excludedPatterns = Array.isArray(declaration.excludedPattern)
|
|
155
152
|
? declaration.excludedPattern
|
|
156
153
|
: [declaration.excludedPattern];
|
|
157
|
-
if (pcreRegexpEngine) {
|
|
158
|
-
return excludedPatterns;
|
|
159
|
-
}
|
|
160
154
|
return excludedPatterns.map((excludedPattern) => {
|
|
161
155
|
try {
|
|
162
|
-
return parsePattern(excludedPattern);
|
|
156
|
+
return parsePattern(excludedPattern, pcreRegexpEngine);
|
|
163
157
|
}
|
|
164
158
|
catch (error) {
|
|
165
159
|
throw wrapBundleError(new Error(`Could not parse path declaration of function '${declaration.function}': ${error.message}`));
|