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.

Transform paths doesn't work with import require statements

See original GitHub issue

I tried out this plugin and it works great for normal es6 import statements with default or named exports. Unfortunately it doesn’t work on files with the legacy commonJS export shape.

A workaround is to change the import to es6 and use something like the esModuleInterop compiler flag. That requires modification of the source code though, and therefore is a heavy handed.

Dependency.ts

export = 3;

Main.ts

import d = require('Dependency');

Expected Main.d.ts

import d = require('./Dependency');

Actual

No transform was performed

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
danielpzacommented, Aug 1, 2019

@richardspence, a fix is up, upgrade to v1.1.8

3reactions
danielpzacommented, Jul 30, 2019

@richardspence, a fix is up in v1.1.7, please upgrade

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to transform require into import statement for third party ...
Tim answer is perfect, the error is because for importing something typescript need its type definitions (property "typings" in target ...
Read more >
The plugin works only when "paths" exists in tsconfig, why? #39
My IMHO is following: it's a little strange to require "paths" to be present in tsconfig.json. I think in an ideal world, the...
Read more >
Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >
How Pros Get Rid of Relative Imports - DEV Community ‍ ‍
The easiest way to get rid of the long imports is to add baseUrl in the jsconfig.json (add jsconfig.json at the root level...
Read more >
Webstorm not resolving module imports using typescript paths
Hello there! I am using Webstorm 2019.3.4 I found it very problematic to configure "paths" option so that IDE does not show me......
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