Skip to content

Commit

Permalink
js: Fix interaction between ES6 modules and meshopt_decoder.js
Browse files Browse the repository at this point in the history
meshopt_decoder.js used a UMD-style export copied from Emscripten that
didn't support ES6 modules, so attempts to import the .js file would
fail.

It doesn't look like there's a good way to make exports fully work
without having a separate .js file, as `export {}` statement can't be
conditional on the support of ES6 syntax.

So the next best thing appears to be to explicitly inject the value into
the global scope, which this change now does.

Also fix README.md for gltfpack to use import code that actually works.
  • Loading branch information
zeux committed Jun 14, 2020
1 parent 9e89bf3 commit 9c67eea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gltf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ gltfpack can also compress textures using Basis Universal format, either storing
When using compressed files, [js/meshopt_decoder.js](https://github.com/zeux/meshoptimizer/blob/master/js/meshopt_decoder.js) needs to be loaded to provide the WebAssembly decoder module like this:

```js
import MeshoptDecoder from "./meshopt_decoder";
import './meshopt_decoder.js'; // imports MeshoptDecoder using ES6

...

Expand Down
2 changes: 2 additions & 0 deletions js/meshopt_decoder.js

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

0 comments on commit 9c67eea

Please sign in to comment.