heap / react-native-heap

A React Native integration for Heap
MIT License
82 stars 36 forks source link

Jest fails with errors that say Cannot find module 'babel-types' or Cannot find module 'babel-template' #424

Closed jbseppanen closed 7 months ago

jbseppanen commented 7 months ago

Index file found here requires babel-types and babel-template packages. https://github.com/heap/react-native-heap/blob/develop/instrumentor/src/index.js#L3-L4

I attempted to replace those two imports with this:

const t = require('@babel/types'); const template = require('@babel/template');

That then changes the error to say TypeError: [BABEL]: template is not a function.

This came from the PR here. I wanted that version (0.22.7) for the security audit fix that it brings. I'm not clear on what need to happen with the template in order to fix.

bomjkolyadun commented 7 months ago

Seeing the same issue with 0.22.7

bnickel commented 7 months ago

Is this issue just limited to Jest? Is autocapture still working correctly?

jbseppanen commented 7 months ago

Actually now I can't even run the app. It throws an error immediately saying error: index.ts: [BABEL]: Cannot find module 'babel-types' I must not have had a clean build last time. So it appears that it's more than just testing.

bnickel commented 7 months ago

Okay, I'm seeing the issue as well. I've determined the fix is:

const t = require('@babel/types');
const template = require('@babel/template').default;

I'll push a fix later today. Thanks for reporting this.

bnickel commented 7 months ago

The fix has been released as 0.22.8