Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the src folder (flatten) when transpiling with nx (tsc)?

I made a lib project using NX here : https://github.com/geofmigliacci/magnetarise so I can transpile & I get my dist folder like so :

dist/core/src

The thing is that when I pack my project and install it, when I want to import I get an import like so :

import { XService } from '@magnetarise/src/services';

But I'd like to have an import like :

import { XService } from '@magnetarise/services'; (not everything inside @magnetarise)

So removing the src folder ; I already took a look at Maintain src/ folder structure when building to dist/ folder with TypeScript 3 & tried to set the rootDir to "src" inside my packages/core/tsconfig.lib.json but it doesn't work.

Has anyone got this problem & know how to solve it ?

Thank you for reading.

like image 951
Geoffrey Migliacci Avatar asked Oct 14 '25 15:10

Geoffrey Migliacci


1 Answers

Need to rootDir inside options of project.json file

https://nx.dev/packages/js/executors/tsc#rootdir

like image 138
Stanisław Avatar answered Oct 18 '25 04:10

Stanisław



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!