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

chore(scripts): add script to downlevel-dts and strip comments #2834

Merged
merged 5 commits into from
Sep 27, 2021

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Sep 27, 2021

Issue

Description

Runs downlevel-dts npm script (if present) in each workspace of monorepo, and strips comments from *.d.ts files. The npm install size is reduced by ~6%.

Script

Rename .txt to .js before running

npmInstallSizes.txt

Before

Total size: 834.16 MB

before.md

After

Total size: 789.60 MB

after.md

Testing

Verified that comments are removed from *.d.ts files.

Tested by running manually running local downlevel-dts in packages/abort-controller followed by running global downlevel-dts:

Before
$ head dist/types/ts3.4/AbortSignal.d.ts
import { AbortHandler, AbortSignal as IAbortSignal } from "@aws-sdk/types";
export declare class AbortSignal implements IAbortSignal {
    onabort: AbortHandler | null;
    private _aborted;
    constructor();
    /*
    * Whether the associated operation has already been cancelled.
    */
    readonly aborted: boolean;
    /**
After
$ head dist/types/ts3.4/AbortSignal.d.ts
import { AbortHandler, AbortSignal as IAbortSignal } from "@aws-sdk/types";
export declare class AbortSignal implements IAbortSignal {
    onabort: AbortHandler | null;
    private _aborted;
    constructor();

    readonly aborted: boolean;

    abort(): void;
}

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

@codecov-commenter
Copy link

codecov-commenter commented Sep 27, 2021

Codecov Report

Merging #2834 (acf61ca) into main (033a4d8) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2834   +/-   ##
=======================================
  Coverage   60.41%   60.41%           
=======================================
  Files         554      554           
  Lines       28885    28885           
  Branches     7072     7072           
=======================================
  Hits        17452    17452           
  Misses      11433    11433           

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 033a4d8...acf61ca. Read the comment docs.

@trivikr trivikr marked this pull request as ready for review September 27, 2021 15:03
Copy link
Contributor

@AllanZhengYP AllanZhengYP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how long this step takes, if it takes minutes, we should use cluster module. I'm also looking for good 3-p library wrapping it.

scripts/downlevel-dts/index.js Show resolved Hide resolved
scripts/downlevel-dts/index.js Show resolved Hide resolved
@trivikr trivikr changed the title chore: add downlevel-dts script to downlevel dts and strip comments chore(scripts): add script to downlevel-dts and strip comments Sep 27, 2021
@trivikr trivikr merged commit 2923d66 into aws:main Sep 27, 2021
@trivikr trivikr deleted the downlevel-dts branch September 27, 2021 18:08
@trivikr
Copy link
Member Author

trivikr commented Sep 27, 2021

I don't know how long this step takes, if it takes minutes, we should use cluster module. I'm also looking for good 3-p library wrapping it.

Tested on c5.9xlarge, it takes 700s

# Ensured that ts3.4 folders are removed from all workspaces by running the followings script
$ foreach dir ("lib" "packages" "clients" "protocol_tests")
  for d in $dir/* ;do (cd "$d" && rm -rf dist/types/ts3.4); done
end

$ time yarn downlevel-dts
yarn run v1.22.11
$ node ./scripts/downlevel-dts
Done in 699.06s.
yarn downlevel-dts  1165.78s user 64.57s system 175% cpu 11:39.19 total

I'll post a different PR to perform the operations in parallel.

@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 Oct 12, 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