@netlify/zip-it-and-ship-it 9.23.1 → 9.24.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/dist/runtimes/node/in_source_config/index.d.ts +4 -1
- package/dist/runtimes/node/in_source_config/properties/schedule.js +2 -1
- package/dist/runtimes/node/parser/bindings.d.ts +2 -2
- package/dist/runtimes/node/parser/bindings.js +4 -1
- package/dist/runtimes/node/parser/exports.js +19 -0
- package/package.json +3 -3
|
@@ -42,5 +42,8 @@ export type ISCExportWithObject = {
|
|
|
42
42
|
export type ISCExportOther = {
|
|
43
43
|
type: 'other';
|
|
44
44
|
};
|
|
45
|
-
export type
|
|
45
|
+
export type ISCDefaultExport = {
|
|
46
|
+
type: 'default';
|
|
47
|
+
};
|
|
48
|
+
export type ISCExport = ISCExportWithCallExpression | ISCExportWithObject | ISCExportOther | ISCDefaultExport;
|
|
46
49
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import babelTypes from '@babel/types';
|
|
1
2
|
export const parse = ({ args }, getAllBindings) => {
|
|
2
3
|
let [expression] = args;
|
|
3
4
|
if (expression.type === 'Identifier') {
|
|
4
5
|
const binding = getAllBindings().get(expression.name);
|
|
5
|
-
if (binding) {
|
|
6
|
+
if (binding && babelTypes.isExpression(binding)) {
|
|
6
7
|
expression = binding;
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Expression, Statement } from '@babel/types';
|
|
2
|
-
type Bindings = Map<string, Expression>;
|
|
1
|
+
import type { Declaration, Expression, Statement } from '@babel/types';
|
|
2
|
+
type Bindings = Map<string, Expression | Declaration>;
|
|
3
3
|
export type BindingMethod = () => Bindings;
|
|
4
4
|
export declare const createBindingsMethod: (nodes: Statement[]) => BindingMethod;
|
|
5
5
|
export {};
|
|
@@ -6,7 +6,10 @@ const getBindingFromVariableDeclaration = function (node, bindings) {
|
|
|
6
6
|
});
|
|
7
7
|
};
|
|
8
8
|
const getBindingsFromNode = function (node, bindings) {
|
|
9
|
-
if (node.type === '
|
|
9
|
+
if (node.type === 'FunctionDeclaration' && node.id?.name) {
|
|
10
|
+
bindings.set(node.id.name, node);
|
|
11
|
+
}
|
|
12
|
+
else if (node.type === 'VariableDeclaration') {
|
|
10
13
|
// A variable was created, so create it and store the potential value
|
|
11
14
|
getBindingFromVariableDeclaration(node, bindings);
|
|
12
15
|
}
|
|
@@ -20,6 +20,10 @@ export const traverseNodes = (nodes, getAllBindings) => {
|
|
|
20
20
|
}
|
|
21
21
|
const esmHandlerExports = getNamedESMExport(node, 'handler', getAllBindings);
|
|
22
22
|
if (esmHandlerExports.length !== 0) {
|
|
23
|
+
if (esmHandlerExports.some(({ type }) => type === 'default')) {
|
|
24
|
+
hasDefaultExport = true;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
23
27
|
handlerExports.push(...esmHandlerExports);
|
|
24
28
|
return;
|
|
25
29
|
}
|
|
@@ -85,6 +89,14 @@ const getNamedESMExport = (node, name, getAllBindings) => {
|
|
|
85
89
|
const exports = getExportsFromExpression(handlerDeclaration?.init);
|
|
86
90
|
return exports;
|
|
87
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Check if the node is an `ExportSpecifier` that has a identifier with a default export:
|
|
94
|
+
* - `export { x as default }`
|
|
95
|
+
*/
|
|
96
|
+
const isDefaultExport = (node) => {
|
|
97
|
+
const { type, exported } = node;
|
|
98
|
+
return type === 'ExportSpecifier' && exported.type === 'Identifier' && exported.name === 'default';
|
|
99
|
+
};
|
|
88
100
|
/**
|
|
89
101
|
* Check if the node is an `ExportSpecifier` that has a named export with
|
|
90
102
|
* the given name, either as:
|
|
@@ -167,6 +179,13 @@ const parsePrimitive = (exp) => {
|
|
|
167
179
|
* `let handler; handler = () => {}; export { handler }`
|
|
168
180
|
*/
|
|
169
181
|
const getExportsFromBindings = (specifiers, name, getAllBindings) => {
|
|
182
|
+
const defaultExport = specifiers.find((node) => isDefaultExport(node));
|
|
183
|
+
if (defaultExport && defaultExport.type === 'ExportSpecifier') {
|
|
184
|
+
const binding = getAllBindings().get(defaultExport.local.name);
|
|
185
|
+
if (binding?.type === 'ArrowFunctionExpression' || binding?.type === 'FunctionDeclaration') {
|
|
186
|
+
return [{ type: 'default' }];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
170
189
|
const specifier = specifiers.find((node) => isNamedExport(node, name));
|
|
171
190
|
if (!specifier || specifier.type !== 'ExportSpecifier') {
|
|
172
191
|
return [];
|
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.24.1",
|
|
4
4
|
"description": "Zip it and ship it",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@babel/parser": "^7.22.5",
|
|
58
58
|
"@netlify/binary-info": "^1.0.0",
|
|
59
|
-
"@netlify/serverless-functions-api": "^1.
|
|
59
|
+
"@netlify/serverless-functions-api": "^1.9.0",
|
|
60
60
|
"@vercel/nft": "^0.23.0",
|
|
61
61
|
"archiver": "^6.0.0",
|
|
62
62
|
"common-path-prefix": "^3.0.0",
|
|
63
63
|
"cp-file": "^10.0.0",
|
|
64
64
|
"es-module-lexer": "^1.0.0",
|
|
65
|
-
"esbuild": "0.19.
|
|
65
|
+
"esbuild": "0.19.4",
|
|
66
66
|
"execa": "^6.0.0",
|
|
67
67
|
"filter-obj": "^5.0.0",
|
|
68
68
|
"find-up": "^6.0.0",
|