@netlify/zip-it-and-ship-it 9.25.1 → 9.25.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.
@@ -19,6 +19,10 @@ export const traverseNodes = (nodes, getAllBindings) => {
19
19
  inputModuleFormat = MODULE_FORMAT.ESM;
20
20
  }
21
21
  const esmHandlerExports = getNamedESMExport(node, 'handler', getAllBindings);
22
+ const esmConfigExports = getNamedESMExport(node, 'config', getAllBindings);
23
+ if (esmConfigExports.length !== 0 && esmConfigExports[0].type === 'object-expression') {
24
+ configExport = esmConfigExports[0].object;
25
+ }
22
26
  if (esmHandlerExports.length !== 0) {
23
27
  if (esmHandlerExports.some(({ type }) => type === 'default')) {
24
28
  hasDefaultExport = true;
@@ -32,15 +36,14 @@ export const traverseNodes = (nodes, getAllBindings) => {
32
36
  handlerExports.push(...cjsHandlerExports);
33
37
  return;
34
38
  }
35
- if (isESMDefaultExport(node)) {
36
- hasDefaultExport = true;
37
- return;
38
- }
39
39
  const cjsDefaultExports = getCJSExports(node, 'default');
40
40
  if (cjsDefaultExports.length !== 0) {
41
41
  hasDefaultExport = true;
42
42
  return;
43
43
  }
44
+ if (isESMDefaultExport(node)) {
45
+ hasDefaultExport = true;
46
+ }
44
47
  const esmConfig = parseConfigESMExport(node);
45
48
  if (esmConfig !== undefined) {
46
49
  configExport = esmConfig;
@@ -179,15 +182,19 @@ const parsePrimitive = (exp) => {
179
182
  * `let handler; handler = () => {}; export { handler }`
180
183
  */
181
184
  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
- }
189
185
  const specifier = specifiers.find((node) => isNamedExport(node, name));
186
+ // If there's no named export with the given name, check if there's a default
190
187
  if (!specifier || specifier.type !== 'ExportSpecifier') {
188
+ const defaultExport = specifiers.find((node) => isDefaultExport(node));
189
+ if (defaultExport && defaultExport.type === 'ExportSpecifier') {
190
+ const binding = getAllBindings().get(defaultExport.local.name);
191
+ // eslint-disable-next-line max-depth
192
+ if (binding?.type === 'ArrowFunctionExpression' ||
193
+ binding?.type === 'FunctionDeclaration' ||
194
+ binding?.type === 'Identifier') {
195
+ return [{ type: 'default' }];
196
+ }
197
+ }
191
198
  return [];
192
199
  }
193
200
  const binding = getAllBindings().get(specifier.local.name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/zip-it-and-ship-it",
3
- "version": "9.25.1",
3
+ "version": "9.25.2",
4
4
  "description": "Zip it and ship it",
5
5
  "main": "./dist/main.js",
6
6
  "type": "module",