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

QA improve checks #1969

Merged
merged 8 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
- reopened

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x]
steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: 📥 Install
run: npm install

- name: ESLint checks
run: npm run lint

- name: Unit tests
run: npm test

- name: E2E tests
run: npm run test:e2e

- name: Build next-i18next
run: npm run build

- name: Check dist for ecmascript compliance
run: npm run check-dist

- name: Check size limits
run: npm run check-size

39 changes: 39 additions & 0 deletions .size-limit.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// @ts-check

const fullEsmMaxSize = "23KB";
const fullCjsMaxSize = "46KB";

const modifyWebpackConfig = config => {
config.resolve = {};
config.resolve.fallback = { "path": false, "fs": false };
}

/**
* Will ensure esm tree-shakeability and total size are within expectations.
*
* @link https://github.com/ai/size-limit/
* @type {{name: string, path: string[], limit: string, import?: string, webpack?: boolean, modifyWebpackConfig: any}[]}
*/
module.exports = [
// ###################################################
// ESM full bundle
// ###################################################
{
name: "ESM (import everything *)",
path: ["dist/esm/index.js"],
import: "*",
limit: fullEsmMaxSize,
modifyWebpackConfig,
},
// ###################################################
// Commonjs full bundle
// ###################################################
{
name: "CJS (require everything *)",
path: ["dist/commonjs/index.js"],
import: "*",
webpack: true,
limit: fullCjsMaxSize,
modifyWebpackConfig,
}
];
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@
"contributors:generate": "all-contributors generate",
"preversion": "npm run test && npm run build && git push",
"postversion": "git push && git push --tags && npm run release",
"release": "gh-release"
"release": "gh-release",
"check-size": "size-limit",
"analyze-size:why": "size-limit --why",
"check-dist": "run-s check-dist:*",
"check-dist:browser-cjs": "es-check --not 'dist/**/*.map.js,dist/commonjs/createClient/package.json,dist/commonjs/**node**.js,dist/commonjs/serverSideTranslations.js' -v es2017 './dist/commonjs/**/*'",
"check-dist:browser-esm": "es-check --not 'dist/**/*.map.js,dist/esm/createClient/package.json,dist/**node**.js,dist/esm/serverSideTranslations.js' -v es2017 --module './dist/esm/**/*'"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -93,6 +98,9 @@
"@babel/preset-env": "^7.18.10",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@size-limit/file": "^8.1.0",
"@size-limit/webpack": "^8.1.0",
"@size-limit/webpack-why": "8.1.0",
"@testing-library/react": "^13.3.0",
"@types/i18next-fs-backend": "^1.1.2",
"@types/jest": "^28.1.7",
Expand All @@ -108,6 +116,7 @@
"babel-plugin-transform-async-to-generator": "^6.24.1",
"bundlesize": "^0.18.1",
"cypress": "^9.1.1",
"es-check": "^7.0.1",
"eslint": "^8.22.0",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-import": "^2.26.0",
Expand All @@ -119,10 +128,13 @@
"husky": "^3.0.0",
"jest": "^26.6.3",
"next": "^12.2.5",
"npm-run-all": "^4.1.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"start-server-and-test": "^1.14.0",
"typescript": "^4.7.4"
"typescript": "^4.7.4",
"size-limit": "8.1.0",
"webpack": "5.74.0"
},
"dependencies": {
"@babel/runtime": "^7.18.9",
Expand Down