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

[WIP] feat: use common TSConfig for clients #3149

Closed
wants to merge 23 commits into from

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Jan 6, 2022

Issue

Refs: #1307
Replaces: #3132

Description

Uses common TSConfig for all generated clients

Testing

CI

Additional context

This is a re-attempt of #3145 with jest maxWorkers at 50%


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

foreach parentDir ("clients" "private")
  for dir in ./$parentDir/*; do (cd "$dir" && sed -i 's/tsconfig.json/tsconfig.cjs.json/g' ./package.json); done
  for dir in ./$parentDir/*; do (cd "$dir" && mv tsconfig.json tsconfig.cjs.json); done
end
foreach parentDir ("clients" "private")
  foreach tsConfigType ("cjs" "es" "types")
    for dir in ./$parentDir/*; do (
      cd "$dir"
      cp ../../clients/client-accessanalyzer/tsconfig.$tsConfigType.json tsconfig.$tsConfigType.json
    ); done
  end
end
@trivikr trivikr requested a review from a team as a code owner January 6, 2022 01:23
@trivikr trivikr marked this pull request as draft January 6, 2022 03:21
@trivikr trivikr changed the title feat: use common TSConfig for clients [WIP] feat: use common TSConfig for clients Jan 6, 2022
@trivikr
Copy link
Member Author

trivikr commented Jan 6, 2022

Cleaned up version posted at #3151

@trivikr trivikr closed this Jan 6, 2022
@trivikr trivikr deleted the root-tsconfig-jest-maxWorkers branch January 6, 2022 04:59
@trivikr trivikr restored the root-tsconfig-jest-maxWorkers branch January 6, 2022 05:36
@trivikr trivikr reopened this Jan 6, 2022
@trivikr
Copy link
Member Author

trivikr commented Jan 6, 2022

The docs generation fails with Javascript heap out of memory, even after using a simplified tsconfig.typedoc.json

$ yarn build-documentation --clientDocs docs/clients/{{CLIENT}} --tsconfig tsconfig.typedoc.json

@trivikr
Copy link
Member Author

trivikr commented Jan 6, 2022

Even if we're able to fix doc generation issue, the tsserver will exit with SIGABT after moving client to use root TSConfig

Screenshot

Screen Shot 2022-01-06 at 7 51 57 AM

This will make TypeScript features unusable in VSCode, like browsing code across packages.
In the below screenshot, we see hover on HttpHandlerOptions import in DynamoDBDocument.ts

Screenshot

Screen Shot 2022-01-06 at 7 53 03 AM

After switching to main branch, and restarting the TSServer the hover on HttpHandlerOptions import in DynamoDBDocument.ts shows the interface in @aws-sdk/types and you can browse to it.

Screenshot

Screen Shot 2022-01-06 at 7 55 24 AM

The issue is reported upstream at microsoft/TypeScript#44951
TypeScript tips on working with large projects https://code.visualstudio.com/docs/typescript/typescript-compiling#_working-with-large-projects

@trivikr
Copy link
Member Author

trivikr commented Jan 6, 2022

Update on doc generation: added tsconfig.typedoc.json with lib and packages included.

Generation of docs for non-clients succeeds when tsconfig is explicitly passed.

$ yarn build-documentation --clientDocs docs/clients/{{CLIENT}} --tsconfig tsconfig.typedoc.json --theme

Generation of docs for clients fails with TypeError: Cannot read properties of undefined (reading 'files')

$ ./node_modules/.bin/lerna exec --scope '@aws-sdk/client-acm' --no-bail --stream -- yarn build:docs --out $(pwd)/docs/clients/$(basename \$LERNA_PACKAGE_NAME) --tsconfig ./../../tsconfig.typedoc.json --theme
...
@aws-sdk/client-acm: /local/home/trivikr/workspace/aws-sdk-js-v3/packages/service-client-documentation-generator/dist-cjs/sdk-client-rename-project.js:23
@aws-sdk/client-acm:             const metadataDir = (_b = (_a = clientDirectory.files.filter((sourceFile) => sourceFile.fileName.endsWith("/package.json"))) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.fullFileName;
@aws-sdk/client-acm:                                                             ^
@aws-sdk/client-acm: TypeError: Cannot read properties of undefined (reading 'files')
@aws-sdk/client-acm:     at SdkClientRenameProjectPlugin.onRenderedBegin (/local/home/trivikr/workspace/aws-sdk-js-v3/packages/service-client-documentation-generator/dist-cjs/sdk-client-rename-project.js:23:61)
@aws-sdk/client-acm:     at /local/home/trivikr/workspace/aws-sdk-js-v3/node_modules/typedoc/dist/lib/utils/events.js:260:33
@aws-sdk/client-acm:     at triggerApi (/local/home/trivikr/workspace/aws-sdk-js-v3/node_modules/typedoc/dist/lib/utils/events.js:111:13)
@aws-sdk/client-acm:     at Renderer.trigger (/local/home/trivikr/workspace/aws-sdk-js-v3/node_modules/typedoc/dist/lib/utils/events.js:253:13)
@aws-sdk/client-acm:     at Renderer.render (/local/home/trivikr/workspace/aws-sdk-js-v3/node_modules/typedoc/dist/lib/output/renderer.js:34:14)
@aws-sdk/client-acm:     at CliApplication.generateDocs (/local/home/trivikr/workspace/aws-sdk-js-v3/node_modules/typedoc/dist/lib/application.js:105:23)
@aws-sdk/client-acm:     at CliApplication.bootstrap (/local/home/trivikr/workspace/aws-sdk-js-v3/node_modules/typedoc/dist/lib/cli.js:49:26)
@aws-sdk/client-acm:     at Object.<anonymous> (/local/home/trivikr/workspace/aws-sdk-js-v3/node_modules/typedoc/bin/typedoc:5:5)
@aws-sdk/client-acm:     at Module._compile (node:internal/modules/cjs/loader:1101:14)
@aws-sdk/client-acm:     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
@aws-sdk/client-acm: error Command failed with exit code 1.
@aws-sdk/client-acm: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! Received non-zero exit code 1 during execution
lerna success exec Executed command in 1 package: "yarn build:docs --out /home/trivikr/workspace/aws-sdk-js-v3/docs/clients/$LERNA_PACKAGE_NAME --tsconfig ./../../tsconfig.typedoc.json --theme"

@trivikr
Copy link
Member Author

trivikr commented Jan 6, 2022

Closing this PR as we're going to pause this work, and merge fixes/improvements identified during the development to main branch. The final cleaned up PR for future reference will be updated in #3151

@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 21, 2022
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.

1 participant