I have a monorepo that includes both a front-end (CRA) React app and an Express API. They both use another package in the monorepo that is plain TS, but uses import
statements. I use tsc
to compile the TS -> JS for the React app, into a directory I call tscompiled
, and for the Node app I further transpile the JS with babel to a directory called lib
, so that all the import
statements become require
s.
So when I want to compile the React app, I need package.json
for my dependency to use the tscompiled
directory with its type definitions:
"main": "tscompiled/index.js",
And then when I want to compile the Express app, I need package.json
for my dependency to use the lib
directory:
"main": "lib/index.js",
This is a real kludge — can I get my Node Express app to handle import
statements or transpile dependent packages within the monorepo automatically?