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: replace .npmignore to allow list of NPM artifacts #10473

Merged
merged 7 commits into from
Oct 20, 2022

Conversation

AllanZhengYP
Copy link
Member

@AllanZhengYP AllanZhengYP commented Oct 13, 2022

Description of changes

Currently all Amplify packages(except for amazon-cognito-identity-js) publish 4 artifacts to the NPM:

  • TypeScript source code in src folder
  • ES5 standard ES Module in lib-esm folder
  • ES6 standard CommonJS module in lib folder
  • Bundled and minified UMD module from lib-esm source code in dist folder

This change exclude the 4th one(dist folder) as they are used to deploy the source code to CDN. Customers should consume them from NPM package directly.

This change also excludes files below beyond .npmignore:

  • index.js: deprecated CommonJS entry point file. Now the CommonJS entry point is ./lib/index.js(see original commit)
  • build.js: internal per-package build script. It can be excluded from publishing to NPM.
  • index-rn.js: possibly the deprecated react native entry point.

After this change, the package size(install size) of each package is reduced by >50%:

  • aws-amplify install size: 179MB to 91 MB(packagephobia); publish size: 37.7MB to 134kB;
  • @aws-amplify/auth install size: 22.6 MB to 13.7 MB; publish size: 2.41MB to 747kB(packagephbia)

The installation time doesn't improve significantly:

  • Before with package-lock.json without cache production-only:
    npm install --force aws-amplify@latest 36.72s user 4.64s system 152% cpu 27.079 total
  • After with package-lock.json without cache production-only:
    npm install --force aws-amplify@clean-npm-artifacts 35.74s user 4.32s system 151% cpu 26.522 total

Mostly because NPM or Yarn does pretty well downloading artifacts concurrently.

The current install size includes chunky react-native. It will be removed updating AWS SDK in next breaking change(commit)

Description of how you validated changes

Unit test & Integ test

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@AllanZhengYP AllanZhengYP requested review from a team as code owners October 13, 2022 21:11
@AllanZhengYP AllanZhengYP changed the title chore: add files to package.json to allow list artifacts published to NPM chore: replace .npmignore to allow list of NPM artifacts Oct 13, 2022
Copy link
Member

@cshfang cshfang left a comment

Choose a reason for hiding this comment

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

🚀

@AllanZhengYP AllanZhengYP force-pushed the clean-npm-artifacts branch 2 times, most recently from ecf315c to 248d636 Compare October 20, 2022 20:02
@codecov-commenter
Copy link

Codecov Report

Merging #10473 (c845936) into next-major-version/5 (b631360) will not change coverage.
The diff coverage is n/a.

@@                  Coverage Diff                  @@
##           next-major-version/5   #10473   +/-   ##
=====================================================
  Coverage                 83.81%   83.81%           
=====================================================
  Files                       193      193           
  Lines                     16899    16899           
  Branches                   3585     3585           
=====================================================
  Hits                      14164    14164           
  Misses                     2657     2657           
  Partials                     78       78           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@AllanZhengYP AllanZhengYP merged commit c9f001d into next-major-version/5 Oct 20, 2022
@AllanZhengYP AllanZhengYP deleted the clean-npm-artifacts branch October 20, 2022 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants