2022-04-17 13:53:47 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# From your clone of next.js, you can invoke this script like
|
|
|
|
#
|
|
|
|
# /absolute/path/to/this/script.sh examples/foo
|
|
|
|
#
|
|
|
|
# This script will
|
|
|
|
#
|
|
|
|
# - build native binary (`next-swc`)
|
|
|
|
# - install dependnecies using `yarn``
|
|
|
|
# - remove some dependencies (`next`, `react`, `react-dom`)
|
|
|
|
# - yarn next build examples/foo
|
|
|
|
# - yarn next start examples/foo
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
|
|
|
|
|
|
dir="$1"
|
2022-04-19 12:14:15 +03:00
|
|
|
nextJsDir="$(pwd)"
|
2022-04-17 13:53:47 +03:00
|
|
|
|
|
|
|
# Ensure that next-swc is up to date
|
2022-04-20 16:34:21 +03:00
|
|
|
echo "----- ⚠️ Building next-swc"
|
2022-04-17 13:53:47 +03:00
|
|
|
(cd ./packages/next-swc && yarn build-native)
|
|
|
|
|
|
|
|
# Install dependencies
|
2022-04-20 16:34:21 +03:00
|
|
|
echo "----- ⚠️ Installing dependencies"
|
|
|
|
if [ ! -d "$dir/node_modules" ]; then
|
|
|
|
if test -f "$dir/yarn.lock"; then
|
|
|
|
echo " Using yarn"
|
|
|
|
# (cd $dir && yarn)
|
|
|
|
else
|
|
|
|
echo " Using yarn"
|
|
|
|
# (cd $dir && npm ci)
|
|
|
|
fi
|
2022-04-19 12:14:15 +03:00
|
|
|
fi
|
2022-04-17 13:53:47 +03:00
|
|
|
|
2022-04-20 16:34:21 +03:00
|
|
|
|
|
|
|
echo "----- ⚠️ Removing cache"
|
|
|
|
(cd $dir && rm -rf .next)
|
|
|
|
|
|
|
|
echo "----- ⚠️ Replacing swc binary"
|
2022-04-30 10:00:21 +03:00
|
|
|
mv packages/next-swc/native/*.node $dir/node_modules/@next/swc-*/
|
|
|
|
ls -alh $dir/node_modules/@next/swc-*/
|
2022-04-17 13:53:47 +03:00
|
|
|
|
|
|
|
# Build and start
|
2022-04-20 16:34:21 +03:00
|
|
|
echo "----- ⚠️ Building the app using next"
|
|
|
|
(cd $dir && npx next build)
|
|
|
|
(cd $dir && npx next start)
|