微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 ts-jest 在 jest 中转换 esm 文件时遇到问题

如何解决使用 ts-jest 在 jest 中转换 esm 文件时遇到问题

所以我一直在思考如何让这些笑话代码转换工作,我在转换 spin.js esm 文件方面取得了一些进展。那个错误消失后,我转到下一个angular-instantsearch 但特别是 angular-instantsearch/node\_modules/instantsearch.js。这是我收到的错误

.../node_modules/angular-instantsearch/node_modules/instantsearch.js/es/index.js:2
import algoliasearchHelper from 'algoliasearch-helper';
^^^^^^

SyntaxError: Cannot use import statement outside a module

这是我处理转换的基本笑话配置:

const nxPreset = require('@nrwl/jest/preset');
module.exports = {
  ...nxPreset,testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],transform: {
    '^.+\\.(ts|js|html)$': 'ts-jest',},resolver: '@nrwl/jest/plugins/resolver',modulefileExtensions: ['ts','js','html'],coverageReporters: ['html'],transformIgnorePatterns: [
    'node_modules/(?!(spin\\.js|instantsearch\\.js/es)/)',],// this caused issues with detecting modules from component files in angular
  /* moduleNameMapper: {
    "instantsearch\\.js/es$": "instantsearch.js/cjs","instantsearch\\.js/es/(.*)$": "instantsearch.js/cjs/$1",} */
};

对此的任何帮助将不胜感激,谢谢!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?