Support absolute URL for typescript
See original GitHub issueWould be good to have a useAbsolute
flag when generating libraries, this could be a universal flag that applies to all typescript projects.
Description
Allow baseUrl
to be applied, we’ll need a third party plugin to transform the absolute paths to relative during compilation
Motivation
Enables absolute URL for project, cleaner imports
Suggested Implementation
Take @nrwl/node:package
for example, We would need to modify compiler used here:
Compiler: https://github.com/cevek/ttypescript/tree/master/packages/ttypescript Plugin: https://github.com/zerkalica/zerollup/tree/master/packages/ts-transform-paths
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:5
Top Results From Across the Web
How to set an absolute path in TypeScript | Towards the Cloud
Absolute file paths can help organize the imports in your TypeScript projects by improving the way import locations are fetched by the ...
Read more >How to use absolute path with Typescript? - Stack Overflow
I have a project that written in Typescript on NodeJS. I am using relative path for my modules to import another. But this...
Read more >Documentation - Module Resolution - TypeScript
A non-relative import can be resolved relative to baseUrl , or through path mapping, which we'll cover below. They can also resolve to...
Read more >Advanced Features: Absolute Imports and Module Path Aliases
Absolute Imports and Module path aliases ... Next.js automatically supports the tsconfig.json and jsconfig.json "paths" and "baseUrl" options since Next.js 9.4.
Read more >Dependency resolution - Parcel
Typically, these dependencies do not specify a full absolute path, ... In addition to the standard dependency specifiers supported across many tools, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I would love to see absolute imports not only for libraries, but for everything within one package. A simple example would be shortening this
to this
Note that I don’t want to specify the package name with the absolute import, this helps me keep packages within boundaries and it makes moving / renaming easier if necessary.
Has anyone solved this problem?