Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore cwd value based on the project option when exist the require option #53

Closed
wants to merge 1 commit into from

Conversation

beejeon
Copy link

@beejeon beejeon commented Jul 10, 2018

When use Bootstrap tsconfig-paths with explicit params and use the project option, cwd value in options.ts use the project option value.

This is a problem when using absoluteBaseUrl.

This PR is Ignore cwd value based on the project option when exist the require option.

@coveralls
Copy link

coveralls commented Jul 10, 2018

Coverage Status

Coverage remained the same at 84.979% when pulling d8e553a on todtod80:options-cwd into 111c105 on dividab:master.

@jonaskello
Copy link
Member

Does this fix #52?

@beejeon
Copy link
Author

beejeon commented Jul 10, 2018

I think, #52 seems to be another issue.

@jonaskello
Copy link
Member

Yes I think you are correct. So this is a separate issue.

@jonaskello
Copy link
Member

If I understand this issue correctly you have a bootstrap.js file, something like this:

const tsConfigPaths = require("tsconfig-paths");

tsConfigPaths.register({
     "/some/absolute/path",
    paths: [..somepaths...]
});

And then you run it something like this:

node -r ./bootstrap.js main.js

But this does not set the project option I think. Could you post how you run it?

@beejeon
Copy link
Author

beejeon commented Jul 15, 2018

@jonaskello
My project structure like this:

  • I use Yarn and yarn workspace
  • Adopted a monorepo approach
my-app
├── README.md
├── node_modules
├── package.json
└── packages
   ├── model
   │  ├── index.ts
   │  └── package.json
   └── web-app
       ├── tsconfig.json
       ├── tsconfig.server.json
       ├── tsconfig-paths-bootstrap.server.ts
       ├── index.ts
       └── package.json

And tsconfig-paths-bootstrap.server.ts like this:

import * as tsConfigPaths from 'tsconfig-paths'

tsConfigPaths.register({
  baseUrl: './',
  paths: {
    "paths": {
      "model": ["../model"]
    }
  }
})

I run this

// Go my-app/packages/web-app
ts-node --project ./tsconfig.server.json -r ./tsconfig-paths-bootstrap.server.ts ./index.ts"

In this case, options.cwd is ./ because use project option value in options.ts
So, I met message error TS2307: Cannot find module. I want use process.cwd() value.

@aleclarson
Copy link
Contributor

@jonaskello I think we should move the minimist usage into this file, so programmatic usage of register can be more explicit (eg: #205).

@jonaskello
Copy link
Member

@aleclarson IIRC the register.js file is just there as a "gateway" into the lib/register.js. So you can use tsconfig-paths/register instead of tsconfig-paths/lib/register. Do you think there is a benefit to have more code in this gateway file?

@jonaskello
Copy link
Member

@aleclarson Is this PR obsolete now that we have merged #206?

@aleclarson
Copy link
Contributor

Yup

@jonaskello
Copy link
Member

Superseded by #206

@jonaskello jonaskello closed this May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants