@@ -102,6 +102,7 @@ def run(self, args, cwd=None):
102
102
103
103
104
104
# The esbuild API flags are broken up into three forms (https://esbuild.github.io/api/):
105
+ # Multi-word arguments are expected to be passed down using snake case e.g. entry_points
105
106
# Boolean types (--minify)
106
107
SUPPORTED_ESBUILD_APIS_BOOLEAN = [
107
108
"minify" ,
@@ -112,7 +113,7 @@ def run(self, args, cwd=None):
112
113
SUPPORTED_ESBUILD_APIS_SINGLE_VALUE = [
113
114
"target" ,
114
115
"format" ,
115
- "main-fields " ,
116
+ "main_fields " ,
116
117
]
117
118
118
119
# Multi-value types (--external:axios --external:aws-sdk)
@@ -236,7 +237,7 @@ def _get_boolean_args(self) -> List[str]:
236
237
args = []
237
238
for param in SUPPORTED_ESBUILD_APIS_BOOLEAN :
238
239
if param in self ._bundler_config and self ._bundler_config [param ] is True :
239
- args .append (f"--{ param } " )
240
+ args .append (f"--{ self . _convert_snake_to_kebab_case ( param ) } " )
240
241
return args
241
242
242
243
def _get_single_value_args (self ) -> List [str ]:
@@ -250,7 +251,7 @@ def _get_single_value_args(self) -> List[str]:
250
251
for param in SUPPORTED_ESBUILD_APIS_SINGLE_VALUE :
251
252
if param in self ._bundler_config :
252
253
value = self ._bundler_config .get (param )
253
- args .append (f"--{ param } ={ value } " )
254
+ args .append (f"--{ self . _convert_snake_to_kebab_case ( param ) } ={ value } " )
254
255
return args
255
256
256
257
def _get_multi_value_args (self ) -> List [str ]:
@@ -267,7 +268,7 @@ def _get_multi_value_args(self) -> List[str]:
267
268
if not isinstance (values , list ):
268
269
raise EsbuildCommandError (f"Invalid type for property { param } , must be a dict." )
269
270
for param_item in values :
270
- args .append (f"--{ param } :{ param_item } " )
271
+ args .append (f"--{ self . _convert_snake_to_kebab_case ( param ) } :{ param_item } " )
271
272
return args
272
273
273
274
def _get_explicit_file_type (self , entry_point , entry_path ):
@@ -296,3 +297,14 @@ def _get_explicit_file_type(self, entry_point, entry_path):
296
297
return entry_point + ext
297
298
298
299
raise ActionFailedError ("entry point {} does not exist" .format (entry_path ))
300
+
301
+ @staticmethod
302
+ def _convert_snake_to_kebab_case (arg : str ) -> str :
303
+ """
304
+ The configuration properties passed down to Lambda Builders are done so using snake case
305
+ e.g. "main_fields" but esbuild expects them using kebab-case "main-fields"
306
+
307
+ :rtype: str
308
+ :return: mutated string to match the esbuild argument format
309
+ """
310
+ return arg .replace ("_" , "-" )
0 commit comments