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

noahdarveau/size-limit test #2717

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Added a size limit configuration to fail builds if treeshaking stops working",
"packageName": "@microsoft/teams-js",
"email": "109628470+noahdarveau-MSFT@users.noreply.github.com",
"dependentChangeType": "none"
}
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,27 @@
"uuid": "^9.0.1"
},
"size-limit": [
{
"brotli": false,
"path": "./packages/teams-js/dist/esm/packages/teams-js/src/index.js",
"import": "{ app, authentication, pages }",
"limit": "57 KB"
},
{
"brotli": false,
"path": "./packages/teams-js/dist/esm/packages/teams-js/src/index.js",
"import": "*"
}
],
"size-limit-explanation": [
"There are 2 configurations for size-limit. The first configuration is used to test treeshakability in teams-js. If treeshaking is broken in any capability other than `app`, `authentication`, or `pages`, then the size of the build",
"will increase above the set amount. The limit is currently just slightly above the size of building the library and importing the 3 specified capabilities. If your build ever fails because of this size-limit check there are a few scenarios you may fall into:",
"1. You made changes to a file other than `app`, `authentication`, `pages`, or an internal folder file that unintentionally broke treeshakability, and you need to investigate and resolve why this has happened.",
"2. You made a change to either `app`, `authentication`, `pages`, or an internal folder file. These size changes are intentional and do not affect treeshaking. In this case, you need to determine the new size of the build and update the size-limit accordingly.",
"3. You made changes to a file other than `app`, `authentication`, `pages`, or an internal folder file that justly requires the size of the build to increase. This can be due to other factors that do not affect treeshakability, but do result",
"in a package size increase. An example of this may be adding references to another library that requires a polyfill. The inclusion of that polyfill may increase the library size.",
"Any time you increase the size-limit of the build, be sure to include an explanation of why it is necessary in the PR description.",
"If you run into any problems or have questions, reach out to [Noah Darveau](noahdarveau-MSFT@microsoft.com) or file an issue on the [Teams-JS github page](https://github.com/OfficeDev/microsoft-teams-library-js).",
"The second configration is there as a simple and easy way to determine the size of the entire library."
]
}
4 changes: 2 additions & 2 deletions packages/teams-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"typings": "./dist/esm/packages/teams-js/dts/index.d.ts",
"module": "./dist/esm/packages/teams-js/src/index.js",
"scripts": {
"build": "pnpm clean && pnpm lint && pnpm build-rollup && pnpm build-webpack && pnpm docs:validate",
"build": "pnpm clean && pnpm lint && pnpm build-rollup && pnpm build-webpack && pnpm docs:validate && pnpm size",
"build-rollup": "pnpm clean && rollup -c",
"build-webpack": "webpack",
"clean": "rimraf ./dist",
"docs": "pnpm typedoc",
"docs:validate": "pnpm typedoc --emit none",
"lint": "pnpm eslint ./src ./test --max-warnings 0 --fix --ext .ts",
"prettier": "prettier --write '**/*.{ts,js,css,html}'",
"size": "pnpm build && size-limit",
"size": "size-limit",
"test": "jest",
"test:verbose": "pnpm test -- --verbose false --silent false"
},
Expand Down
Loading