@@ -14,6 +14,7 @@ def _esbuild_impl(ctx):
1414 # Path alias mapings are used to create a jsconfig with mappings so that esbuild
1515 # how to resolve custom package or module names
1616 path_alias_mappings = dict ()
17+ npm_workspaces = []
1718
1819 if (ctx .attr .link_workspace_root ):
1920 path_alias_mappings .update (generate_path_mapping (ctx .workspace_name , "." ))
@@ -29,12 +30,19 @@ def _esbuild_impl(ctx):
2930
3031 if NpmPackageInfo in dep :
3132 deps_depsets .append (dep [NpmPackageInfo ].sources )
33+ npm_workspaces .append (dep [NpmPackageInfo ].workspace )
3234
3335 # Collect the path alias mapping to resolve packages correctly
3436 if hasattr (dep , MODULE_MAPPINGS_ASPECT_RESULTS_NAME ):
3537 for key , value in getattr (dep , MODULE_MAPPINGS_ASPECT_RESULTS_NAME ).items ():
3638 path_alias_mappings .update (generate_path_mapping (key , value [1 ].replace (ctx .bin_dir .path + "/" , "" )))
3739
40+ node_modules_mappings = [
41+ "../../../external/%s/node_modules/*" % workspace
42+ for workspace in depset (npm_workspaces ).to_list ()
43+ ]
44+ path_alias_mappings .update ({"*" : node_modules_mappings })
45+
3846 deps_inputs = depset (transitive = deps_depsets ).to_list ()
3947 inputs = filter_files (ctx .files .entry_point , [".mjs" , ".js" ]) + ctx .files .srcs + deps_inputs
4048
@@ -48,6 +56,7 @@ def _esbuild_impl(ctx):
4856 args .add ("--bundle" , entry_point .path )
4957 args .add ("--sourcemap" )
5058 args .add ("--keep-names" )
59+ args .add ("--preserve-symlinks" )
5160 args .add_joined (["--platform" , ctx .attr .platform ], join_with = "=" )
5261 args .add_joined (["--target" , ctx .attr .target ], join_with = "=" )
5362 args .add_joined (["--log-level" , "info" ], join_with = "=" )
0 commit comments