contentlayerdev / contentlayer

Contentlayer turns your content into data - making it super easy to import MD(X) and CMS content in your app
https://www.contentlayer.dev
MIT License
3.27k stars 200 forks source link

Be able to use workspaces dependencies and tsconfig paths in contentlayer.config.ts #608

Open gustaveWPM opened 9 months ago

gustaveWPM commented 9 months ago

Hello.

I think it would be great to be able to use workspaces and Typescript paths related dependencies in contentlayer.config.ts.

For instance, if I try it in my tailwind.config.ts

// tailwind.config.ts
import { buildPathFromParts } from '@repo/shared-lib/str';
console.log(buildPathFromParts('hello', 'world'));

All works as intended.

But if I do the same in contentlayer.config.ts

Then, I get an error:

ConfigReadError (/home/me/Delivery/project/contentlayer.config.ts): Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/me/Delivery/project/node_modules/@repo/shared-lib/str' imported from /home/me/Delivery/project/.contentlayer/.cache/v0.3.4/compiled-contentlayer-config-KYFR5QIE.mjs
ConfigReadError (/home/me/Delivery/project/contentlayer.config.ts): Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/me/Delivery/project/node_modules/@repo/shared-lib/str' imported from /home/me/Delivery/project/.contentlayer/.cache/v0.3.4/compiled-contentlayer-config-KYFR5QIE.mjs

It's quite annoying because I can't do anything other than imports with absolute or relative paths. I can't use the paths in my tsconfig.json, and I can't use some of my third-party libraries, unless I adapt them entirely and have to write everything in relative or absolute path in them too.


EDIT: maybe it's related to ESBuild?

gustaveWPM commented 6 months ago

.

stale[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

gustaveWPM commented 4 months ago

:cry:

stale[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

gustaveWPM commented 2 months ago

.

zhutmost commented 1 week ago

Hi, I have met a similar issue. Do you find any solutions?

gustaveWPM commented 1 week ago

no, sorry. This is very tedious.