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.

Usage with path aliases

See original GitHub issue

I’ve set up some custom path aliases in my ts-config: ie:

"paths": {
    "@themes": ["themes"],
    "@themes/*": ["themes/*"],
  },

Running this through rollup-plugin-ts results in the below error

[!] (plugin Typescript) TS2307: Cannot find module '@themes'.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
wessbergcommented, Jul 9, 2020

Alright everyone, this issue has been fixed as part of v1.2.28 which will be released shortly. The problem was that rollup-plugin-ts always forced the baseUrl to ., which made path mapping resolve to wrong paths for other values for the baseUrl. @marjorg, I’ve tested it against the feature branch of your repo, and it built successfully. I don’t need access to the repo anymore. Thanks, that made everything a lot easier!

2reactions
bastienrobertcommented, Jul 2, 2020

If it can help, i use @rollup/plugin-alias :

import alias from '@rollup/plugin-alias';
import tsconfig from './tsconfig.json';

function resolveEntries() {
  return Object.entries(
    tsconfig.compilerOptions.paths
  ).map(([find, [replacement]]) => ({ find, replacement }));
}

export default {
// ...
  plugins: [
    alias({
      resolve: ['.ts', '.tsx'],
      entries: resolveEntries(),
    }),
  ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Simpler Typescript paths with path aliases - Christian Lüdemann
Typescript aliases allow you to specify a word/alias for an absolute path in the application from which you can resolve paths from absolutely....
Read more >
Improving code readability with Path Aliases - Medium
Path aliasing or aliases are preconfigured names used to replace long paths in files and resolve to certain directories on a codebase. There ......
Read more >
Path Aliases in TypeScript and why you should use them
So, let's explain how to use path aliases in Typescript. Imagine you have a project structure like the following one: Let's update your...
Read more >
Path aliases with TypeScript in Node.js - Level Up Coding
With path aliases, you can declare aliases that map to a certain absolute path in your application.
Read more >
How To Configure Path Aliases With TypeScript
In this article, I'll show how to configure path aliasing in a TypeScript project. ... To use the package, I'll add it to...
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