Skip to content

Transpile to JS considering paths from tsconifg #18951

Closed
@wclr

Description

@wclr

For convenience to get rid of relative paths one may use:

import { sharedStuff } from '~/shared'

For this to work in tsconfig I have:

"baseUrl": ".",
    "paths": {
      "~/*": ["./*"]
    }

Transpired JS still have require('~/shared') and node will fail to find the module. Loaders like webpack has mechanics for this, but node as a standard runtime for JS AFAIN has not standardized/common approach to handle such paths correctly.

So if TS uses paths for looking up of the modules, why for convenience not convert such paths to relative to module paths so node (and other loaders) could require it? This probably should be a compiler option.

What do you think? Am I missing something why it can not be implemented? Maybe some unsafe/irrelevant cases of paths mapping?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions