1
0
mirror of https://github.com/c9fe/22120.git synced 2024-08-18 23:29:45 +02:00
22120/scripts/old_compile.sh
Cris Stringfellow 3e8d2ebae9
create
2023-01-15 02:07:52 +08:00

49 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
unset npm_config_prefix
source $HOME/.nvm/nvm.sh
. $HOME/.profile
nvm use --lts
echo "Cleaning old build and dist files..."
rm -rf build/* dist/*
echo "Setting build (CJS) mode..."
./scripts/go_build.sh
patch_required=$(grep -ER "require\([\"'](node:)?stream/web[\"']\)" node_modules/*)
files=$(grep -rlER "require\([\"'](node:)?stream/web[\"']\)" node_modules/*)
if [[ ! -z "$patch_required" ]]; then
while IFS= read -r file; do
#echo '--->' $file
#grep -q $file package.json
#if [ $? == 1 ]; then
echo '--->' $file "UNPATCHED!"
echo "Found an error!"
echo "Found something you need to patch before building"
echo "See: https://github.com/vercel/pkg/issues/1451"
echo
echo "$patch_required"
echo
echo "You need to add all these to pkg.patches to replace with require('stream').web"
./scripts/go_dev.sh
exit 1
#fi
#echo "OK"
done <<< $files
fi
echo "Bundling javascript..."
export NODE_ENV='production'
npx webpack
chmod +x ./build/22120.js
echo "Building for windows nix and macos..."
npx pkg --compress Gzip .
echo "Restoring dev (ES module) mode..."
./scripts/go_dev.sh
echo "Rebundling an es module for npm es module import..."
npm run bundle