From b2694a78bf58233b7457a9807d72f0958e900585 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 4 Dec 2024 14:12:08 +0000 Subject: [PATCH 1/7] Publish a dual CJS/ESM package with platform-specific loaders --- CHANGELOG.md | 1 + Makefile | 11 +- bindings/wysiwyg-wasm/README.md | 5 +- bindings/wysiwyg-wasm/index-wasm-esm.js | 64 +++++++++ bindings/wysiwyg-wasm/index.cjs | 85 ++++++++++++ bindings/wysiwyg-wasm/index.d.ts | 17 +++ bindings/wysiwyg-wasm/index.js | 85 ++++++++++++ bindings/wysiwyg-wasm/node.cjs | 120 +++++++++++++++++ bindings/wysiwyg-wasm/node.js | 117 ++++++++++++++++ bindings/wysiwyg-wasm/package.json | 43 ++++-- bindings/wysiwyg-wasm/tsconfig.json | 2 +- bindings/wysiwyg-wasm/yarn.lock | 127 +++++++++++++++++- package-lock.json | 10 -- platforms/web/README.md | 7 + platforms/web/lib/composer.test.ts | 3 +- platforms/web/lib/composer.ts | 3 +- platforms/web/lib/conversion.ts | 3 +- platforms/web/lib/dom.ts | 2 +- platforms/web/lib/suggestion.test.tsx | 10 +- platforms/web/lib/suggestion.ts | 3 +- platforms/web/lib/types.ts | 3 +- platforms/web/lib/useComposerModel.test.tsx | 2 +- platforms/web/lib/useComposerModel.ts | 9 +- platforms/web/lib/useFormattingFunctions.ts | 2 +- platforms/web/lib/useListeners/event.test.ts | 7 +- platforms/web/lib/useListeners/event.ts | 4 +- .../web/lib/useListeners/useListeners.ts | 5 +- .../web/lib/useTestCases/useTestCases.ts | 2 +- platforms/web/lib/useTestCases/utils.test.ts | 7 +- platforms/web/lib/useTestCases/utils.ts | 3 +- platforms/web/lib/useWysiwyg.ts | 2 + platforms/web/package.json | 15 ++- platforms/web/scripts/hack_myfetch.js | 100 -------------- platforms/web/test.setup.ts | 26 ++-- platforms/web/vite.config.ts | 9 +- platforms/web/yarn.lock | 96 +------------ 36 files changed, 738 insertions(+), 272 deletions(-) create mode 100644 bindings/wysiwyg-wasm/index-wasm-esm.js create mode 100644 bindings/wysiwyg-wasm/index.cjs create mode 100644 bindings/wysiwyg-wasm/index.d.ts create mode 100644 bindings/wysiwyg-wasm/index.js create mode 100644 bindings/wysiwyg-wasm/node.cjs create mode 100644 bindings/wysiwyg-wasm/node.js delete mode 100644 package-lock.json delete mode 100644 platforms/web/scripts/hack_myfetch.js 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..7ae47c751 100644 --- a/bindings/wysiwyg-wasm/README.md +++ b/bindings/wysiwyg-wasm/README.md @@ -30,8 +30,9 @@ These files should be copied into a web project and imported with code like: ```html