Skip to content

Commit

Permalink
fix: rollback to old build system to fix #37 and to keep the small bu…
Browse files Browse the repository at this point in the history
…ild size
  • Loading branch information
matubu committed Aug 6, 2023
1 parent 9b60f09 commit f61d49b
Show file tree
Hide file tree
Showing 74 changed files with 130 additions and 105 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

in_dir=./src
out_dir=./dist

esbuild_system=esbuild-linux-64
[ "$(uname)" == "Darwin" ] && esbuild_system=esbuild-darwin-64

esbuild_version=0.14.28
esbuild=$esbuild_system-$esbuild_version
esbuild_bin=./package/bin/esbuild
esbuild_options="--bundle --minify"

minify_file () {
# arguments:
# 1- input file
# minify a file from in_dir/... to out_dir/...

set -e

file=$1
out=${file/${in_dir}/${out_dir}}
mkdir -p $(dirname $out)
$esbuild_bin $file $esbuild_options --format=esm --target=es2019 --outfile=$out

[[ $file == *.css ]] && return
node=${file/${in_dir}/"${out_dir}/node"}
mkdir -p $(dirname $node)
$esbuild_bin $file $esbuild_options --format=cjs --platform=node --target=node12 --outfile=$node
}

[ ! -f $esbuild.tgz ] && curl -O https://registry.npmjs.org/$esbuild_system/-/$esbuild.tgz
[ ! -f $esbuild_bin ] && tar xf ./$esbuild.tgz

rm -rf $out_dir

for file in $(find $in_dir \( -name "*.js" -o -name "*.css" \) -type f); do
minify_file $file &
done

for pid in $(jobs -p); do
wait $pid || (wait && echo -e "\n\033[91mError: could not minify some files\033[0m" && exit 1)
done

cp src/*.d.ts dist
cp src/*.d.ts dist/node

exit 0
2 changes: 1 addition & 1 deletion dist/detect.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/languages/bash.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/languages/docker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/languages/git.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/languages/html.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/languages/http.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/languages/js_template_literals.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/languages/jsdoc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/languages/json.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
var a=[{type:"var",match:/("|')?[a-zA-Z]\w*\1(?=\s*:)/g},{expand:"str"},{expand:"num"},{type:"num",match:/\bnull\b/g},{type:"bool",match:/\b(true|false)\b/g}];export{a as default};
var t=[{type:"var",match:/("|')?[a-zA-Z]\w*\1(?=\s*:)/g},{expand:"str"},{expand:"num"},{type:"num",match:/\bnull\b/g},{type:"bool",match:/\b(true|false)\b/g}];export{t as default};
Loading

0 comments on commit f61d49b

Please sign in to comment.