Use RTK Query endpoints as a package in a lerna monorepo

I have Lerna Monorepo with an api folder inside of the packages folder.

api folder is just RTKQuery endpoints which code split into several other folders as described in Code Splitting.

I have two other React apps. one for website and the other for admin panel.

currently what I do is this:

import { useAdminSampleQuery } from 'api/admin/sampleQuery';
import { useSampleQuery } from 'api/sampleQuery';

and I need to use RTK query in those apps like so:

import { useAdminSampleQuery, useSampleQuery } from 'api';

so I tried to use rollup and simply combine all the files into one, but I found this problem.

I just need to use the whole RTKquery folder as a separate package any solutions? [same as this question]

Leave a Comment