Bläddra i källkod

HUE-8687 [frontend] Add automatic bundle cleaning when running "npm run dev"

Johan Ahlen 6 år sedan
förälder
incheckning
2de3fa5
4 ändrade filer med 82 tillägg och 5 borttagningar
  1. 1 1
      ext/thirdparty/README.md
  2. 74 0
      package-lock.json
  3. 5 4
      package.json
  4. 2 0
      webpack.config.js

+ 1 - 1
ext/thirdparty/README.md

@@ -189,11 +189,11 @@ Frontend third party dependencies (some checked in and some via npm)
 |TopoJSON|1.0.0|BSD|https://github.com/topojson/topojson|
 |TotalStorage|1.1.3|MIT|https://github.com/Upstatement/jquery-total-storage|
 |TouchSwipe|1.6.18|MIT|https://github.com/mattbryson/TouchSwipe-Jquery-Plugin|
-|TouchSwipe|1.6.18|MIT|https://github.com/mattbryson/TouchSwipe-Jquery-Plugin|
 |tzdetect.js|?|MIT|https://github.com/Canop/tzdetect.js|
 |Webpack|4.29.0|MIT|https://www.npmjs.com/package/webpack|
 |Webpack Bundel Tracker|0.4.2-beta|MIT|https://www.npmjs.com/package/webpack-bundle-tracker|
 |Webpack cli|3.2.1|MIT|https://www.npmjs.com/package/webpack-cli|
 |Webpack clean plugin|1.0.1|MIT|https://www.npmjs.com/package/clean-webpack-plugin|
+|Webpack Clean Obsolete Chunks plugin|0.4.0|MIT|https://github.com/GProst/webpack-clean-obsolete-chunks|
 |wysihtml5|0.3.0|MIT|https://github.com/xing/wysihtml5|
 |X-editable|1.5.1|MIT|http://github.com/vitalets/x-editable|"

+ 74 - 0
package-lock.json

@@ -2843,6 +2843,20 @@
         }
       }
     },
+    "del": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/del/-/del-3.0.0.tgz",
+      "integrity": "sha1-U+z2mf/LyzljdpGrE7rxYIGXZuU=",
+      "dev": true,
+      "requires": {
+        "globby": "^6.1.0",
+        "is-path-cwd": "^1.0.0",
+        "is-path-in-cwd": "^1.0.0",
+        "p-map": "^1.1.1",
+        "pify": "^3.0.0",
+        "rimraf": "^2.2.8"
+      }
+    },
     "delayed-stream": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
@@ -4490,6 +4504,27 @@
       "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==",
       "dev": true
     },
+    "globby": {
+      "version": "6.1.0",
+      "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz",
+      "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=",
+      "dev": true,
+      "requires": {
+        "array-union": "^1.0.1",
+        "glob": "^7.0.3",
+        "object-assign": "^4.0.1",
+        "pify": "^2.0.0",
+        "pinkie-promise": "^2.0.0"
+      },
+      "dependencies": {
+        "pify": {
+          "version": "2.3.0",
+          "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
+          "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
+          "dev": true
+        }
+      }
+    },
     "globule": {
       "version": "1.2.1",
       "resolved": "https://registry.npmjs.org/globule/-/globule-1.2.1.tgz",
@@ -5321,6 +5356,30 @@
         }
       }
     },
+    "is-path-cwd": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz",
+      "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=",
+      "dev": true
+    },
+    "is-path-in-cwd": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz",
+      "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==",
+      "dev": true,
+      "requires": {
+        "is-path-inside": "^1.0.0"
+      }
+    },
+    "is-path-inside": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz",
+      "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=",
+      "dev": true,
+      "requires": {
+        "path-is-inside": "^1.0.1"
+      }
+    },
     "is-plain-object": {
       "version": "2.0.4",
       "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
@@ -6475,6 +6534,12 @@
         "p-limit": "^2.0.0"
       }
     },
+    "p-map": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/p-map/-/p-map-1.2.0.tgz",
+      "integrity": "sha512-r6zKACMNhjPJMTl8KcFH4li//gkrXWfbD6feV8l6doRHlzljFWGJ2AP6iKaCJXyZmAUMOPtvbW7EXkbWO/pLEA==",
+      "dev": true
+    },
     "p-try": {
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz",
@@ -8703,6 +8768,15 @@
         }
       }
     },
+    "webpack-clean-obsolete-chunks": {
+      "version": "0.4.0",
+      "resolved": "https://registry.npmjs.org/webpack-clean-obsolete-chunks/-/webpack-clean-obsolete-chunks-0.4.0.tgz",
+      "integrity": "sha512-VSaM/iVkbtRgp3mBIHfuZ0Pm/ekWL3jR5b55+dOnlon77hkBsNfuylkz9UqvUPA1AIljrbtiFpdRuoDtu7v5/A==",
+      "dev": true,
+      "requires": {
+        "del": "^3.0.0"
+      }
+    },
     "webpack-cli": {
       "version": "3.2.1",
       "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.2.1.tgz",

+ 5 - 4
package.json

@@ -39,18 +39,19 @@
     "sprintf-js": "1.1.2"
   },
   "devDependencies": {
-    "architect-build": "0.1.1",
     "@babel/core": "7.2.2",
     "@babel/preset-env": "7.3.1",
+    "architect-build": "0.1.1",
     "babel-cli": "6.26.0",
     "babel-eslint": "10.0.1",
     "babel-jscs": "3.0.0-beta1",
     "babel-loader": "8.0.5",
+    "clean-webpack-plugin": "1.0.1",
+    "dryice": "0.4.11",
     "eslint": "5.12.1",
     "eslint-config-prettier": "4.0.0",
     "eslint-plugin-prettier": "3.0.1",
     "expose-loader": "0.7.5",
-    "dryice": "0.4.11",
     "grunt": "1.0.3",
     "grunt-contrib-less": "2.0.0",
     "grunt-contrib-uglify": "4.0.0",
@@ -59,8 +60,8 @@
     "prettier": "1.16.1",
     "webpack": "4.29.0",
     "webpack-bundle-tracker": "0.4.2-beta",
-    "webpack-cli": "^3.2.1",
-    "clean-webpack-plugin": "1.0.1"
+    "webpack-clean-obsolete-chunks": "^0.4.0",
+    "webpack-cli": "^3.2.1"
   },
   "scripts": {
     "devinstall": "npm cache clean && npm install && npm prune",

+ 2 - 0
webpack.config.js

@@ -1,6 +1,7 @@
 const webpack = require('webpack');
 const BundleTracker = require('webpack-bundle-tracker');
 const CleanWebpackPlugin = require('clean-webpack-plugin');
+var CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');
 
 module.exports = {
   devtool: 'source-map',
@@ -47,6 +48,7 @@ module.exports = {
 
   plugins: [
     // new WebpackShellPlugin({ onBuildStart:[__dirname + '/tools/scripts/clean_js_bundles.sh ' +  __dirname ] }),
+    new CleanObsoleteChunks(),
     new CleanWebpackPlugin([__dirname + '/desktop/core/src/desktop/static/desktop/js/bundles']),
     new BundleTracker({ filename: './webpack-stats.json' }),
     new webpack.BannerPlugin('\nLicensed to Cloudera, Inc. under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  Cloudera, Inc. licenses this file\nto you under the Apache License, Version 2.0 (the\n"License"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n')