Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix splitbrain between .js being ESM & CJS inconsistently #189

Merged
merged 7 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
},
rules: {
camelcase: ["error", { properties: "never" }],
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

export * from "./pkg/matrix_sdk_crypto_wasm.d";
export * from "./pkg/matrix_sdk_crypto_wasm.d.ts";

/**
* Load the WebAssembly module in the background, if it has not already been loaded.
Expand Down
4 changes: 2 additions & 2 deletions node.js → node.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ let initialised = false;
*
* It will throw if there is an attempt to load the module asynchronously running
*
* @returns {typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d")}
* @returns {typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d", { with: { "resolution-mode": "require" } })}
richvdh marked this conversation as resolved.
Show resolved Hide resolved
*/
function loadModuleSync() {
if (modPromise) throw new Error("The WASM module is being loaded asynchronously but hasn't finished");
Expand All @@ -80,7 +80,7 @@ function loadModuleSync() {
/**
* Loads and instantiates the WASM module asynchronously
*
* @returns {Promise<typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d")>}
* @returns {Promise<typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d", { with: { "resolution-mode": "require" } })>}
*/
async function loadModuleAsync() {
const bytes = await readFile(filename);
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"ruma",
"nio"
],
"type": "module",
"exports": {
".": {
"matrix-org:wasm-esm": {
Expand All @@ -26,8 +27,8 @@
},
"require": {
"types": "./index.d.ts",
"node": "./node.js",
"default": "./index.js"
"node": "./node.cjs",
"default": "./index.cjs"
},
"import": {
"types": "./index.d.ts",
Expand All @@ -38,11 +39,11 @@
},
"files": [
"index.mjs",
"index.js",
"index.cjs",
"index-wasm-esm.mjs",
"index.d.ts",
"node.mjs",
"node.js",
"node.cjs",
"pkg/matrix_sdk_crypto_wasm.d.ts",
"pkg/matrix_sdk_crypto_wasm_bg.js",
"pkg/matrix_sdk_crypto_wasm_bg.cjs",
Expand Down
1 change: 1 addition & 0 deletions src/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ impl From<RustShieldState> for ShieldState {
#[cfg(test)]
pub(crate) mod tests {
use wasm_bindgen_test::wasm_bindgen_test;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_node_experimental);

use super::EncryptionAlgorithm;

Expand Down
1 change: 1 addition & 0 deletions src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ pub(crate) mod tests {
use matrix_sdk_crypto::types::requests::KeysQueryRequest as OriginalKeysQueryRequest;
use serde_json::Value;
use wasm_bindgen_test::wasm_bindgen_test;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_node_experimental);

use super::{KeysClaimRequest, KeysQueryRequest, KeysUploadRequest};

Expand Down
Loading