问题描述
我正在从导出 ESM 模块的 node_module 包中导入默认导入。我已经设置了我的 Jest/Babel,使它不再抱怨 SyntaxError: Unexpected token import
,但是现在它成功导入了模块,结果发现该模块是一个空对象。我需要以某种方式转换我的代码吗? (P.S. 这可能不言而喻,但导入在我的应用中运行良好。)(P.P.S. 我正在使用 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 {
...
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)