Open dantasfiles opened 4 years ago
The problem is require
doesn't support ES6 modules.
https://github.com/microsoft/dts-gen/blob/bff184105c86a8f7f9e2f4f9a424775cdd4f7c4c/lib/run.ts#L77
The solution in https://github.com/microsoft/dts-gen/issues/42#issuecomment-414038955 uses @babel/register:
The require hook will bind itself to node's require and automatically compile files on the fly.
npm install @babel/core @babel/register --save-dev
lib/run.js
require("@babel/register")({
ignore: [],
presets: ["INSERT YOUR PRESET HERE"]
});
I used module:metro-react-native-babel-preset
as my preset.
npm run build
npm link
dts-gen -m aws-amplify-react-native
However, it kept on wanting me to install more and more packages, aws-amplify-react-native
-> aws-amplify
-> react-native
.
Finally, it crashed with an Invariant Violation: __fbBatchedBridgeConfig is not set, cannot invoke native modules at invariant
error.
This seems to be too complex a use-case for dts-gen
so I'm going to give up for now.
ETA: I hit "close issue" by mistake.