From 317770fb2334fa63cf34490e41db3556807d6afa Mon Sep 17 00:00:00 2001 From: taiy <53635909+taiyme@users.noreply.github.com> Date: Sun, 12 Feb 2023 17:15:12 +0900 Subject: [PATCH 1/2] =?UTF-8?q?enhance(client):=20=E3=83=AA=E3=82=A2?= =?UTF-8?q?=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=8C=E7=84=A1=E3=81=84?= =?UTF-8?q?=E3=81=93=E3=81=A8=E3=82=92=E4=BC=9D=E3=81=88=E3=82=8B=20(#9901?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/MkReactedUsersDialog.vue | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/frontend/src/components/MkReactedUsersDialog.vue b/packages/frontend/src/components/MkReactedUsersDialog.vue index 2a8dffc014..1506e24ce8 100644 --- a/packages/frontend/src/components/MkReactedUsersDialog.vue +++ b/packages/frontend/src/components/MkReactedUsersDialog.vue @@ -10,15 +10,21 @@
-
- +
+ +
{{ i18n.ts.nothing }}
- - - +
From 9965bc8f9457692eb8b18efa7d9f68e5bae97d24 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Sun, 12 Feb 2023 09:18:31 +0100 Subject: [PATCH 2/2] Fix moduleNameMapper to not resolve `.wasm.js` to `.wasm` (#9894) * Fix moduleNameMapper to not resolve `.wasm.js` to `.js` Fixes #9767 Undici [tries to import `./llhttp/llhttp.wasm.js`](https://github.com/nodejs/undici/blob/e155c6db5cec9bc577d548fa7c7378013631c79c/lib/client.js#L342) which is currently broken by the (hacky) module name mapper. * longer timeout value * 30s * 50s * 60s to be safe * Revert "60s to be safe" This reverts commit f3e0f5796273c0cdcbd901e8c08ae3136b9768f8. * 2cc98226cac2e0a08332e1ce281ba8917c5b58fc revert? * revert * remove timeout * detectOpenHandles * Really solved? * Revert "detectOpenHandles" This reverts commit 29214bdff80e15998f34171bf409d454a3d10129. * Add `coveragePathIgnorePatterns` * Revert "Add `coveragePathIgnorePatterns`" This reverts commit fcf8c6806b339b7c21f53137f9939d00020904aa. * Import jsonld dynamically * remove import * add comment --------- Co-authored-by: syuilo --- packages/backend/jest-resolver.cjs | 14 -------------- packages/backend/jest.config.cjs | 11 +++++++++-- .../src/core/activitypub/LdSignatureService.ts | 5 +++-- 3 files changed, 12 insertions(+), 18 deletions(-) delete mode 100644 packages/backend/jest-resolver.cjs diff --git a/packages/backend/jest-resolver.cjs b/packages/backend/jest-resolver.cjs deleted file mode 100644 index 4424b800dc..0000000000 --- a/packages/backend/jest-resolver.cjs +++ /dev/null @@ -1,14 +0,0 @@ -// https://github.com/facebook/jest/issues/12270#issuecomment-1194746382 - -const nativeModule = require('node:module'); - -function resolver(module, options) { - const { basedir, defaultResolver } = options; - try { - return defaultResolver(module, options); - } catch (error) { - return nativeModule.createRequire(basedir).resolve(module); - } -} - -module.exports = resolver; diff --git a/packages/backend/jest.config.cjs b/packages/backend/jest.config.cjs index f0a3dc16c2..2f11f6a3e9 100644 --- a/packages/backend/jest.config.cjs +++ b/packages/backend/jest.config.cjs @@ -83,7 +83,14 @@ module.exports = { // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module moduleNameMapper: { - "^@/(.*?).js": "/src/$1.ts", + // Do not resolve .wasm.js to .wasm by the rule below + '^(.+)\\.wasm\\.js$': '$1.wasm.js', + // SWC converts @/foo/bar.js to `../../src/foo/bar.js`, and then this rule + // converts it again to `../../src/foo/bar` which then can be resolved to + // `.ts` files. + // See https://github.com/swc-project/jest/issues/64#issuecomment-1029753225 + // TODO: Use `--allowImportingTsExtensions` on TypeScript 5.0 so that we can + // directly import `.ts` files without this hack. '^(\\.{1,2}/.*)\\.js$': '$1', }, @@ -112,7 +119,7 @@ module.exports = { // resetModules: false, // A path to a custom resolver - resolver: './jest-resolver.cjs', + // resolver: './jest-resolver.cjs', // Automatically restore mock state between every test restoreMocks: true, diff --git a/packages/backend/src/core/activitypub/LdSignatureService.ts b/packages/backend/src/core/activitypub/LdSignatureService.ts index a29e1be564..618ae48b1b 100644 --- a/packages/backend/src/core/activitypub/LdSignatureService.ts +++ b/packages/backend/src/core/activitypub/LdSignatureService.ts @@ -1,6 +1,5 @@ import * as crypto from 'node:crypto'; import { Inject, Injectable } from '@nestjs/common'; -import jsonld from 'jsonld'; import { HttpRequestService } from '@/core/HttpRequestService.js'; import { bindThis } from '@/decorators.js'; import { CONTEXTS } from './misc/contexts.js'; @@ -85,7 +84,9 @@ class LdSignature { @bindThis public async normalize(data: any) { const customLoader = this.getLoader(); - return await jsonld.normalize(data, { + // XXX: Importing jsonld dynamically since Jest frequently fails to import it statically + // https://github.com/misskey-dev/misskey/pull/9894#discussion_r1103753595 + return (await import('jsonld')).default.normalize(data, { documentLoader: customLoader, }); }