Skip to content

Commit

Permalink
Ensure compatibility with Firefox
Browse files Browse the repository at this point in the history
By removing the EXPORT_ES6 setting for web environments, since
dynamic module import doesn't currently work in a worker, see:
https://bugzilla.mozilla.org/show_bug.cgi?id=1540913

This partially reverts commit be993a1.
  • Loading branch information
kleisauke committed Aug 23, 2021
1 parent f528918 commit ba6f7ee
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -52,12 +52,11 @@ Cross-Origin-Opener-Policy: same-origin
```
<sup>See [here](https://web.dev/coop-coep/) for more information.</sup>

After that, wasm-vips can be imported and initialized using an ES6 module
syntax:
After that, wasm-vips can be imported and initialized like this:

```html
<script src="vips.js"></script>
<script type="module">
import Vips from './vips.js';
const vips = await Vips();
</script>
```
Expand Down
3 changes: 1 addition & 2 deletions playground/src/playground-runner.html
Expand Up @@ -12,11 +12,10 @@
</style>
</head>
<body>
<script src="../lib/vips.js?<%= __webpack_hash__ %>"></script>
<script type="module">
let loadedElements = [];

import Vips from '../lib/vips.js?<%= __webpack_hash__ %>';

window.addEventListener('message', load);

function load(event) {
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -138,6 +138,6 @@ if("web" IN_LIST ENVIRONMENT)
set_property(
TARGET ${PROJECT_NAME}-web
APPEND_STRING PROPERTY
LINK_FLAGS " -s ENVIRONMENT=web,worker -s EXPORT_ES6 -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$Browser"
LINK_FLAGS " -s ENVIRONMENT=web,worker -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$Browser"
)
endif()
3 changes: 1 addition & 2 deletions test/bench/index.html
Expand Up @@ -9,12 +9,11 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.6/platform.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.3.4/chai.min.js" crossorigin="anonymous"></script>
<script src="lib/web/vips.js"></script>
<script type="module">
// Global variables used throughout the benchmarks
const assert = chai.assert;

import Vips from './lib/web/vips.js';

// Target width and height
const width = 720;
const height = 588;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/index.html
Expand Up @@ -75,6 +75,7 @@
timeout: 60000
});
</script>
<script src="lib/web/vips.js"></script>
<script type="module" src="test_arithmetic.js"></script>
<script type="module" src="test_colour.js"></script>
<script type="module" src="test_connection.js"></script>
Expand All @@ -93,7 +94,6 @@
globalThis.expect = chai.expect;

import * as Helpers from './helpers.js';
import Vips from './lib/web/vips.js';

const options = {
print: (stdout) => console.log(stdout.replace(/\033\[[0-9;]*m/g, "")),
Expand Down

0 comments on commit ba6f7ee

Please sign in to comment.