reactjs - למה המודול שלי ריק {} כשמריצים Jest ומייבאים מודול ESM?


אני מייבא את הייבוא ברירת המחדל מחבילה ב-node_module שמייצאת מודול ESM. הגדרתי את Jest/Babel שלי כך שהוא הפסיק להתרעם על SyntaxError: Unexpected token import, אבל עכשיו כשהייבוא של המודול מצליח, מתברר שהמודול הוא אובייקט ריק. האם אני צריך לשנות את הקוד שלי בצורה מסוימת? (נ.ב. כנראה שזה ברור מאליו, אבל הייבוא עובד טוב באפליקציה שלי.) (נ.נ.ב. אני משתמש ב-Create React App ו-TypeScript, למקרה שזה משנה משהו.)

jest.config.js

module.exports = {
  moduleNameMapper: {
    '\\.(css|less)$': 'identity-obj-proxy',
  },
  preset: 'ts-jest',
  transformIgnorePatterns: ['node_modules/(?!(@micro-frontend-apps)/)'] // this successfully allows the ESM module to be imported without complaint
};

styles.ts (נבדק)

import { theme } from '@micro-frontend-apps/design-systems-library';
import styled from 'styled-components';

const InputContainer = styled.div`
  .react-tel-input {
    font-family: ${theme.font.fontFamilyBrand}; // *theme is undefined here*
    li {
    ...