-
-
Notifications
You must be signed in to change notification settings - Fork 652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: js/ts dependency inference with file suffix #22041
base: main
Are you sure you want to change the base?
fix: js/ts dependency inference with file suffix #22041
Conversation
@@ -166,7 +166,7 @@ def _add_extensions(file_imports: frozenset[str], file_extensions: tuple[str, .. | |||
for file_import in file_imports | |||
for string in ( | |||
[file_import] | |||
if PurePath(file_import).suffix | |||
if PurePath(file_import).suffix and PurePath(file_import).suffix in file_extensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we had a file like foo.<suffix>.js
, foo.<suffix>
was being added to the PathGlobs,
but that file doesn't exist, the correct would be to fallback to the else
statement and use foo.<suffix>.(<file_extensions>)
, so I'm adding a check to make sure the suffix is what we would expect coming from the parameters (all js/ts extensions depending on each dependency inference).
rule_runner.write_files( | ||
{ | ||
"root/project/src/__generated__/BUILD": "javascript_sources()", | ||
"root/project/src/__generated__/moduleA.generated.js": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.generated.js
is one use case, but any suffix should be handled correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! See comment.
src/python/pants/backend/javascript/dependency_inference/rules.py
Outdated
Show resolved
Hide resolved
src/python/pants/backend/javascript/dependency_inference/rules.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
macos test suite failed with:
can we re-run? |
Description
Its possible that we have a file like
foo.<suffix>.js
, but when importing that file on another .js file, dependency inference wasn't working.