Build system: add bundling analysis to dev build (#150)
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 14 Feb 2021 08:14:24 +0000 (09:14 +0100)
committerGitHub <noreply@github.com>
Sun, 14 Feb 2021 08:14:24 +0000 (09:14 +0100)
.eslintignore
.gitignore
.prettierignore
package-lock.json
package.json
rollup.config.mjs

index c3af857904ebfd987602da36b219a186a84e4e7a..b7d3d591f81c519fd8a47af9167de549f5e5d3a8 100644 (file)
@@ -1 +1,2 @@
 lib/
+lib.min/
index 2e2848ad7a6cf6c1378b3b30b6923f93185a563b..c918d5dd19c968d7e82cf7dd08f92bc8de7e127e 100644 (file)
@@ -50,3 +50,4 @@ jspm_packages
 .history/
 .scannerwork
 lib
+lib.min
index e40d57b1e25c381fbadae36741e29467be34e9a1..f5df346941e775c00c7b275067df72c9506dd7c8 100644 (file)
@@ -1,3 +1,4 @@
 .nyc_output/
 coverage/
 lib/
+lib.min/
index e376fccbab27bc1598654f470c3262c6d64fc3a2..efed1e62096d6efa27caa84ce398f8199a3c0c69 100644 (file)
       "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==",
       "dev": true
     },
+    "jest-worker": {
+      "version": "26.6.2",
+      "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz",
+      "integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==",
+      "dev": true,
+      "requires": {
+        "@types/node": "*",
+        "merge-stream": "^2.0.0",
+        "supports-color": "^7.0.0"
+      },
+      "dependencies": {
+        "has-flag": {
+          "version": "4.0.0",
+          "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+          "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+          "dev": true
+        },
+        "supports-color": {
+          "version": "7.2.0",
+          "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+          "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+          "dev": true,
+          "requires": {
+            "has-flag": "^4.0.0"
+          }
+        }
+      }
+    },
     "js-tokens": {
       "version": "4.0.0",
       "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
         "mimic-fn": "^3.0.0"
       }
     },
+    "merge-stream": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
+      "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",
+      "dev": true
+    },
     "merge2": {
       "version": "1.4.1",
       "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
         "fsevents": "~2.3.1"
       }
     },
+    "rollup-plugin-analyzer": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/rollup-plugin-analyzer/-/rollup-plugin-analyzer-4.0.0.tgz",
+      "integrity": "sha512-LL9GEt3bkXp6Wa19SNR5MWcvHNMvuTFYg+eYBZN2OIFhSWN+pEJUQXEKu5BsOeABob3x9PDaLKW7w5iOJnsESQ==",
+      "dev": true
+    },
     "rollup-plugin-delete": {
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/rollup-plugin-delete/-/rollup-plugin-delete-2.0.0.tgz",
         "del": "^5.1.0"
       }
     },
+    "rollup-plugin-terser": {
+      "version": "7.0.2",
+      "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz",
+      "integrity": "sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==",
+      "dev": true,
+      "requires": {
+        "@babel/code-frame": "^7.10.4",
+        "jest-worker": "^26.2.1",
+        "serialize-javascript": "^4.0.0",
+        "terser": "^5.0.0"
+      },
+      "dependencies": {
+        "serialize-javascript": {
+          "version": "4.0.0",
+          "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
+          "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==",
+          "dev": true,
+          "requires": {
+            "randombytes": "^2.1.0"
+          }
+        }
+      }
+    },
     "rollup-plugin-typescript2": {
       "version": "0.29.0",
       "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.29.0.tgz",
         }
       }
     },
+    "terser": {
+      "version": "5.6.0",
+      "resolved": "https://registry.npmjs.org/terser/-/terser-5.6.0.tgz",
+      "integrity": "sha512-vyqLMoqadC1uR0vywqOZzriDYzgEkNJFK4q9GeyOBHIbiECHiWLKcWfbQWAUaPfxkjDhapSlZB9f7fkMrvkVjA==",
+      "dev": true,
+      "requires": {
+        "commander": "^2.20.0",
+        "source-map": "~0.7.2",
+        "source-map-support": "~0.5.19"
+      },
+      "dependencies": {
+        "source-map": {
+          "version": "0.7.3",
+          "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz",
+          "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==",
+          "dev": true
+        }
+      }
+    },
     "test-exclude": {
       "version": "6.0.0",
       "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz",
index 529bcf0c68c566ecabb0ec5676e10a835e29a5c3..ff1376dfcf89e311c1bc547d57fabaac2c83ad3c 100644 (file)
@@ -75,7 +75,9 @@
     "prettier-plugin-organize-imports": "^1.1.1",
     "prettierx": "^0.17.0",
     "rollup": "^2.39.0",
+    "rollup-plugin-analyzer": "^4.0.0",
     "rollup-plugin-delete": "^2.0.0",
+    "rollup-plugin-terser": "^7.0.2",
     "rollup-plugin-typescript2": "^0.29.0",
     "sonar-scanner": "^3.1.0",
     "source-map-support": "^0.5.19",
index d35b8c42a00cea7e12e5eaf36f5d1733d048a374..8afbc006de8827bccd162a14d2d3a1d4e33de695 100644 (file)
@@ -1,17 +1,27 @@
 import typescript from 'rollup-plugin-typescript2'
+import analyze from 'rollup-plugin-analyzer'
+import { terser } from 'rollup-plugin-terser'
 import del from 'rollup-plugin-delete'
 
 const isDevelopmentBuild = process.env.BUILD === 'development'
 
 export default {
   input: 'src/index.ts',
-  output: {
-    dir: 'lib',
-    format: 'cjs',
-    sourcemap: !!isDevelopmentBuild,
-    preserveModules: true,
-    preserveModulesRoot: 'src'
-  },
+  output: [
+    {
+      dir: 'lib',
+      format: 'cjs',
+      sourcemap: !!isDevelopmentBuild,
+      preserveModules: true,
+      preserveModulesRoot: 'src'
+    },
+    isDevelopmentBuild && {
+      file: 'lib.min/index.js',
+      format: 'cjs',
+      sourcemap: !!isDevelopmentBuild,
+      plugins: [terser({ numWorkers: 2 })]
+    }
+  ],
   external: ['async_hooks', 'cluster', 'events', 'worker_threads'],
   plugins: [
     typescript({
@@ -20,7 +30,8 @@ export default {
         : 'tsconfig.json'
     }),
     del({
-      targets: 'lib/*'
-    })
+      targets: ['lib/*', 'lib.min/*']
+    }),
+    isDevelopmentBuild && analyze()
   ]
 }