Skip to content

Commit

Permalink
chore: 🤖 refine loaders in meson build for ThorVG (#50)
Browse files Browse the repository at this point in the history
* chore: 🤖 refine loaders in meson build for ThorVG

* chore: 🤖 add changesets

* chore: 🤖 size-limit for *.wasm files

* chore: 🤖 simplify the size-limit config
  • Loading branch information
theashraf authored Nov 20, 2023
1 parent 82830d2 commit bff25d3
Show file tree
Hide file tree
Showing 8 changed files with 514 additions and 784 deletions.
5 changes: 5 additions & 0 deletions .changeset/selfish-jeans-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lottiefiles/dotlottie-web': patch
---

chore: 🤖 refine loaders in meson build for ThorVG
39 changes: 16 additions & 23 deletions .size-limit.cjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
const fs = require('fs');
const path = require('path');

const packagesDir = path.join(__dirname, 'packages');
const packageDirs = fs.readdirSync(packagesDir);

const packages = packageDirs
.map((dir) => {
const packageJsonPath = path.join(packagesDir, dir, 'package.json');

if (fs.existsSync(packageJsonPath)) {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));

return {
name: packageJson.name,
path: path.join(__dirname, packageJson.repository.directory, packageJson.module),
import: '*',
const dotLottieWebConfig = [
{
name: '@lottiefiles/dotlottie-web',
path: 'packages/web/dist/index.js',
import: '{ DotLottie }',
},
{
name: '@lottiefiles/dotlottie-web WASM',
path: 'packages/web/dist/*.wasm',
modifyWebpackConfig: (config) => {
config.experiments = {
asyncWebAssembly: true,
};
}

return null;
})
.filter(Boolean);
},
},
];

module.exports = packages;
module.exports = [...dotLottieWebConfig];
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"release:publish": "pnpm clean && pnpm build && changeset publish",
"release:version": "changeset version",
"size": "size-limit",
"size:why": "size-limit --why --clean-dir --save-bundle ./tmp",
"stats:eslint": "cross-env TIMING=1 turbo run stats:eslint",
"stats:ts": "turbo run stats:ts",
"test": "turbo run test",
Expand All @@ -43,9 +42,7 @@
"@lottiefiles/prettier-config": "3.0.0",
"@lottiefiles/remark-preset": "1.0.0",
"@lottiefiles/tsconfig": "2.0.0",
"@size-limit/esbuild": "^11.0.0",
"@size-limit/esbuild-why": "^11.0.0",
"@size-limit/preset-small-lib": "^10.0.2",
"@size-limit/preset-big-lib": "^10.0.2",
"cross-env": "7.0.3",
"eslint": "7.32.0",
"husky": "8.0.3",
Expand Down
12 changes: 6 additions & 6 deletions packages/web/build_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ git fetch origin
git checkout "$THORVG_TAG_OR_BRANCH"
check_command_success "Error switching to the desired tag/branch: $THORVG_TAG_OR_BRANCH"

# Run the wasm build script with the provided EMSDK path
./wasm_build.sh "$EMSDK_PATH"
check_command_success "Error running wasm_build.sh"
sed "s|EMSDK:|$EMSDK_PATH|g" wasm_cross.txt > /tmp/.wasm_cross.txt
meson -Db_lto=true -Ddefault_library=static -Dstatic=true -Dloaders="lottie, png, jpg" --cross-file /tmp/.wasm_cross.txt build_wasm
ninja -C build_wasm/

# Change back to the parent directory
cd "$DIR"
Expand All @@ -82,9 +82,9 @@ TMPFILE=$(mktemp /tmp/wasm_cross.XXXXXX)
# Ensure the temp file is always cleaned up on exit
trap 'rm -f "$TMPFILE"' EXIT

# Substitute the EMSDK path in the wasm_x86_i686.txt file and save to the temporary file
sed "s|EMSDK:|$EMSDK_PATH|g" "$DIR/wasm_x86_i686.txt" > "$TMPFILE"
check_command_success "Error substituting EMSDK path in wasm_x86_i686.txt"
# Substitute the EMSDK path in the wasm_cross.txt file and save to the temporary file
sed "s|EMSDK:|$EMSDK_PATH|g" "$DIR/wasm_cross.txt" > "$TMPFILE"
check_command_success "Error substituting EMSDK path in wasm_cross.txt"

# Setup meson build with the cross file
meson --cross-file "$TMPFILE" src/renderer-wasm/bin
Expand Down
Loading

0 comments on commit bff25d3

Please sign in to comment.