diff --git a/README.md b/README.md index dc4b9fa432c9890cfae9eea84614b801a031b03a..e3d0deec433b7dc31ab8989b3852f1b0960710a3 100644 --- a/README.md +++ b/README.md @@ -68,10 +68,16 @@ If working on just the viewer, ``npm run watch-viewer`` will provide shorter com Debug/production mode in browsers can be turned on/off during runtime by calling ``setMolStarDebugMode(true/false, true/false)`` from the dev console. -### Force full rebuild +### Cleaning and forcing a full rebuild + npm run clean + +Wipes the `build` and `lib` directories and `.tsbuildinfo` files. + npm run rebuild -Force a full rebuild to resolve build errors that may occassionally arise. Once a force rebuild finishes successfully, incremental `npm run build` can be used again for further builds. +Runs the cleanup script prior to building the project, forcing a full rebuild of the project. + +Use these commands to resolve occassional build failures which may arise after some dependency updates. Once done, `npm run build` should work again. Note that full rebuilds take more to complete. ### Build for production: NODE_ENV=production npm run build diff --git a/package.json b/package.json index 3732b73ae953b5873500ebd36bb008aaae6ca1bd..f9fc29bfae405392fbf3fce5191d7101df7289f4 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,10 @@ "test": "npm run lint && jest", "jest": "jest", "build": "npm run build-tsc && npm run build-extra && npm run build-webpack", - "rebuild": "npm run rebuild-tsc && npm run build-extra && npm run build-webpack", + "clean": "node ./scripts/clean.js", + "rebuild": "npm run clean && npm run build", "build-viewer": "npm run build-tsc && npm run build-extra && npm run build-webpack-viewer", "build-tsc": "concurrently \"tsc --incremental\" \"tsc --build tsconfig.commonjs.json --incremental\"", - "rebuild-tsc": "concurrently \"tsc\" \"tsc --build tsconfig.commonjs.json --incremental\"", "build-extra": "cpx \"src/**/*.{scss,html,ico}\" lib/", "build-webpack": "webpack --mode production --config ./webpack.config.production.js", "build-webpack-viewer": "webpack --mode production --config ./webpack.config.viewer.js", @@ -38,7 +38,7 @@ "volume-server-test": "node lib/commonjs/servers/volume/server.js --idMap em 'test/${id}.mdb' --defaultPort 1336", "plugin-state": "node lib/commonjs/servers/plugin-state/index.js --working-folder ./build/state --port 1339", "preversion": "npm run test", - "version": "npm run build", + "version": "npm run rebuild", "postversion": "git push && git push --tags" }, "files": [ diff --git a/scripts/clean.js b/scripts/clean.js new file mode 100644 index 0000000000000000000000000000000000000000..d1a61e9eccb1449e6c19cba674c3656fda66c9bd --- /dev/null +++ b/scripts/clean.js @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info. + * + * @author Michal MalĂ˝ <malym@ibt.cas.cz> + */ + +const fs = require('fs'); +const path = require('path'); + +const toClean = [ + path.resolve(__dirname, '../build'), + path.resolve(__dirname, '../lib'), + path.resolve(__dirname, '../tsconfig.tsbuildinfo'), +]; + +toClean.forEach(ph => { + if (fs.existsSync(ph)) + fs.rm(ph, { recursive: true }, err => { if (err) console.warn(`Failed to delete ${ph}: ${err}`); }); +});