diff --git a/CHANGELOG.md b/CHANGELOG.md index 30c70127d..b549399a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [Web] Add typescript checking to bindings/wysiwyg-wasm. - [Web] Update vite and related packages. - [Web] Simplify build scripts. +- [Web] Publish a dual CJS/ESM package with platform-specific loaders. # [2.37.14] - [Android] Have separate modes for parsing HTML for 'editor mode' and 'message mode' using `isEditor: Boolean` parameter. diff --git a/Makefile b/Makefile index 741e19e0b..676887c8c 100644 --- a/Makefile +++ b/Makefile @@ -27,15 +27,8 @@ ios: targets-ios web: cd bindings/wysiwyg-wasm && \ yarn && \ - yarn build && \ - mkdir -p ../../platforms/web/generated && \ - cp \ - pkg/wysiwyg_bg.wasm \ - pkg/wysiwyg_bg.wasm.d.ts \ - pkg/wysiwyg.d.ts \ - pkg/wysiwyg.js \ - ../../platforms/web/generated/ - cd platforms/web && yarn install && yarn build + yarn build + cd platforms/web && yarn && yarn build web-format: cd platforms/web && \ diff --git a/bindings/wysiwyg-wasm/README.md b/bindings/wysiwyg-wasm/README.md index f2aed3e42..abe613ade 100644 --- a/bindings/wysiwyg-wasm/README.md +++ b/bindings/wysiwyg-wasm/README.md @@ -11,9 +11,9 @@ WASM/JavaScript bindings for wysiwyg-rust. ```sh cd bindings/wysiwyg-wasm -npm install -npm run build -#npm run test (no tests yet) +yarn +yarn build +#yarn test (no tests yet) ``` This will generate: @@ -26,15 +26,24 @@ pkg/matrix_sdk_wysiwyg.js ... plus other files ``` -These files should be copied into a web project and imported with code like: +You can then consume these files in your project by linking the package in your package.json: + +```json +{ + "dependencies": { + "@matrix-org/matrix-sdk-wysiwyg-wasm": "link:../../bindings/wysiwyg-wasm" + } +} +``` + +And consume with code like this: ```html