ncc
ncc copied to clipboard
Changing working directory before building breaks `tsconfig` `paths`
In a lerna monorepo, if you have paths
defined in one of the packages tsconfig
, e.g.
...
"paths": {
"@common/*": ["common/*"]
}
...
And you import using those paths:
// handler.ts
import { MyClass } from "@common/my-class";
It works when you do the following at the root directory of the package
yarn ncc build src/handlers/my-handler/handler.ts -o dist/my-handler -e aws-sdk -s -t
however, if you cd
to the root level package and do
yarn ncc build packages/my-package/src/handlers/my-handler/handler.ts -o packages/my-package/dist/my-handler -e aws-sdk -s -t
ncc
stops transforming the @common/my-class
import and then when you execute the bundle you get a failure because it tries to find the package in node_modules
This is related to my workaround in https://github.com/vercel/ncc/issues/951 which proved to not work when you have such imports