Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## 0.1.0
## 1.0.0

First published release.

Expand All @@ -16,7 +16,7 @@ surprised by it.

### Fixed before publishing

Two things that would each have made this release wrong.
Three things that would each have made this release wrong.

The binary shipped Helvetica, baked into `viro-web.data` by the preload step and
therefore redistributed with the package. It renders in **Roboto** now, which is
Expand All @@ -30,6 +30,15 @@ existed in `types.ts` and in no build. Every one of them would have been
`undefined` at runtime. Rebuilt from virocore; the package's own test now
checks all 126, and that the preloaded font is one this package may ship.

And the glue module could not be bundled by Metro. `loadViroWebModule` reached
it through a variable specifier, which Metro refuses at build time, and the
`webpackIgnore` comment that was there to excuse it is stripped by
`babel-preset-expo` before Metro's dependency collector runs. So an Expo web app
did not fail at runtime against this package, it failed to build at all. The
import goes through an indirection now, which no bundler parses. That
indirection needs `unsafe-eval`, so a page under a strict CSP should pass
`importGlue` instead.

### Added

- **The tracking engine ships with the package.** Web AR needed a second WASM
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reactvision/viro-web-renderer",
"version": "0.1.0",
"version": "1.0.0",
"description": "WebAssembly/WebGL2 build of the Viro renderer (virocore) for the web platform",
"license": "MIT",
"author": "ReactVision",
Expand Down
11 changes: 8 additions & 3 deletions src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function resolveAssetBase(baseUrl?: string): string {
/**
* Load and instantiate the WASM renderer module.
*
* The Emscripten glue (viro-web.js) is imported dynamically so bundlers treat it
* as an async chunk and the ~2MB payload is only fetched on demand. The
* The Emscripten glue (viro-web.js) is fetched from the asset base at runtime
* rather than bundled, so the ~2MB payload is only paid for on demand. The
* .wasm/.data sidecars are located from the same base (see resolveAssetBase).
*/
export interface LoadOptions {
Expand All @@ -50,7 +50,12 @@ export async function loadViroWebModule(
imported = await opts.importGlue();
} else {
const glueUrl = base + "viro-web.js";
imported = await import(/* webpackIgnore: true */ /* @vite-ignore */ glueUrl);
// Indirect so no bundler parses a non-literal import(). Metro rejects one
// outright, and strips the webpackIgnore comment before it would help.
const importModule = new Function("u", "return import(u)") as (
u: string,
) => Promise<{ default?: ViroWebModuleFactory } | ViroWebModuleFactory>;
imported = await importModule(glueUrl);
}

const factory = ((imported as { default?: ViroWebModuleFactory }).default ??
Expand Down
Loading