kentcdodds / kentcdodds/babel-plugin-preval

ReferenceError: Can't find variable: preval (React Native app)

Open
#105 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.4k
Forks
48
PR merge metrics
No merged PRs in 30d

Description

- `babel-plugin-preval` version: 5.1.0
- `node` version: 16.12.0
- `npm` (or `yarn`) version: 8.4.1

Relevant code or config

```javascript
const gitHash = preval`
import GitInfo from 'react-git-info/macro';
gitInfo = GitInfo();
module.exports = gitInfo.commit.shortHash
`
```

My `babel.config.js` file:
```
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: ['babel-plugin-preval']
}

```

What you did: I'm trying to use preval to get the git hash and have it displayed in the app.

What happened:

`ReferenceError: Can't find variable: preval`

I'm not sure if there's any additional steps I need to take to have this work in React Native.

Contributor guide

Open the contributing guide

Research direction

Start with the preval template in the issue and the provided babel.config.js, then reproduce the ReferenceError in the React Native app using the stated versions. Investigate whether the Babel plugin is applied to this syntax; done means the app displays the git short hash without the runtime ReferenceError, with any required configuration or limitation recorded.

Written by the indexing model from the issue text.

Assessment

Tech stack
babel, javascript, react-native
Domain
build-system, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.