dividab / tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.
MIT License
1.82k stars 104 forks source link

Add support for baseUrl overwrite using TS_NODE_BASEURL environment v… #114

Closed ejhayes closed 2 years ago

ejhayes commented 4 years ago

Adds support for baseUrl overwrite using TS_NODE_BASEURL environment variable.

First off, thanks for this library! It seems that several people are running into a case where they need to change the baseUrl to get this working after running tsc. So far most of the solutions look to be either:

1) Creating a bootstrap js file for the sole purpose of changing baseUrl 2) Extending tsconfig.json to extend the orginal tsconfig.json and then set baseUrl based on that

It seems like the simplest solution would be to allow changing the baseUrl via environment variable instead of either of the above options.

codecov[bot] commented 4 years ago

Codecov Report

Merging #114 into master will not change coverage by %. The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #114   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files           4       4           
  Lines         129     129           
  Branches       52      52           
======================================
  Misses        129     129           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 32338c6...9afa8d9. Read the comment docs.

cspotcode commented 3 years ago

ts-node allows specifying overrides within your tsconfig.json; it might make sense for tsconfig-paths to detect a ts-node hook and grab the compiler options from there.

{
  "ts-node": {
    "compilerOptions": {
      "baseUrl": "overridden for ts-node"
    }
  },
  "compilerOptions: {
    "baseUrl": "this one is used by tsc"
    // ...
}
// detect ts-node and get options
process[Symbol.for('ts-node.register.instance')].config.options
jonaskello commented 3 years ago

Seems like some ppl find this useful so I will merge it.

jonaskello commented 3 years ago

However there seems to be some merge conflicts that needs attending to first.

information-security commented 2 years ago

Hi,

Any updates on this? This PR is very useful. Without this env var, we are forced to either use any of the workarounds mentioned by the OP or use a third-party package like tscpaths or tsc-alias. This feature is more convenient than these workarounds and keeps our dependency tree less crowded.

I'd appreciate it if you could merge/release this as soon as possible.

jonaskello commented 2 years ago

If someone could resolve the conflicts a merge would be possible.

information-security commented 2 years ago

@jonaskello I am willing to contribute but I don't have write access to this repository. Do you want me to submit a new PR?

jonaskello commented 2 years ago

@information-security Yes, please make a new PR.

jonaskello commented 2 years ago

Superseded by #185