Skip to content

Commit

Permalink
fixes build error while building with node >= 18
Browse files Browse the repository at this point in the history
__This is a temporary fix__

Any machine building with node >= 18 runs into this issue:
unfoldingWord/translation-helps-rcl#121

I've modified the build scripts to use the set-env.sh scripts
to determine what the NODE_OPTIONS should be when building.
  • Loading branch information
theNerd247 committed Nov 29, 2023
1 parent 1671611 commit fa43758
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "gateway-edit",
"version": "2.1.0",
"scripts": {
"dev": "bash -c \"source ./scripts/set-env.sh && cross-env NODE_OPTIONS=--max_old_space_size=4096 next\"",
"build": "bash -c \"source ./scripts/set-env.sh && cross-env NODE_OPTIONS=--max_old_space_size=4096 next build\"",
"start": "bash -c \"source ./scripts/set-env.sh && cross-env NODE_OPTIONS=--max_old_space_size=4096 next start\"",
"dev": "bash -c \"source ./scripts/set-env.sh && next\"",
"build": "bash -c \"source ./scripts/set-env.sh && next build\"",
"start": "bash -c \"source ./scripts/set-env.sh && next start\"",
"export": "next export",
"postinstall": "husky install",
"increment-build": "bash scripts/increment-build.sh && git add -A",
Expand Down
27 changes: 26 additions & 1 deletion scripts/set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,29 @@ set_env_var $ENV_FILE NEXT_PUBLIC_BUILD_NUMBER $BUILD_NUMBER
set_env_var $ENV_FILE NEXT_PUBLIC_BUILD_BRANCH $BRANCH
set_env_var $ENV_FILE NEXT_PUBLIC_BUILD_CONTEXT $CONTEXT

echo "Environment file new contents: $(cat $ENV_FILE)"
echo "Environment file new contents: $(cat $ENV_FILE)"

function semMajorVersion() {
sed -Ee 's/^v([0-9]+)\..*$/\1/'
}

function nodeOptions() {
nodeMajorVersion=$(node --version | semMajorVersion)

maxOldSpaceSize="--max_old_space_size=4096"
openSSLLegacyProvider="--openssl-legacy-provider"

if [[ $nodeMajorVersion -gt "16" ]]; then
echo "$maxOldSpaceSize $openSSLLegacyProvider"
else
echo "$maxOldSpaceSize"
fi
}

# NOTE: This code and its transcient dependencies will
# not be needed once we upgrade node verions universally.

# export these variable so that the process executed
# in the package.json.scripts file will inherit them
export NODE_OPTIONS="$(nodeOptions)"

0 comments on commit fa43758

Please sign in to comment.