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.

Typescript support: support / load user defined tsconfig.json for transpiling files

See original GitHub issue

Current behavior:

index.spec.ts

import { forward } from '@apps/commons-e2e';

Fails with

Error: Cannot find module ‘@apps/commons-e2e’ from ‘e2e\src\integration’

Desired behavior:

ts-node should load an user defined tsconfig.json to find own path mappings.

Test code to reproduce

  1. create a tsconfig.json with a path mapping to a lib
  2. create a spec file using this path mapping
  3. run cypress

Versions

4.4.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:18
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
kpittman-securuscommented, May 7, 2020

@jennifer-shehane any update on the status for this one?

4reactions
maxime1992commented, Apr 14, 2020

I just tried to upgrade to 4.4.0 and ended up with the same error.

Everything was working just fine with that version but if I try to take advantage of the new feature:

TypeScript test files are now supported without using special preprocessors plugins. Addresses #1859.

To have it working previously I had to do the following:

const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

module.exports = {
  resolve: {
    extensions: ['.ts', '.js'],
    plugins: [
      new TsconfigPathsPlugin({
        configFile: './tsconfig.json',
      }),
    ],
  },
  module: {
    rules: [
      {
        test: /\.ts$/,
        exclude: [/node_modules/],
        use: [
          {
            loader: 'ts-loader',
            options: {
              configFile: 'tsconfig.e2e.json',
            },
          },
        ],
      },
    ],
  },
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - What is a tsconfig.json - TypeScript
The tsconfig.json file specifies the root files and the compiler options required to compile the project. JavaScript projects can use a jsconfig.json file...
Read more >
TSConfig Reference - Docs on every TSConfig option
This includes generating a type for the import based on the static JSON shape. TypeScript does not support resolving JSON files by default:...
Read more >
Documentation - tsc CLI Options - TypeScript
Flag Type Default ‑‑allowJs boolean false ‑‑allowUmdGlobalAccess boolean false ‑‑allowUnreachableCode boolean
Read more >
Docs on every TSConfig option - TypeScript
The configuration from the base file are loaded first, then overridden by those in the ... TypeScript does not support resolving JSON files...
Read more >
TSConfig Option: esModuleInterop - TypeScript
Turning on esModuleInterop will fix both of these problems in the code transpiled by TypeScript. The first changes the behavior in the compiler, ......
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