'jsconfig.json paths for modules in node_modules

I have following file structure:

project
├── process
│   └── MyProjectLib
│       └── process.js
├── node_modules
│   └── MyModule
│       └── process
│           └── MyModuleLib
│               └── process.js
└── jsconfig.json

Content of process.js in MyModuleLib:

export function myModuleFunction()
{
    return "hallo";
}

Content of process.js in MyProjectLib:

function myProjectFunction()
{
    var x = myModuleFunction();

    return x + " myModuleFunction";
}

Now I need an import in MyProjectLib.process.js

It has to be in this format (I cannot change it, this needs my application):

import { myModuleFunction } from "MyModuleLib";

But currently it looks like

import { myModuleFunction } from "MyModule/process/MyModuleLib/process";

My jsconfig.json:

{
    "compilerOptions": {
      "module": "es6",      
      "moduleResolution": "node",
      "baseUrl": ".",
      "allowSyntheticDefaultImports": true,
      "checkJs": true,
      "noEmit": true,
      "removeComments": true,
      "strict": false,
      "paths": {
        "*": [ "MyModule/process/MyModuleLib/process"]
      }
    },
    "include": ["**/*.js", "node_modules/**/process/*/process.js"],
}

The content of node_modules cannnot be changed. I tried to modfiy it with "paths" but it doesn't work. How can I route the import so it looks like i want?

In the best case the solution should not be specific to "MyModule", though it should work with similar modules in the directory "node_modules".



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source