2018-11-21 14:22:31 +00:00
|
|
|
# To be invoked with PACKAGENAME/lib/FOO.js or PACKAGENAME/dist/FOO.js
|
2018-11-07 00:18:41 +00:00
|
|
|
targettempfile="$(pwd)/$3"
|
|
|
|
mkdir -p "$(dirname "$1")"
|
|
|
|
cd "$(dirname "$1")"/..
|
|
|
|
case "$1" in
|
|
|
|
syntax/lib/babel_parser.js)
|
2020-06-10 10:42:44 +00:00
|
|
|
src=../../node_modules/@babel/parser/lib/index.js
|
2018-11-07 00:18:41 +00:00
|
|
|
[ -f "$src" ] || npm -i .
|
|
|
|
redo-ifchange "$src" babel_parser_suffix.js
|
|
|
|
cat "$src" babel_parser_suffix.js
|
|
|
|
;;
|
|
|
|
syntax/lib/*)
|
|
|
|
file=$(basename "$1")
|
|
|
|
redo-ifchange "src/$file"
|
2020-06-10 10:42:44 +00:00
|
|
|
../../node_modules/.bin/babel "src/$file"
|
2018-11-07 00:18:41 +00:00
|
|
|
;;
|
|
|
|
*/lib/*)
|
|
|
|
redo-ifchange ../syntax/all
|
|
|
|
file=$(basename "$1")
|
|
|
|
redo-ifchange "src/$file"
|
2018-12-13 20:19:35 +00:00
|
|
|
if [ -n "$SYNDICATE_COMPILE_SERVER" ]
|
|
|
|
then
|
2018-12-24 11:35:06 +00:00
|
|
|
if curl -fs --data-binary "@src/$file" ${SYNDICATE_COMPILE_SERVER}/"$file" \
|
2018-12-13 20:19:35 +00:00
|
|
|
> ${targettempfile} 2>/dev/null
|
|
|
|
then
|
|
|
|
:
|
|
|
|
else
|
2018-12-24 11:35:06 +00:00
|
|
|
# I can't figure out a way to get curl to both exit on
|
|
|
|
# error, and print the response body on error. So
|
|
|
|
# instead we try once, discarding the output but
|
|
|
|
# keeping the exit status, and if it fails, we try
|
|
|
|
# again, keeping the output but discarding the exit
|
|
|
|
# status.
|
|
|
|
curl -s --data-binary "@src/$file" ${SYNDICATE_COMPILE_SERVER}/"$file" >&2
|
2018-12-13 20:19:35 +00:00
|
|
|
rm -f ${targettempfile}
|
2018-12-24 11:35:06 +00:00
|
|
|
false
|
2018-12-13 20:19:35 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
npx syndicate-babel "src/$file"
|
|
|
|
fi
|
2018-11-07 00:18:41 +00:00
|
|
|
;;
|
|
|
|
*/dist/*)
|
2018-11-21 17:02:05 +00:00
|
|
|
# Conservatively assume the distribution depends on ALL the
|
|
|
|
# local source files PLUS the lib/*.js of dependent syndicate
|
|
|
|
# packages, other than core which has src/*.js files instead.
|
|
|
|
#
|
|
|
|
for d in src/*.js; do echo lib/$(basename $d); done | xargs redo-ifchange
|
|
|
|
for dep in $(cat package.json | \
|
|
|
|
jq -r '.dependencies | to_entries[].key' | \
|
|
|
|
fgrep '@syndicate-lang/' | \
|
|
|
|
sed -e 's:^@syndicate-lang/::')
|
|
|
|
do
|
|
|
|
for srcfile in ../$dep/src/*.js
|
|
|
|
do
|
|
|
|
if [ -f $srcfile ]
|
|
|
|
then
|
|
|
|
if [ "$dep" = "core" ]
|
|
|
|
then
|
|
|
|
echo $srcfile
|
|
|
|
else
|
|
|
|
libfile=$(echo $srcfile | sed -e 's:/src/:/lib/:')
|
|
|
|
echo $libfile
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2018-11-26 18:37:08 +00:00
|
|
|
done | xargs redo-ifchange
|
2018-11-21 14:22:31 +00:00
|
|
|
configfile=$(basename "$1" .js).webpack.config.js
|
|
|
|
redo-ifchange $configfile
|
2020-06-10 10:42:44 +00:00
|
|
|
for maybedep in $(../../node_modules/.bin/webpack --config "$configfile" --json -o "$targettempfile" | jq -r '.modules[].identifier')
|
2018-11-07 00:18:41 +00:00
|
|
|
do
|
|
|
|
[ -f "$maybedep" ] && echo "$maybedep"
|
|
|
|
done | xargs redo-ifchange
|
|
|
|
;;
|
|
|
|
esac
|