Skip to content

Commit

Permalink
Make scratch-run much faster
Browse files Browse the repository at this point in the history
- Use TurboWarp/scratch-vm
- Adopt bundling config from TurboWarp/packager
  • Loading branch information
hieplpvip committed Jan 3, 2024
1 parent 4487e8a commit 0b9885e
Show file tree
Hide file tree
Showing 12 changed files with 2,040 additions and 6,612 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/*.zip
path: bin/*.zip
- name: Upload to Release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/*.zip
file: bin/*.zip
tag: ${{ github.ref }}
file_glob: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
build
bin
dist
13 changes: 9 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
NODE_VERSION=16.16.0

VERSION=$(node -p -e "require('./package.json').version")
BUILD_CMD="npx pkg index.js --no-bytecode --public-packages \"*\" --public"
BUILD_CMD="npx pkg ../dist/index.js"

rm -rf build && mkdir build && cd build
rm -rf bin dist
npx webpack

npx ncc build ../index.js --minify --out .
echo "(()=>require(\"text-encoding\"))();" >> index.js # Hack to force inclusion of text-encoding
TEXT_ENCODING_FIND="function(module,exports){eval('module.exports = require(\"text-encoding\")"
TEXT_ENCODING_REPL="function(module,exports,__webpack_require__){eval('module.exports = __webpack_require__(\"text-encoding\")"
sed -i s/"$TEXT_ENCODING_FIND"/"$TEXT_ENCODING_REPL"/g dist/index.js

mkdir bin
cd bin

# Linux amd64
$BUILD_CMD -t node"$NODE_VERSION"-linux-x64 --out-path linux-amd64
Expand Down
Loading

0 comments on commit 0b9885e

Please sign in to comment.