Skip to content

Add configurable WASM URL for browser bundler compatibility#143

Merged
slimbuck merged 1 commit intoplaycanvas:mainfrom
slimbuck:wasm-dev
Jan 14, 2026
Merged

Add configurable WASM URL for browser bundler compatibility#143
slimbuck merged 1 commit intoplaycanvas:mainfrom
slimbuck:wasm-dev

Conversation

@slimbuck
Copy link
Member

Add configurable WASM URL for browser bundler compatibility

This PR enables browser-based bundlers (Vite, Webpack, etc.) to properly locate and bundle the WebP WASM file by:

  • Exporting the WebPCodec class from the public API
  • Adding a static wasmUrl property to configure the WASM file path
  • Adding a package export for the lib/ directory to allow direct WASM imports

Changes

  • WebPCodec.wasmUrl: New static property to configure the WASM file URL before SOG read/write operations
  • Package exports: Added ./lib/* export mapping for direct access to webp.wasm

Usage

For bundlers that require explicit WASM URL handling:

import { WebPCodec } from '@playcanvas/splat-transform';
import wasmUrl from '@playcanvas/splat-transform/lib/webp.wasm?url';

WebPCodec.wasmUrl = wasmUrl;

This should be called once at application startup, before any SOG file operations.

@slimbuck slimbuck requested review from a team and Copilot January 14, 2026 18:05
@slimbuck slimbuck self-assigned this Jan 14, 2026
@slimbuck slimbuck added the bug Something isn't working label Jan 14, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds configurable WASM URL support to enable browser bundlers (Vite, Webpack, etc.) to properly locate and bundle the WebP WASM file. The solution exports the WebPCodec class publicly and adds a static wasmUrl property that can be set before SOG operations.

Changes:

  • Added a public wasmUrl static property to WebPCodec class for configuring WASM file location
  • Exported WebPCodec class from the library's public API
  • Added ./lib/* export mapping in package.json for direct access to WASM files

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/lib/utils/webp-codec.ts Added static wasmUrl property and modified locateFile logic to use it when available
src/lib/index.ts Exported WebPCodec class from public API
package.json Added ./lib/* export mapping for direct WASM file imports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@slimbuck slimbuck merged commit b05ad5a into playcanvas:main Jan 14, 2026
8 checks passed
@slimbuck slimbuck deleted the wasm-dev branch January 14, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants