@netlify/zip-it-and-ship-it 9.25.7 → 9.26.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.
|
@@ -75,7 +75,12 @@ export const parseSource = (source, { functionName, logger }) => {
|
|
|
75
75
|
if (configExport.method !== undefined) {
|
|
76
76
|
result.methods = normalizeMethods(configExport.method, functionName);
|
|
77
77
|
}
|
|
78
|
-
result.routes = getRoutes(
|
|
78
|
+
result.routes = getRoutes({
|
|
79
|
+
functionName,
|
|
80
|
+
methods: result.methods ?? [],
|
|
81
|
+
path: configExport.path,
|
|
82
|
+
preferStatic: configExport.preferStatic === true,
|
|
83
|
+
});
|
|
79
84
|
return result;
|
|
80
85
|
}
|
|
81
86
|
const iscExports = handlerExports
|
|
@@ -9,11 +9,10 @@ const getEntryFileContents = (mainPath, moduleFormat, featureFlags, runtimeAPIVe
|
|
|
9
9
|
const importPath = `.${mainPath.startsWith('/') ? mainPath : `/${mainPath}`}`;
|
|
10
10
|
if (runtimeAPIVersion === 2) {
|
|
11
11
|
return [
|
|
12
|
-
`import * as func from '${importPath}'`,
|
|
13
12
|
`import * as bootstrap from './${BOOTSTRAP_FILE_NAME}'`,
|
|
13
|
+
`import * as func from '${importPath}'`,
|
|
14
14
|
// See https://esbuild.github.io/content-types/#default-interop.
|
|
15
15
|
'const funcModule = typeof func.default === "function" ? func : func.default',
|
|
16
|
-
`global.Netlify = bootstrap.getNetlifyGlobal()`,
|
|
17
16
|
`export const handler = bootstrap.getLambdaHandler(funcModule)`,
|
|
18
17
|
].join(';');
|
|
19
18
|
}
|
package/dist/utils/routes.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
export type Route = {
|
|
2
2
|
pattern: string;
|
|
3
3
|
methods: string[];
|
|
4
|
+
prefer_static?: boolean;
|
|
4
5
|
} & ({
|
|
5
6
|
literal: string;
|
|
6
7
|
} | {
|
|
7
8
|
expression: string;
|
|
8
9
|
});
|
|
10
|
+
interface GetRoutesOptions {
|
|
11
|
+
functionName: string;
|
|
12
|
+
methods: string[];
|
|
13
|
+
path: unknown;
|
|
14
|
+
preferStatic?: boolean;
|
|
15
|
+
}
|
|
9
16
|
/**
|
|
10
17
|
* Takes a `path` declaration, normalizes it into an array, and processes the
|
|
11
18
|
* individual elements to obtain an array of `Route` expressions.
|
|
12
19
|
*/
|
|
13
|
-
export declare const getRoutes: (
|
|
20
|
+
export declare const getRoutes: ({ functionName, methods, path: pathOrPaths, preferStatic, }: GetRoutesOptions) => Route[];
|
|
21
|
+
export {};
|
package/dist/utils/routes.js
CHANGED
|
@@ -14,7 +14,7 @@ const isPathLiteral = (path) => {
|
|
|
14
14
|
* Takes an element from a `path` declaration and returns a Route element that
|
|
15
15
|
* represents it.
|
|
16
16
|
*/
|
|
17
|
-
const getRoute = (
|
|
17
|
+
const getRoute = ({ functionName, methods, path, preferStatic }) => {
|
|
18
18
|
if (typeof path !== 'string') {
|
|
19
19
|
throw new FunctionBundlingUserError(`'path' property must be a string, found '${JSON.stringify(path)}'`, {
|
|
20
20
|
functionName,
|
|
@@ -28,7 +28,7 @@ const getRoute = (path, functionName, methods) => {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
if (isPathLiteral(path)) {
|
|
31
|
-
return { pattern: path, literal: path, methods };
|
|
31
|
+
return { pattern: path, literal: path, methods, prefer_static: preferStatic || undefined };
|
|
32
32
|
}
|
|
33
33
|
try {
|
|
34
34
|
const pattern = new ExtendedURLPattern({ pathname: path });
|
|
@@ -39,7 +39,7 @@ const getRoute = (path, functionName, methods) => {
|
|
|
39
39
|
// trailing slash, so that a declaration of `path: "/foo"` matches requests
|
|
40
40
|
// for both `/foo` and `/foo/`.
|
|
41
41
|
const normalizedRegex = `^${regex}\\/?$`;
|
|
42
|
-
return { pattern: path, expression: normalizedRegex, methods };
|
|
42
|
+
return { pattern: path, expression: normalizedRegex, methods, prefer_static: preferStatic || undefined };
|
|
43
43
|
}
|
|
44
44
|
catch {
|
|
45
45
|
throw new FunctionBundlingUserError(`'${path}' is not a valid path according to the URLPattern specification`, {
|
|
@@ -52,12 +52,19 @@ const getRoute = (path, functionName, methods) => {
|
|
|
52
52
|
* Takes a `path` declaration, normalizes it into an array, and processes the
|
|
53
53
|
* individual elements to obtain an array of `Route` expressions.
|
|
54
54
|
*/
|
|
55
|
-
export const getRoutes = (
|
|
56
|
-
if (!
|
|
55
|
+
export const getRoutes = ({ functionName, methods, path: pathOrPaths, preferStatic = false, }) => {
|
|
56
|
+
if (!pathOrPaths) {
|
|
57
57
|
return [];
|
|
58
58
|
}
|
|
59
|
-
const paths = [...new Set(Array.isArray(
|
|
60
|
-
const routes = paths
|
|
59
|
+
const paths = [...new Set(Array.isArray(pathOrPaths) ? pathOrPaths : [pathOrPaths])];
|
|
60
|
+
const routes = paths
|
|
61
|
+
.map((path) => getRoute({
|
|
62
|
+
functionName,
|
|
63
|
+
methods,
|
|
64
|
+
path,
|
|
65
|
+
preferStatic,
|
|
66
|
+
}))
|
|
67
|
+
.filter(nonNullable);
|
|
61
68
|
return routes;
|
|
62
69
|
};
|
|
63
70
|
//# sourceMappingURL=routes.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/zip-it-and-ship-it",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.26.1",
|
|
4
4
|
"description": "Zip it and ship it",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@babel/parser": "^7.22.5",
|
|
58
58
|
"@babel/types": "7.23.0",
|
|
59
59
|
"@netlify/binary-info": "^1.0.0",
|
|
60
|
-
"@netlify/serverless-functions-api": "^1.
|
|
60
|
+
"@netlify/serverless-functions-api": "^1.12.0",
|
|
61
61
|
"@vercel/nft": "^0.23.0",
|
|
62
62
|
"archiver": "^6.0.0",
|
|
63
63
|
"common-path-prefix": "^3.0.0",
|