So I have been banging my head on how to get these jest code transforms to work and I have made a bit of progress with transforming the spin.js
esm files. With that error gone I moved on to the next one which was angular-instantsearch
but specifically angular-instantsearch/node\_modules/instantsearch.js
. Here is the error I am reciving:
.../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
Here is my base jest config that deals with the transforms:
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",
} */
};
Any help on this will be extremely appreciated, thanks!
question from:
https://stackoverflow.com/questions/65907329/trouble-transforming-esm-files-in-jest-with-ts-jest 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…