-
Notifications
You must be signed in to change notification settings - Fork 178
FBT default import has issues with ESModules/CommonJS interop #115
Comments
We already use It'd be best to submit a minimum repro case as a small git repo so that we could look into this. |
Following our talk, I'd suggest to use this code to output the transient JS code that is present when the error occurs: https://github.com/facebook/fbt/blob/master/packages/fb-babel-plugin-utils/TestUtil.js#L63-L78
|
@kayhadrin As we discussed in #137, you can find a minimal reproduction of this issue Repro use Next.js & Typescript. In |
FYI: someone wrote an article that could be useful to others using typescript: https://medium.com/@frenchyooy/configuring-fbt-api-with-typescript-and-react-create-app-492ee72f44bb |
FYI: I was having the same problem and switched to |
🐛 Bug Report
I'm working in an ES2017 codebase compiled with TypeScript, Babel, and webpack. It seems that in certain contexts, using the default import of FBT fails because
babel-plugin-fbt
says the variablefbt
is not bound when using thefbt()
syntax in code. Examining the value of the import, is an object with this structure:I'm not sure which step of tooling is responsible for making the default export an object.
I've confirmed that a reliable workaround is to write
const { fbt } = require('fbt')
rather thanconst fbt = require('fbt')
.I believe that the fault lies in
babel-plugin-fbt
, since I am able to use the default exports of other libraries without issue.To Reproduce
Not certain what the minimal replication case is.
Expected behavior
When using TypeScript and/or webpack, FBT should work reliably when using the default export.
envinfo
The text was updated successfully, but these errors were encountered: