Skip to content
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(codgen): only publish types and dist folder to npm #1615

Closed
wants to merge 1 commit into from

Conversation

workeitel
Copy link
Contributor

Before all kind of .ts files got published as well, which can cause problems when consuming them because TypeScript would re-compile .ts files in node_modules. It's better to only publish the types and dist folder with compiled artifacts.

Issue #, if available:

Description of changes:

I think it would be better to have an allow-list instead of the deny-list. I tried adding a files section:

diff --git a/codegen/smithy-aws-typescript-codegen/src/main/resources/software/amazon/smithy/aws/typescript/codegen/package.json.template b/codegen/smithy-aws-typescript-codegen/src/main/resources/software/amazon/smithy/aws/typescript/codegen/package.json.template
index cb857a66e0..992d26b505 100644
--- a/codegen/smithy-aws-typescript-codegen/src/main/resources/software/amazon/smithy/aws/typescript/codegen/package.json.template
+++ b/codegen/smithy-aws-typescript-codegen/src/main/resources/software/amazon/smithy/aws/typescript/codegen/package.json.template
@@ -3,5 +3,6 @@
     "name": "AWS SDK for JavaScript Team",
     "url": "https://aws.amazon.com/javascript/"
   },
+  "files": ["dist", "types"],
   "license": "Apache-2.0"
 }

but the result generated a strange map:

+  "files": {
+    "0": "dist",
+    "1": "types"
+  },

I'm not sure how to debug it further.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Before all kind of `.ts` files got published as well, which can cause problems when consuming them because TypeScript would re-compile `.ts` files in `node_modules`. It's better to only publish the `types` and `dist` folder with compiled artifacts.
@trivikr trivikr changed the title fix(codgen): Only publish types and dist folder to npm fix(codgen): only publish types and dist folder to npm Oct 25, 2020
@codecov-io
Copy link

Codecov Report

Merging #1615 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1615   +/-   ##
=======================================
  Coverage   79.73%   79.73%           
=======================================
  Files         324      324           
  Lines       12056    12056           
  Branches     2547     2547           
=======================================
  Hits         9613     9613           
  Misses       2443     2443           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 19f3fea...7f233bc. Read the comment docs.

@AllanZhengYP
Copy link
Contributor

@workeitel I agree we need to move to allowed list in the future. Regarding not publishing the TypeScript, we release them per the request from #1462 . Can take a looks at the original PR and?

For the issue you mentioned above that TSC will compile .ts in node_modules, they must be excluded from tsconfig.json

@workeitel
Copy link
Contributor Author

I'm sorry, I was wrong. node_modules IS compiled even if it's excluded. But that's only correct if the files next to each other:

$ grep exclude tsconfig.json 
  "exclude": ["node_modules"]
$ npx tsc --listFiles | grep -v ".d.ts"
/private/tmp/asdf/src/test.ts

But after copying the files they are compiled even when excluded:

$ cp /private/tmp/asdf/node_modules/@aws-sdk/client-api-gateway/pagination/Interfaces.ts /private/tmp/asdf/node_modules/@aws-sdk/client-api-gateway/types/pagination/Interfaces.ts
$ npx tsc --listFiles | grep -v ".d.ts"
/private/tmp/asdf/node_modules/@aws-sdk/client-api-gateway/types/pagination/Interfaces.ts
/private/tmp/asdf/src/test.ts

That means there is no problem as long as the .ts files are separated from the dist and types folder.

Resolving the PR.

@workeitel workeitel closed this Oct 26, 2020
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants