Lng build - Unresolved dependencies

I want to use shared code in our TypeScript project. I basically followed the TypeScript handbook about using the paths property.

However, this configuration doesn’t seem to be working with the (default) bundler. I keep getting an Unresolved dependencies error during lng build.

I’ve setup a basic TypeScript project on my github. The project should use code from the shared folder, which is located one level up.

When running LNG_BUILD_FAIL_ON_WARNINGS=true lng build I keep getting:

...lightning-typescript-external\lightningjs-typescript-external\src\index.ts → build/appBundle.js...
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
@shared/utils (imported by src/App.ts)
(!) Missing global variable name
Use output.globals to specify browser global variable names corresponding to external modules
@shared/utils (guessing 'utils')
created build/appBundle.js in 1.8s
[!] Warnings occurred and --failAfterWarnings flag present

Is this supported in Lightning-CLI? Or am I missing something in the configuration?

Hi @p_eijkelhardt. This is indeed not a supported configuration for the Lightning-CLI. The tsconfig.json is mainly only used for TypeScript type checking. Rollup/esbuild is used to bundle with a pre-baked configuration. In general with most bundlers it’s not a good idea (if it’s even supported) to include code that is outside of the root directory of a project. The best advice I can give is to look into making your shared code an NPM module and use npm link to symlink it to your main project. If your project consists heavily of many shared modules then there’s also Lerna.