From 1b621ea2b43cf54dfce3be6adf481ff7a6693f94 Mon Sep 17 00:00:00 2001 From: Haseeb Ahmad Date: Thu, 1 Feb 2024 11:42:19 -0500 Subject: [PATCH 1/5] code splitting with rollup - split each folder with index.ts in styles/ dir to it's own package - existing code should move components to their own directories like Input as many components in a file - new components should be created in their own directories - add eslint for fix lint errors in rollup js files - update and optimize rollup build --- .eslintrc | 11 + getFiles.js | 28 ++ package-lock.json | 974 ++++++++++++++++++++++++++++++------------ package.json | 7 +- rollup.config.js | 144 +++++-- scripts/buildUtils.js | 31 ++ scripts/postBuild.js | 45 ++ tsconfig.json | 1 + tsconfig.lib.json | 1 + 9 files changed, 930 insertions(+), 312 deletions(-) create mode 100644 .eslintrc create mode 100644 getFiles.js create mode 100644 scripts/buildUtils.js create mode 100644 scripts/postBuild.js diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..b4b3b194 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,11 @@ +{ + "parser": "babel-eslint", + "parserOptions": { + "babelOptions": { + "presets": [ + ["babel-preset-react-app", false], + "babel-preset-react-app/prod" + ] + } + } +} \ No newline at end of file diff --git a/getFiles.js b/getFiles.js new file mode 100644 index 00000000..0e02fa4a --- /dev/null +++ b/getFiles.js @@ -0,0 +1,28 @@ +/* eslint-disable import/prefer-default-export */ +const fs = require('fs'); + +export const getFiles = (entry, extensions = [], excludeExtensions = []) => { + let fileNames = []; + const dirs = fs.readdirSync(entry); + + dirs.forEach((dir) => { + const path = `${entry}/${dir}`; + + if (fs.lstatSync(path).isDirectory()) { + fileNames = [ + ...fileNames, + ...getFiles(path, extensions, excludeExtensions), + ]; + + return; + } + + if (!excludeExtensions.some((exclude) => dir.endsWith(exclude)) + && extensions.some((ext) => dir.endsWith(ext)) + ) { + fileNames.push(path); + } + }); + + return fileNames; +}; diff --git a/package-lock.json b/package-lock.json index 3e8609fc..7ce099f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,9 +29,11 @@ "devDependencies": { "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^24.1.0", + "@rollup/plugin-dynamic-import-vars": "^2.1.2", "@rollup/plugin-image": "^3.0.2", "@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-replace": "^5.0.2", + "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.0", "@rollup/plugin-url": "^8.0.1", "@svgr/rollup": "^7.0.0", @@ -61,10 +63,12 @@ "rollup": "^3.21.0", "rollup-plugin-dts": "^5.3.0", "rollup-plugin-filesize": "^10.0.0", + "rollup-plugin-generate-package-json": "^3.2.0", "rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-postcss": "^4.0.2", "rollup-plugin-progress": "^1.1.2", "rollup-plugin-typescript2": "^0.34.1", + "rollup-plugin-visualizer": "^5.12.0", "styled-components": "^5.3.10", "tslib": "^2.5.0", "typescript": "^4.9.5" @@ -4580,6 +4584,48 @@ "node": ">=10" } }, + "node_modules/@rollup/plugin-dynamic-import-vars": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@rollup/plugin-dynamic-import-vars/-/plugin-dynamic-import-vars-2.1.2.tgz", + "integrity": "sha512-4lr2oXxs9hcxtGGaK8s0i9evfjzDrAs7ngw28TqruWKTEm0+U4Eljb+F6HXGYdFv8xRojQlrQwV7M/yxeh3yzQ==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "astring": "^1.8.5", + "estree-walker": "^2.0.2", + "fast-glob": "^3.2.12", + "magic-string": "^0.30.3" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-dynamic-import-vars/node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@rollup/plugin-dynamic-import-vars/node_modules/magic-string": { + "version": "0.30.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz", + "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/@rollup/plugin-image": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@rollup/plugin-image/-/plugin-image-3.0.2.tgz", @@ -4659,6 +4705,28 @@ "node": ">=12" } }, + "node_modules/@rollup/plugin-terser": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz", + "integrity": "sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==", + "dev": true, + "dependencies": { + "serialize-javascript": "^6.0.1", + "smob": "^1.0.0", + "terser": "^5.17.4" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/plugin-typescript": { "version": "11.1.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-11.1.1.tgz", @@ -6188,6 +6256,12 @@ "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==", "dev": true }, + "node_modules/@types/normalize-package-data": { + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz", + "integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==", + "dev": true + }, "node_modules/@types/parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", @@ -7470,6 +7544,15 @@ "integrity": "sha512-eBvWn1lvIApYMhzQMsu9ciLfkBY499mFZlNqG+/9WR7PVlroQw0vG30cOQQbaKz3sCEc44TAOu2ykzqXSNnwag==", "dev": true }, + "node_modules/astring": { + "version": "1.8.6", + "resolved": "https://registry.npmjs.org/astring/-/astring-1.8.6.tgz", + "integrity": "sha512-ISvCdHdlTDlH5IpxQJIex7BWBywFWgjJSVdwst+/iQCoEYnyOaQ95+X1JGshuBjGp6nxKUy1jMgE3zPqN7fQdg==", + "dev": true, + "bin": { + "astring": "bin/astring" + } + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -10234,6 +10317,15 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/detect-indent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-5.0.0.tgz", + "integrity": "sha512-rlpvsxUtM0PQvy9iZe640/IWwWYyBsTApREbA1pHOpmOUIl9MkP/U4z7vTtg4Oaojvqhxt7sdufnT0EzGaR31g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -12628,20 +12720,6 @@ "node": ">= 0.6" } }, - "node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/fs-minipass": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", @@ -13228,42 +13306,6 @@ "node": ">=12" } }, - "node_modules/html-minifier-terser/node_modules/acorn": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz", - "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/html-minifier-terser/node_modules/terser": { - "version": "5.18.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.18.1.tgz", - "integrity": "sha512-j1n0Ao919h/Ai5r43VAnfV/7azUYW43GPxK7qSATzrsERfW7+y2QW9Cp9ufnRF5CQUWbnLSo7UJokSWCqg4tsQ==", - "dev": true, - "dependencies": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.8.2", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "bin": { - "terser": "bin/terser" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/html-minifier-terser/node_modules/terser/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, "node_modules/html-webpack-plugin": { "version": "5.5.3", "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.5.3.tgz", @@ -22562,6 +22604,20 @@ } } }, + "node_modules/react-scripts/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/react-scripts/node_modules/semver": { "version": "7.5.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.3.tgz", @@ -22990,6 +23046,57 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/read-pkg": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", + "dev": true, + "dependencies": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/read-pkg/node_modules/hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true + }, + "node_modules/read-pkg/node_modules/normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "dependencies": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "node_modules/read-pkg/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/read-pkg/node_modules/type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -23611,18 +23718,6 @@ "node": ">=16.0.0" } }, - "node_modules/rollup-plugin-filesize/node_modules/acorn": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz", - "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/rollup-plugin-filesize/node_modules/colors": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", @@ -23632,12 +23727,6 @@ "node": ">=0.1.90" } }, - "node_modules/rollup-plugin-filesize/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, "node_modules/rollup-plugin-filesize/node_modules/filesize": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/filesize/-/filesize-6.4.0.tgz", @@ -23662,22 +23751,20 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/rollup-plugin-filesize/node_modules/terser": { - "version": "5.18.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.18.1.tgz", - "integrity": "sha512-j1n0Ao919h/Ai5r43VAnfV/7azUYW43GPxK7qSATzrsERfW7+y2QW9Cp9ufnRF5CQUWbnLSo7UJokSWCqg4tsQ==", + "node_modules/rollup-plugin-generate-package-json": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-generate-package-json/-/rollup-plugin-generate-package-json-3.2.0.tgz", + "integrity": "sha512-+Kq1kFVr+maxW/mZB+E+XuaieCXVZqjl2tNU9k3TtAMs3NOaeREa5sRHy67qKDmcnFtZZukIQ3dFCcnV+r0xyw==", "dev": true, "dependencies": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.8.2", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "bin": { - "terser": "bin/terser" + "read-pkg": "^5.2.0", + "write-pkg": "^4.0.0" }, "engines": { - "node": ">=10" + "node": ">=8.3" + }, + "peerDependencies": { + "rollup": ">=1.0.0" } }, "node_modules/rollup-plugin-peer-deps-external": { @@ -23887,6 +23974,20 @@ "url": "https://github.com/avajs/find-cache-dir?sponsor=1" } }, + "node_modules/rollup-plugin-typescript2/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/rollup-plugin-typescript2/node_modules/pkg-dir": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", @@ -23914,6 +24015,82 @@ "node": ">=10" } }, + "node_modules/rollup-plugin-visualizer": { + "version": "5.12.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-visualizer/-/rollup-plugin-visualizer-5.12.0.tgz", + "integrity": "sha512-8/NU9jXcHRs7Nnj07PF2o4gjxmm9lXIrZ8r175bT9dK8qoLlvKTwRMArRCMgpMGlq8CTLugRvEmyMeMXIU2pNQ==", + "dev": true, + "dependencies": { + "open": "^8.4.0", + "picomatch": "^2.3.1", + "source-map": "^0.7.4", + "yargs": "^17.5.1" + }, + "bin": { + "rollup-plugin-visualizer": "dist/bin/cli.js" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "rollup": "2.x || 3.x || 4.x" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/rollup-plugin-visualizer/node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/rollup-plugin-visualizer/node_modules/source-map": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/rollup-plugin-visualizer/node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/rollup-plugin-visualizer/node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, "node_modules/rollup-pluginutils": { "version": "2.8.2", "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", @@ -24364,6 +24541,12 @@ "npm": ">= 3.0.0" } }, + "node_modules/smob": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/smob/-/smob-1.4.1.tgz", + "integrity": "sha512-9LK+E7Hv5R9u4g4C3p+jjLstaLe11MDsL21UpYaCNmapvMkYhqCV4A/f/3gyH8QjMyh6l68q9xC85vihY9ahMQ==", + "dev": true + }, "node_modules/sockjs": { "version": "0.3.24", "resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.24.tgz", @@ -24441,6 +24624,27 @@ "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==", "dev": true }, + "node_modules/sort-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-2.0.0.tgz", + "integrity": "sha512-/dPCrG1s3ePpWm6yBbxZq5Be1dXGLyLn9Z791chDC3NFrpkVbWGzkBwPN1knaciexFXgRJ7hzdnwZ4stHSDmjg==", + "dev": true, + "dependencies": { + "is-plain-obj": "^1.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/sort-keys/node_modules/is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-list-map": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", @@ -25359,6 +25563,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/terser": { + "version": "5.27.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.27.0.tgz", + "integrity": "sha512-bi1HRwVRskAjheeYl291n3JC4GgO/Ty4z1nVs5AAsmonJulGxpSektecnNedrwK9C7vpvVtcX3cw00VSLt7U2A==", + "dev": true, + "dependencies": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.8.2", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/terser-webpack-plugin": { "version": "5.3.9", "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.9.tgz", @@ -25393,24 +25615,6 @@ } } }, - "node_modules/terser-webpack-plugin/node_modules/acorn": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz", - "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/terser-webpack-plugin/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, "node_modules/terser-webpack-plugin/node_modules/schema-utils": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz", @@ -25429,24 +25633,24 @@ "url": "https://opencollective.com/webpack" } }, - "node_modules/terser-webpack-plugin/node_modules/terser": { - "version": "5.18.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.18.1.tgz", - "integrity": "sha512-j1n0Ao919h/Ai5r43VAnfV/7azUYW43GPxK7qSATzrsERfW7+y2QW9Cp9ufnRF5CQUWbnLSo7UJokSWCqg4tsQ==", + "node_modules/terser/node_modules/acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "dev": true, - "dependencies": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.8.2", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, "bin": { - "terser": "bin/terser" + "acorn": "bin/acorn" }, "engines": { - "node": ">=10" + "node": ">=0.4.0" } }, + "node_modules/terser/node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -26989,18 +27193,6 @@ "@types/node": "*" } }, - "node_modules/workbox-build/node_modules/acorn": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz", - "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/workbox-build/node_modules/ajv": { "version": "8.12.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", @@ -27017,12 +27209,6 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/workbox-build/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, "node_modules/workbox-build/node_modules/estree-walker": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", @@ -27137,24 +27323,6 @@ "node": ">=8" } }, - "node_modules/workbox-build/node_modules/terser": { - "version": "5.18.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.18.1.tgz", - "integrity": "sha512-j1n0Ao919h/Ai5r43VAnfV/7azUYW43GPxK7qSATzrsERfW7+y2QW9Cp9ufnRF5CQUWbnLSo7UJokSWCqg4tsQ==", - "dev": true, - "dependencies": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.8.2", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "bin": { - "terser": "bin/terser" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/workbox-build/node_modules/tr46": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", @@ -27444,6 +27612,79 @@ "typedarray-to-buffer": "^3.1.5" } }, + "node_modules/write-json-file": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/write-json-file/-/write-json-file-3.2.0.tgz", + "integrity": "sha512-3xZqT7Byc2uORAatYiP3DHUUAVEkNOswEWNs9H5KXiicRTvzYzYqKjYc4G7p+8pltvAw641lVByKVtMpf+4sYQ==", + "dev": true, + "dependencies": { + "detect-indent": "^5.0.0", + "graceful-fs": "^4.1.15", + "make-dir": "^2.1.0", + "pify": "^4.0.1", + "sort-keys": "^2.0.0", + "write-file-atomic": "^2.4.2" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/write-json-file/node_modules/make-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "dev": true, + "dependencies": { + "pify": "^4.0.1", + "semver": "^5.6.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/write-json-file/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/write-json-file/node_modules/write-file-atomic": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz", + "integrity": "sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + }, + "node_modules/write-pkg": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/write-pkg/-/write-pkg-4.0.0.tgz", + "integrity": "sha512-v2UQ+50TNf2rNHJ8NyWttfm/EJUBWMJcx6ZTYZr6Qp52uuegWw/lBkCtCbnYZEmPRNL61m+u67dAmGxo+HTULA==", + "dev": true, + "dependencies": { + "sort-keys": "^2.0.0", + "type-fest": "^0.4.1", + "write-json-file": "^3.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/write-pkg/node_modules/type-fest": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.4.1.tgz", + "integrity": "sha512-IwzA/LSfD2vC1/YDYMv/zHP4rDF1usCwllsDpbolT3D4fUepIO7f9K70jjmUewU/LmGUKJcwcVtDCpnKk4BPMw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/ws": { "version": "7.5.9", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", @@ -27485,6 +27726,15 @@ "node": ">=0.4" } }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -27526,15 +27776,6 @@ "node": ">=10" } }, - "node_modules/yargs/node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, - "engines": { - "node": ">=10" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -30737,6 +30978,36 @@ } } }, + "@rollup/plugin-dynamic-import-vars": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@rollup/plugin-dynamic-import-vars/-/plugin-dynamic-import-vars-2.1.2.tgz", + "integrity": "sha512-4lr2oXxs9hcxtGGaK8s0i9evfjzDrAs7ngw28TqruWKTEm0+U4Eljb+F6HXGYdFv8xRojQlrQwV7M/yxeh3yzQ==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.0.1", + "astring": "^1.8.5", + "estree-walker": "^2.0.2", + "fast-glob": "^3.2.12", + "magic-string": "^0.30.3" + }, + "dependencies": { + "@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "magic-string": { + "version": "0.30.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz", + "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==", + "dev": true, + "requires": { + "@jridgewell/sourcemap-codec": "^1.4.15" + } + } + } + }, "@rollup/plugin-image": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@rollup/plugin-image/-/plugin-image-3.0.2.tgz", @@ -30782,6 +31053,17 @@ } } }, + "@rollup/plugin-terser": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz", + "integrity": "sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==", + "dev": true, + "requires": { + "serialize-javascript": "^6.0.1", + "smob": "^1.0.0", + "terser": "^5.17.4" + } + }, "@rollup/plugin-typescript": { "version": "11.1.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-11.1.1.tgz", @@ -31881,6 +32163,12 @@ "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==", "dev": true }, + "@types/normalize-package-data": { + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz", + "integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==", + "dev": true + }, "@types/parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", @@ -32931,6 +33219,12 @@ "integrity": "sha512-eBvWn1lvIApYMhzQMsu9ciLfkBY499mFZlNqG+/9WR7PVlroQw0vG30cOQQbaKz3sCEc44TAOu2ykzqXSNnwag==", "dev": true }, + "astring": { + "version": "1.8.6", + "resolved": "https://registry.npmjs.org/astring/-/astring-1.8.6.tgz", + "integrity": "sha512-ISvCdHdlTDlH5IpxQJIex7BWBywFWgjJSVdwst+/iQCoEYnyOaQ95+X1JGshuBjGp6nxKUy1jMgE3zPqN7fQdg==", + "dev": true + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -34948,6 +35242,12 @@ "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", "dev": true }, + "detect-indent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-5.0.0.tgz", + "integrity": "sha512-rlpvsxUtM0PQvy9iZe640/IWwWYyBsTApREbA1pHOpmOUIl9MkP/U4z7vTtg4Oaojvqhxt7sdufnT0EzGaR31g==", + "dev": true + }, "detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -36769,17 +37069,6 @@ "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", "dev": true }, - "fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, "fs-minipass": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", @@ -37218,34 +37507,6 @@ "param-case": "^3.0.4", "relateurl": "^0.2.7", "terser": "^5.10.0" - }, - "dependencies": { - "acorn": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz", - "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==", - "dev": true - }, - "terser": { - "version": "5.18.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.18.1.tgz", - "integrity": "sha512-j1n0Ao919h/Ai5r43VAnfV/7azUYW43GPxK7qSATzrsERfW7+y2QW9Cp9ufnRF5CQUWbnLSo7UJokSWCqg4tsQ==", - "dev": true, - "requires": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.8.2", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "dependencies": { - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - } - } - } } }, "html-webpack-plugin": { @@ -44087,6 +44348,17 @@ "workbox-webpack-plugin": "^6.4.1" }, "dependencies": { + "fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, "semver": { "version": "7.5.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.3.tgz", @@ -44416,6 +44688,50 @@ } } }, + "read-pkg": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", + "dev": true, + "requires": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + }, + "dependencies": { + "hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true + }, + "type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "dev": true + } + } + }, "readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -44883,24 +45199,12 @@ "terser": "^5.6.0" }, "dependencies": { - "acorn": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz", - "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==", - "dev": true - }, "colors": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", "dev": true }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, "filesize": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/filesize/-/filesize-6.4.0.tgz", @@ -44915,21 +45219,19 @@ "requires": { "duplexer": "^0.1.2" } - }, - "terser": { - "version": "5.18.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.18.1.tgz", - "integrity": "sha512-j1n0Ao919h/Ai5r43VAnfV/7azUYW43GPxK7qSATzrsERfW7+y2QW9Cp9ufnRF5CQUWbnLSo7UJokSWCqg4tsQ==", - "dev": true, - "requires": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.8.2", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - } } } }, + "rollup-plugin-generate-package-json": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-generate-package-json/-/rollup-plugin-generate-package-json-3.2.0.tgz", + "integrity": "sha512-+Kq1kFVr+maxW/mZB+E+XuaieCXVZqjl2tNU9k3TtAMs3NOaeREa5sRHy67qKDmcnFtZZukIQ3dFCcnV+r0xyw==", + "dev": true, + "requires": { + "read-pkg": "^5.2.0", + "write-pkg": "^4.0.0" + } + }, "rollup-plugin-peer-deps-external": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/rollup-plugin-peer-deps-external/-/rollup-plugin-peer-deps-external-2.2.4.tgz", @@ -45082,6 +45384,17 @@ "pkg-dir": "^4.1.0" } }, + "fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, "pkg-dir": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", @@ -45102,6 +45415,58 @@ } } }, + "rollup-plugin-visualizer": { + "version": "5.12.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-visualizer/-/rollup-plugin-visualizer-5.12.0.tgz", + "integrity": "sha512-8/NU9jXcHRs7Nnj07PF2o4gjxmm9lXIrZ8r175bT9dK8qoLlvKTwRMArRCMgpMGlq8CTLugRvEmyMeMXIU2pNQ==", + "dev": true, + "requires": { + "open": "^8.4.0", + "picomatch": "^2.3.1", + "source-map": "^0.7.4", + "yargs": "^17.5.1" + }, + "dependencies": { + "cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + } + }, + "source-map": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", + "dev": true + }, + "yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "requires": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + } + }, + "yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true + } + } + }, "rollup-pluginutils": { "version": "2.8.2", "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", @@ -45453,6 +45818,12 @@ "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", "dev": true }, + "smob": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/smob/-/smob-1.4.1.tgz", + "integrity": "sha512-9LK+E7Hv5R9u4g4C3p+jjLstaLe11MDsL21UpYaCNmapvMkYhqCV4A/f/3gyH8QjMyh6l68q9xC85vihY9ahMQ==", + "dev": true + }, "sockjs": { "version": "0.3.24", "resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.24.tgz", @@ -45521,6 +45892,23 @@ "socks": "^2.6.2" } }, + "sort-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-2.0.0.tgz", + "integrity": "sha512-/dPCrG1s3ePpWm6yBbxZq5Be1dXGLyLn9Z791chDC3NFrpkVbWGzkBwPN1knaciexFXgRJ7hzdnwZ4stHSDmjg==", + "dev": true, + "requires": { + "is-plain-obj": "^1.0.0" + }, + "dependencies": { + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==", + "dev": true + } + } + }, "source-list-map": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", @@ -46226,6 +46614,32 @@ "supports-hyperlinks": "^2.0.0" } }, + "terser": { + "version": "5.27.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.27.0.tgz", + "integrity": "sha512-bi1HRwVRskAjheeYl291n3JC4GgO/Ty4z1nVs5AAsmonJulGxpSektecnNedrwK9C7vpvVtcX3cw00VSLt7U2A==", + "dev": true, + "requires": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.8.2", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "dependencies": { + "acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "dev": true + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + } + } + }, "terser-webpack-plugin": { "version": "5.3.9", "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.9.tgz", @@ -46239,18 +46653,6 @@ "terser": "^5.16.8" }, "dependencies": { - "acorn": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz", - "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==", - "dev": true - }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, "schema-utils": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz", @@ -46261,18 +46663,6 @@ "ajv": "^6.12.5", "ajv-keywords": "^3.5.2" } - }, - "terser": { - "version": "5.18.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.18.1.tgz", - "integrity": "sha512-j1n0Ao919h/Ai5r43VAnfV/7azUYW43GPxK7qSATzrsERfW7+y2QW9Cp9ufnRF5CQUWbnLSo7UJokSWCqg4tsQ==", - "dev": true, - "requires": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.8.2", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - } } } }, @@ -47456,12 +47846,6 @@ "@types/node": "*" } }, - "acorn": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz", - "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==", - "dev": true - }, "ajv": { "version": "8.12.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", @@ -47474,12 +47858,6 @@ "uri-js": "^4.2.2" } }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, "estree-walker": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", @@ -47569,18 +47947,6 @@ "has-flag": "^4.0.0" } }, - "terser": { - "version": "5.18.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.18.1.tgz", - "integrity": "sha512-j1n0Ao919h/Ai5r43VAnfV/7azUYW43GPxK7qSATzrsERfW7+y2QW9Cp9ufnRF5CQUWbnLSo7UJokSWCqg4tsQ==", - "dev": true, - "requires": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.8.2", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - } - }, "tr46": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", @@ -47838,6 +48204,68 @@ "typedarray-to-buffer": "^3.1.5" } }, + "write-json-file": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/write-json-file/-/write-json-file-3.2.0.tgz", + "integrity": "sha512-3xZqT7Byc2uORAatYiP3DHUUAVEkNOswEWNs9H5KXiicRTvzYzYqKjYc4G7p+8pltvAw641lVByKVtMpf+4sYQ==", + "dev": true, + "requires": { + "detect-indent": "^5.0.0", + "graceful-fs": "^4.1.15", + "make-dir": "^2.1.0", + "pify": "^4.0.1", + "sort-keys": "^2.0.0", + "write-file-atomic": "^2.4.2" + }, + "dependencies": { + "make-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "dev": true, + "requires": { + "pify": "^4.0.1", + "semver": "^5.6.0" + } + }, + "semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true + }, + "write-file-atomic": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz", + "integrity": "sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + } + } + }, + "write-pkg": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/write-pkg/-/write-pkg-4.0.0.tgz", + "integrity": "sha512-v2UQ+50TNf2rNHJ8NyWttfm/EJUBWMJcx6ZTYZr6Qp52uuegWw/lBkCtCbnYZEmPRNL61m+u67dAmGxo+HTULA==", + "dev": true, + "requires": { + "sort-keys": "^2.0.0", + "type-fest": "^0.4.1", + "write-json-file": "^3.2.0" + }, + "dependencies": { + "type-fest": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.4.1.tgz", + "integrity": "sha512-IwzA/LSfD2vC1/YDYMv/zHP4rDF1usCwllsDpbolT3D4fUepIO7f9K70jjmUewU/LmGUKJcwcVtDCpnKk4BPMw==", + "dev": true + } + } + }, "ws": { "version": "7.5.9", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", @@ -47862,6 +48290,12 @@ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true + }, "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -47886,14 +48320,6 @@ "string-width": "^4.2.0", "y18n": "^5.0.5", "yargs-parser": "^20.2.2" - }, - "dependencies": { - "y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true - } } }, "yargs-parser": { diff --git a/package.json b/package.json index f90f2d2b..d8060578 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,10 @@ "scripts": { "start": "react-scripts start", "build": "NODE_ENV=production BABEL_ENV=production npx rollup -c", + "build:post": "node ./scripts/postBuild.js", "test": "echo \"No test specified\"", "prepare": "echo \"install devDependencies for github install...\"", - "prepack": "rm -rf dist && npm run build", + "prepack": "rm -rf dist && npm run build && npm run build:post", "packTest": "npm pack --dry-run", "eject": "react-scripts eject", "styleguide": "styleguidist server --open", @@ -58,9 +59,11 @@ "devDependencies": { "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^24.1.0", + "@rollup/plugin-dynamic-import-vars": "^2.1.2", "@rollup/plugin-image": "^3.0.2", "@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-replace": "^5.0.2", + "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.0", "@rollup/plugin-url": "^8.0.1", "@svgr/rollup": "^7.0.0", @@ -90,10 +93,12 @@ "rollup": "^3.21.0", "rollup-plugin-dts": "^5.3.0", "rollup-plugin-filesize": "^10.0.0", + "rollup-plugin-generate-package-json": "^3.2.0", "rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-postcss": "^4.0.2", "rollup-plugin-progress": "^1.1.2", "rollup-plugin-typescript2": "^0.34.1", + "rollup-plugin-visualizer": "^5.12.0", "styled-components": "^5.3.10", "tslib": "^2.5.0", "typescript": "^4.9.5" diff --git a/rollup.config.js b/rollup.config.js index 47745dc3..e5149d8a 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -15,6 +15,9 @@ import svgr from '@svgr/rollup'; import typescript from 'rollup-plugin-typescript2'; import replace from '@rollup/plugin-replace'; import resolve from '@rollup/plugin-node-resolve'; +import terser from '@rollup/plugin-terser'; +import generatePackageJson from 'rollup-plugin-generate-package-json'; +import { getFiles } from './scripts/buildUtils.js'; import pkg from './package.json' assert { type: 'json' }; @@ -23,63 +26,130 @@ const dateFnsDirs = fs .readdirSync(path.join(".", "node_modules", "date-fns")) .map((d) => `date-fns/${d}`); +const plugins = [ + peerDepsExternal({ includeDependencies: true }), + progress(), + image(), + url({ + include: [ + '**/*.eot', '**/*.otf', '**/*.ttf', '**/*.woff', '**/*.woff2', + '**/*.png', '**/*.jpg', '**/*.gif' + ], + }), + svgr(), + commonjs({ + include: ['node_modules/**'], + exclude: ['node_modules/process-es6/**'], + }), + postcss({ + modules: true + }), + resolve(), + babel({ + exclude: 'node_modules/**', + babelHelpers: 'runtime' + }), + filesize(), + typescript({ + tsconfig: 'tsconfig.lib.json', + useTsconfigDeclarationDir: true, + }), + replace({ + 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'), + preventAssignment: true, + __IS_DEV__: process.env.NODE_ENV === 'development', + }), + terser(), +]; + +const subfolderPlugins = (folderName) => [ + ...plugins, + generatePackageJson({ + baseContents: { + name: `${pkg.name}/${folderName.toLowerCase()}`, + private: true, + main: "./index.cjs", + module: "./index.mjs", + types: "./index.d.ts", + peerDependencies: pkg.peerDependencies, + version: pkg.version, + }, + outputFolder: `dist/${folderName}/` + }), +]; + +const folderBuilds = fs.readdirSync('./src/@commonsku/styles').map((folder) => { + if (!fs.existsSync(`src/@commonsku/styles/${folder}/index.ts`)) { + return null; + } + + return { + input: `src/@commonsku/styles/${folder}/index.ts`, + output: [{ + file: `dist/${folder}/index.mjs`, + format: 'es', + exports: 'named', + }, { + file: `dist/${folder}/index.cjs`, + format: 'cjs', + exports: 'named', + }], + plugins: subfolderPlugins(folder), + external: Object.keys(pkg.dependencies) + .concat(Object.keys(pkg.peerDependencies)) + .concat(dateFnsDirs) + .concat([/node_modules/]), + }; +}).filter(v => v); + +const folderTypes = fs.readdirSync('./src/@commonsku/styles').map((folder) => { + if (!fs.existsSync(`src/@commonsku/styles/${folder}/index.ts`)) { + return null; + } + + return { + input: `dist/styles/${folder}/index.d.ts`, + output: [{ file: `dist/${folder}/index.d.ts`, format: "es" }], + plugins: [dts()], + }; +}).filter(v => v); + const config = [ + { + input: getFiles('src/@commonsku/utils', ['js', 'ts', 'tsx']), + output: { + dir: 'dist/utils/', + format: 'es', + }, + plugins: plugins, + external: [/node_modules/], + }, { input: 'src/@commonsku/styles/index.ts', output: [{ file: pkg.main, format: 'cjs', - // exports: 'named', - sourcemap: true, + exports: 'named', interop: 'compat', }, { file: pkg.module, format: 'es', - // exports: 'named', - sourcemap: true, + exports: 'named', interop: 'compat', }], - plugins: [ - peerDepsExternal({ includeDependencies: true }), - progress(), - image(), - url({ - include: [ - '**/*.eot', '**/*.otf', '**/*.ttf', '**/*.woff', '**/*.woff2', - '**/*.png', '**/*.jpg', '**/*.gif' - ], - }), - svgr(), - commonjs({ - include: ['node_modules/**'], - exclude: ['node_modules/process-es6/**'], - }), - postcss({ - modules: true - }), - resolve(), - babel({ - exclude: 'node_modules/**', - babelHelpers: 'runtime' - }), - filesize(), - typescript({ - tsconfig: 'tsconfig.lib.json', - }), - replace({ - 'process.env.NODE_ENV': JSON.stringify('production'), - preventAssignment: true, - }), - ], + plugins, external: Object.keys(pkg.dependencies) .concat(Object.keys(pkg.peerDependencies)) - .concat(dateFnsDirs), + .concat(dateFnsDirs) + .concat([/node_modules/]), }, + ...folderBuilds, { input: "dist/styles/index.d.ts", output: [{ file: "dist/index.d.ts", format: "es" }], plugins: [dts()], }, + ...folderTypes, ]; export default config; diff --git a/scripts/buildUtils.js b/scripts/buildUtils.js new file mode 100644 index 00000000..a256dab0 --- /dev/null +++ b/scripts/buildUtils.js @@ -0,0 +1,31 @@ +import fs from 'node:fs'; + +export const getComponentsFolders = (entry) => { + const dirs = fs.readdirSync(entry) + const dirsWithoutIndex = dirs.filter(name => name !== 'index.ts' && name !== 'utils') + return dirsWithoutIndex +}; + +export const getFiles = (entry, extensions = [], excludeExtensions = []) => { + let fileNames = []; + const dirs = fs.readdirSync(entry); + dirs.forEach((dir) => { + const path = `${entry}/${dir}`; + + if (fs.lstatSync(path).isDirectory()) { + fileNames = [ + ...fileNames, + ...getFiles(path, extensions, excludeExtensions), + ]; + + return; + } + + if (!excludeExtensions.some((exclude) => dir.endsWith(exclude)) + && extensions.some((ext) => dir.endsWith(ext)) + ) { + fileNames.push(path); + } + }); + return fileNames; +}; diff --git a/scripts/postBuild.js b/scripts/postBuild.js new file mode 100644 index 00000000..8918b38f --- /dev/null +++ b/scripts/postBuild.js @@ -0,0 +1,45 @@ +import fs from 'node:fs'; +import { resolve, join, basename } from 'node:path'; + +const packagePath = process.cwd(); +const distPath = join(packagePath, './dist'); + +const writeJson = (targetPath, obj) => + fs.writeFileSync(targetPath, JSON.stringify(obj, null, 2), 'utf8'); + +function createPackageFile() { + const packageData = fs.readFileSync(resolve(packagePath, './package.json'), 'utf8'); + const { scripts, devDependencies, ...packageOthers } = JSON.parse(packageData); + const newPackageData = { + ...packageOthers, + private: false, + typings: './index.d.ts', + main: './index.cjs', + module: './index.mjs', + }; + + const targetPath = resolve(distPath, './package.json'); + + writeJson(targetPath, newPackageData); + console.log(`Created package.json in ${targetPath}`); +} + +function includeFileInBuild(file) { + const sourcePath = resolve(packagePath, file); + const targetPath = resolve(distPath, basename(file)); + fs.copyFileSync(sourcePath, targetPath); + console.log(`Copied ${sourcePath} to ${targetPath}`); +} + +function run() { + try { + createPackageFile(); + includeFileInBuild('./README.md'); + // await includeFileInBuild('../../LICENSE'); + } catch (err) { + console.error(err); + process.exit(1); + } +} + +run(); diff --git a/tsconfig.json b/tsconfig.json index f6424941..7d380c80 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,6 +26,7 @@ "strictNullChecks": true, "suppressImplicitAnyIndexErrors": true, "declaration": true, + "declarationDir": "dist", "declarationMap": true, "typeRoots": [ "src/@commonsku/styles/types", diff --git a/tsconfig.lib.json b/tsconfig.lib.json index a75340f9..14e03a2b 100644 --- a/tsconfig.lib.json +++ b/tsconfig.lib.json @@ -26,6 +26,7 @@ "strictNullChecks": true, "suppressImplicitAnyIndexErrors": true, "declaration": true, + "declarationDir": "dist", "declarationMap": true, "typeRoots": [ "src/@commonsku/styles/types", From c28d7002633d294f2fd5f2909f2add0bd64432cb Mon Sep 17 00:00:00 2001 From: Haseeb Ahmad Date: Thu, 1 Feb 2024 16:59:19 -0500 Subject: [PATCH 2/5] clean up scripts --- rollup.config.js | 66 ++++++++++++++++++------------------------- scripts/buildUtils.js | 14 +++++++-- scripts/postBuild.js | 1 - 3 files changed, 38 insertions(+), 43 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index e5149d8a..badf8e53 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -11,16 +11,16 @@ import postcss from 'rollup-plugin-postcss'; import url from '@rollup/plugin-url'; import image from '@rollup/plugin-image'; import svgr from '@svgr/rollup'; -// import typescript from '@rollup/plugin-typescript'; import typescript from 'rollup-plugin-typescript2'; import replace from '@rollup/plugin-replace'; import resolve from '@rollup/plugin-node-resolve'; import terser from '@rollup/plugin-terser'; import generatePackageJson from 'rollup-plugin-generate-package-json'; -import { getFiles } from './scripts/buildUtils.js'; - +import { getFiles, getComponentsFolders } from './scripts/buildUtils.js'; import pkg from './package.json' assert { type: 'json' }; +const STYLES_BASE_PATH = 'src/@commonsku/styles'; + // see https://github.com/Hacker0x01/react-datepicker/issues/1606 const dateFnsDirs = fs .readdirSync(path.join(".", "node_modules", "date-fns")) @@ -66,7 +66,7 @@ const subfolderPlugins = (folderName) => [ ...plugins, generatePackageJson({ baseContents: { - name: `${pkg.name}/${folderName.toLowerCase()}`, + name: `${pkg.name}-${folderName.toLowerCase()}`, private: true, main: "./index.cjs", module: "./index.mjs", @@ -78,41 +78,29 @@ const subfolderPlugins = (folderName) => [ }), ]; -const folderBuilds = fs.readdirSync('./src/@commonsku/styles').map((folder) => { - if (!fs.existsSync(`src/@commonsku/styles/${folder}/index.ts`)) { - return null; - } - - return { - input: `src/@commonsku/styles/${folder}/index.ts`, - output: [{ - file: `dist/${folder}/index.mjs`, - format: 'es', - exports: 'named', - }, { - file: `dist/${folder}/index.cjs`, - format: 'cjs', - exports: 'named', - }], - plugins: subfolderPlugins(folder), - external: Object.keys(pkg.dependencies) - .concat(Object.keys(pkg.peerDependencies)) - .concat(dateFnsDirs) - .concat([/node_modules/]), - }; -}).filter(v => v); - -const folderTypes = fs.readdirSync('./src/@commonsku/styles').map((folder) => { - if (!fs.existsSync(`src/@commonsku/styles/${folder}/index.ts`)) { - return null; - } +const folderBuilds = getComponentsFolders(`./${STYLES_BASE_PATH}`).map((folder) => ({ + input: `${STYLES_BASE_PATH}/${folder}/index.ts`, + output: [{ + file: `dist/${folder}/index.mjs`, + format: 'es', + exports: 'named', + }, { + file: `dist/${folder}/index.cjs`, + format: 'cjs', + exports: 'named', + }], + plugins: subfolderPlugins(folder), + external: Object.keys(pkg.dependencies) + .concat(Object.keys(pkg.peerDependencies)) + .concat(dateFnsDirs) + .concat([/node_modules/]), +})).filter(v => v); - return { - input: `dist/styles/${folder}/index.d.ts`, - output: [{ file: `dist/${folder}/index.d.ts`, format: "es" }], - plugins: [dts()], - }; -}).filter(v => v); +const folderTypes = getComponentsFolders(`./${STYLES_BASE_PATH}`).map((folder) => ({ + input: `dist/styles/${folder}/index.d.ts`, + output: [{ file: `dist/${folder}/index.d.ts`, format: "es" }], + plugins: [dts()], +})).filter(v => v); const config = [ { @@ -125,7 +113,7 @@ const config = [ external: [/node_modules/], }, { - input: 'src/@commonsku/styles/index.ts', + input: `${STYLES_BASE_PATH}/index.ts`, output: [{ file: pkg.main, format: 'cjs', diff --git a/scripts/buildUtils.js b/scripts/buildUtils.js index a256dab0..5a823e9d 100644 --- a/scripts/buildUtils.js +++ b/scripts/buildUtils.js @@ -1,9 +1,17 @@ import fs from 'node:fs'; export const getComponentsFolders = (entry) => { - const dirs = fs.readdirSync(entry) - const dirsWithoutIndex = dirs.filter(name => name !== 'index.ts' && name !== 'utils') - return dirsWithoutIndex + const dirs = fs.readdirSync(entry); + const dirsWithoutIndex = dirs.filter( + name => fs.existsSync(`${entry}/${name}/index.ts`) && (![ + 'utils', + 'types', + 'img', + '.DS_Store', + ].includes(name)) + ); + console.log(dirs); + return dirsWithoutIndex }; export const getFiles = (entry, extensions = [], excludeExtensions = []) => { diff --git a/scripts/postBuild.js b/scripts/postBuild.js index 8918b38f..ed80a0a6 100644 --- a/scripts/postBuild.js +++ b/scripts/postBuild.js @@ -35,7 +35,6 @@ function run() { try { createPackageFile(); includeFileInBuild('./README.md'); - // await includeFileInBuild('../../LICENSE'); } catch (err) { console.error(err); process.exit(1); From 140709a8f15b7338615d889d6d34de63e15205a0 Mon Sep 17 00:00:00 2001 From: Haseeb Ahmad Date: Thu, 1 Feb 2024 17:10:49 -0500 Subject: [PATCH 3/5] removed console.log --- scripts/buildUtils.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/buildUtils.js b/scripts/buildUtils.js index 5a823e9d..c442ef47 100644 --- a/scripts/buildUtils.js +++ b/scripts/buildUtils.js @@ -10,7 +10,6 @@ export const getComponentsFolders = (entry) => { '.DS_Store', ].includes(name)) ); - console.log(dirs); return dirsWithoutIndex }; From 1d54f916eafca1df640b1eb4f3153f0d901c7fce Mon Sep 17 00:00:00 2001 From: Haseeb Ahmad Date: Thu, 1 Feb 2024 17:15:51 -0500 Subject: [PATCH 4/5] refector func getComponentsFolders --- scripts/buildUtils.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/buildUtils.js b/scripts/buildUtils.js index c442ef47..95809cfb 100644 --- a/scripts/buildUtils.js +++ b/scripts/buildUtils.js @@ -1,17 +1,15 @@ import fs from 'node:fs'; -export const getComponentsFolders = (entry) => { - const dirs = fs.readdirSync(entry); - const dirsWithoutIndex = dirs.filter( - name => fs.existsSync(`${entry}/${name}/index.ts`) && (![ +export const getComponentsFolders = (entry) => ( + fs.readdirSync(entry).filter( + dir => fs.existsSync(`${entry}/${dir}/index.ts`) && (![ 'utils', 'types', 'img', '.DS_Store', - ].includes(name)) - ); - return dirsWithoutIndex -}; + ].includes(dir)) + ) +); export const getFiles = (entry, extensions = [], excludeExtensions = []) => { let fileNames = []; From 498d62575aa8f24381730b670040f575e55e90bc Mon Sep 17 00:00:00 2001 From: Haseeb Ahmad Date: Tue, 26 Mar 2024 13:18:44 -0400 Subject: [PATCH 5/5] merged in lastest master --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index e74f3514..2e3bb73d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@commonsku/styles", - "version": "1.17.29", + "version": "1.17.31", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@commonsku/styles", - "version": "1.17.29", + "version": "1.17.31", "license": "ISC", "dependencies": { "@googlemaps/js-api-loader": "^1.16.2",