-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[ESLint Plugin] Enforce inclusion of dist-esm and exclusion of src in files field in package.json #11411
[ESLint Plugin] Enforce inclusion of dist-esm and exclusion of src in files field in package.json #11411
Conversation
+1 on fixing all the package.json files in the same PR |
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.
I don't think we can remove dist-esm
. External bundlers rely on having our ESM sources to build us for different targets like browsers, and our browser mappings rely on having the ESMs in the package.
We should not remove dist-esm. It is not just for source mapping. It is preferred by bundlers. Some of the rationale is documented here, feel free to send a PR either updating this or removing the guideline with rationale! |
Let's change this to remove |
Thanks @willmtemple, @bterlson, and @xirzec for the feedback! Please take another look. Hi @XiaoningLiu, would you please confirm if source files need to be shipped in |
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.
Left some comments with some nitpicks about code style and a couple of places where I think this could benefit from extra documentation, overall happy with the change to the linter's behavior.
common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-files-required.ts
Outdated
Show resolved
Hide resolved
common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-files-required.ts
Show resolved
Hide resolved
common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-files-required.ts
Outdated
Show resolved
Hide resolved
common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-files-required.ts
Outdated
Show resolved
Hide resolved
common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-files-required.ts
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.
Overall happy with this rule change, but I'd like to suggest making sure that this still works with packages that use shared code, such as keyvault (via keyvault-common) and storage. I think the output structure of their dist-esm
is different due to the deeper-rooted source tree.
I think we should require all of dist-esm
rather than just dist-esm/src
.
* files list by the fixer. | ||
* @param pat - A pattern that is missing from the files list | ||
*/ | ||
function buildFixRequiredPattern(pat: string): string { |
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.
This really helped clarify the purpose of the map above, thanks!
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.
Just spoke with @deyaaeldeen and he clarified that the current behavior is not to requite dist-esm/src
, but to use it as the default value, but anything that begins with dist-esm
will be accepted. I'm good with that.
This change updates thets-package-json-files-required
rule to check for the absence ofsrc
anddist-esm
in thefiles
list inpackage.json
since sourcemaps now have the sources embedded. It is based on discussion with @xirzec here #11273 (comment). Related issue: #7615.TODO in this PR: update every package'spackage.json
to conform to the final rule before merging.After discussion with @willmtemple, @bterlson, and @xirzec here, this PR updates the eslint plugin to make sure
dist-esm
is included andsrc
is not inpackage'json
'sfiles
list.