question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feature: acknowledge tsconfig paths

See original GitHub issue

What I would like to do is have multiple packages in the same repo. So far everything works well EXCEPT, I have one package that depends on another I have the paths defined in the tsconfig so that I can use the correct module name during development and testing.

{
   ...
   "baseUrl": "./",
    "paths": {
      "@livesafe/common": [
        "./src/app/common/public_api.ts"
      ],
      "@livesafe/dialog": [
        "./src/app/dialog/public_api.ts"
      ]
    }
}

Everything works great for dev but falls over when trying to generate the bundle for @livesafe/dialog I get the following error.

screen shot 2017-07-31 at 8 29 21 am 1

Looking through the code I couldn’t find a way to configure paths for the ngc step of the build.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

6reactions
deanpetersoncommented, Apr 19, 2018

I have a similar problem. Following a suggestion for making environment variables reusable, I added the following to the tsconfig: "compilerOptions": { . . . "paths": { "@env/*": ["environments/*"] } },

That is so I can use something like: import { environment } from "@env/environment"; Rather than a relative path to the evironment.ts file that exists outside the modules base folder I will be packaging up. Of course when I go to run npm run build:lib to execute ng-packagr I get the error that @env module does not exist. I am having a little trouble deciphering some of the suggestions above. Is there an approach that will work to fix this problem? I would like to use environment variables in place of hard coding values that will change based on the application my npm package is running in. I thought I had a solution with @env/environment but ng-packagr will not allow it.

1reaction
dhergescommented, Apr 7, 2018

No, not yet. There’s two sides of it:

  1. improving the programmatic API for better tsconfig customization (it’s a mess, there’s a default tsconfig, an entry point tsconfig, and a build-time tsconfig). What users want is to configre the entry point tsconfig. Right you, the API only allows to configure the default.
  2. multi-package builds: something like dependsOn: [ "path/to/other/package.json" ] that will build the dependee package first and then build the dependent.
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use paths in tsconfig.json?
This can be set up on your tsconfig.json file, as it is a TS feature. You can do like this: "compilerOptions": { "baseUrl":...
Read more >
TypeScript: Documentation - Module Resolution
Use non-relative paths when importing any of your external dependencies. ... Traditionally, imports in Node.js are performed by calling a function named ...
Read more >
tsconfig paths not recognized
In the root of my project I have a tsconfig.base.json. where. ... However, when I am using Resharper, it does not recognize the...
Read more >
Restructure with ease thanks to Typescript path mappings
In our tsconfig.json file we first need to set a baseUrl to tell the compiler where the paths are starting from. In our...
Read more >
Short TypeScript Import Paths in Angular9 - Bits and Pieces
The first thing is that your IDE can highlight whether the import paths are right or wrong. If your IDE cannot recognize the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found