Skip to content

Commit

Permalink
Test build for Emscripten PR 21701
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Apr 13, 2024
1 parent 9a0856d commit beb64ee
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 35 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Uses libvips v8.15.2, compiled with Emscripten v3.1.57.

### Changed

- Inline worker scripts (`*.worker.js`) into the main output file.
[emscripten-core/emscripten#21701](https://github.com/emscripten-core/emscripten/pull/21701)

### Removed

- Remove the `workaroundCors` setting.

## [v0.0.8] - 2024-03-17

Uses libvips v8.15.2, compiled with Emscripten v3.1.56.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN \

# Emscripten patches
RUN \
curl -Ls https://github.com/emscripten-core/emscripten/compare/3.1.57...kleisauke:wasm-vips-3.1.57.patch | patch -p1 -d $EMSDK/upstream/emscripten && \
curl -Ls https://github.com/emscripten-core/emscripten/compare/3.1.57...kleisauke:wasm-vips-3.1.57-pthread_inline.patch | patch -p1 -d $EMSDK/upstream/emscripten && \
emcc --clear-cache && embuilder build sysroot --force

# Rust
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ yarn add wasm-vips

### Browser

Requires `vips.js`, `vips.wasm` and `vips.worker.js` to be served from
the same directory. Additionally, when using ES6 modules, it's necessary
to also serve the `vips-es6.js` and `vips-es6.worker.js` files.
Requires `vips.js` (or `vips-es6.js`) and `vips.wasm` to be served from
the same directory.

Since wasm-vips requires [the `SharedArrayBuffer` API](
https://caniuse.com/sharedarraybuffer), the website needs to opt-in to
a cross-origin isolated state, by serving the following HTTP headers on
both the main document and worker script (`*.worker.js`):
the main document:

```http
Cross-Origin-Embedder-Policy: require-corp
Expand Down
2 changes: 0 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,7 @@ node --version

# Omit -es6 suffix from Node.js files
mv $SOURCE_DIR/lib/vips-node-es6.mjs $SOURCE_DIR/lib/vips-node.mjs
mv $SOURCE_DIR/lib/vips-node-es6.worker.mjs $SOURCE_DIR/lib/vips-node.worker.mjs
sed -i 's/vips-node-es6/vips-node/g' $SOURCE_DIR/lib/vips-node.mjs
sed -i 's/vips-node-es6/vips-node/g' $SOURCE_DIR/lib/vips-node.worker.mjs

# Print the target features section
echo -n "Used Wasm features: "
Expand Down
3 changes: 0 additions & 3 deletions build/preamble_vips.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ interface EmscriptenModule {
): WebAssembly.Exports;
locateFile(url: string, scriptDirectory: string): string;
mainScriptUrlOrBlob: Blob | File | string;

// https://github.com/kleisauke/wasm-vips/issues/12
workaroundCors: boolean;
}

declare module Vips {
Expand Down
3 changes: 0 additions & 3 deletions lib/vips.d.ts

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"ignore": [
"src/closure-externs/wasm-vips.js",
"src/fixed-threadpool-web.js",
"src/locatefile-cors-pre.js",
"src/modules-pre.js"
],
"env": [
Expand Down
5 changes: 0 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ if ("node" IN_LIST ENVIRONMENT)
endif()

if ("web" IN_LIST ENVIRONMENT)
set(WEB_CORS_WORKAROUND
--pre-js=${CMAKE_CURRENT_SOURCE_DIR}/locatefile-cors-pre.js
)
set(WEB_FIXED_THREADPOOL
--js-library=${CMAKE_CURRENT_SOURCE_DIR}/fixed-threadpool-web.js
)
Expand All @@ -188,13 +185,11 @@ if ("web" IN_LIST ENVIRONMENT)

target_link_options(${PROJECT_NAME}-web
PUBLIC
${WEB_CORS_WORKAROUND}
${WEB_LINK_OPTIONS}
-sENVIRONMENT=web,worker
)
target_link_options(${PROJECT_NAME}-web-es6
PUBLIC
# Note: we don't apply the CORS workaround since module scripts don't support `importScripts()`.
${WEB_LINK_OPTIONS}
-sEXPORT_ES6
# Deno reuses the web ES6 module
Expand Down
16 changes: 0 additions & 16 deletions src/locatefile-cors-pre.js

This file was deleted.

0 comments on commit beb64ee

Please sign in to comment.