Created
December 8, 2017 02:54
-
-
Save turadg/16399a5cef8c8c9905dad0d7e8dda3c0 to your computer and use it in GitHub Desktop.
Find in webpack builds modules that are never imported
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Testing prod build for modules in src that aren't ever imported." | |
echo | |
echo "NOTE: Any dev-only imports will appear to be unused." | |
USED_LIST_PATH=usedModules.txt | |
STATS_PATH=public/assets/stats.json | |
if [ ! -e $USED_LIST_PATH ]; then | |
echo Building module stats | |
yarn build-prod | |
jq .modules[].name $STATS_PATH |tr -d '"' > $USED_LIST_PATH | |
fi | |
SELECT_RE=".*\.(jsx?|s?css)$" | |
src_modules=`find -E src -regex $SELECT_RE | grep -v -E "__tests__|mocks|dev|fixtures|mixins"` | |
echo "These modules are never built into Webpack:" | |
for module in $src_modules ; do | |
grep --quiet $module usedModules.txt | |
if [[ $? != 0 ]]; then | |
echo $module | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment