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

Support custom locations for 'tsconfig.json' #132

Closed
DanielRosenwasser opened this issue Apr 19, 2016 · 10 comments
Closed

Support custom locations for 'tsconfig.json' #132

DanielRosenwasser opened this issue Apr 19, 2016 · 10 comments

Comments

@DanielRosenwasser
Copy link

The fact that tsify tries to figure out the appropriate tsconfig.json is great, but some projects have several different tsconfig.json files (e.g. one for source alone, one for tests, etc.). @sandersn ran into this issue.

I would think there are two separate (but not mutually exclusive!) ways of going about this:

  1. Keep the current behavior but respect Browserify's basedir setting when looking for a tsconfig.json.
  2. Add an option to tsify itself to take a project or tsconfigPath option.

I think it would be a good idea to do both, but doing just one would go a long way.

@smrq
Copy link
Member

smrq commented Apr 19, 2016

Yep, both options make sense (and the latter was already suggested at #84). I've just never gotten around to it.

PRs welcome, of course. But I could probably knock this one out pretty quickly...

@smrq
Copy link
Member

smrq commented Apr 19, 2016

Okay, so as far as option 1 goes, I've made the change, but it won't work properly with TypeScript <1.9, since ts.findConfigFile() will prioritize a tsconfig in the CWD over whatever is passed in via basedir (microsoft/TypeScript#2965). Works just fine with typescript@next.

@smrq
Copy link
Member

smrq commented Apr 19, 2016

Option 2, same caveat when configuring it with a directory. Specifying a file works fine. This will be out shortly.

@smrq
Copy link
Member

smrq commented Apr 19, 2016

Okay, try updating to v0.15.1. This adds support for --project, which can be either a directory to search in (TS >= 1.9), or a tsconfig file, as well as the change to use basedir instead of the cwd when it is set. (The --project setting takes precedence over basedir, which takes precedence over the cwd.)

@smrq smrq closed this as completed Apr 19, 2016
@sandersn
Copy link

I tried 0.15.1 with typescript (not typescript@next). Explicitly specifying tsconfig's path works. Thanks!

@DanielRosenwasser
Copy link
Author

Thanks a bunch @smrq!

@azarus
Copy link

azarus commented Jun 4, 2017

So how do you define --project in tsify can't see a working example and --project is a command line argument, how am i supposed to use that in the gulp task?

@cartant
Copy link
Contributor

cartant commented Jun 5, 2017

@azarus tsify accepts compiler options specifed via the plugin options argument:

browserify({
    entries: "index.ts"
}).plugin("tsify", {
    project: "tsconfig.json"
})

Also, if a project is not specified, tsify uses TypeScript's findConfigFile to locate one, so it's behaviour should be the same as tsc's if no project file is specified.

@azarus
Copy link

azarus commented Jun 5, 2017

That doesn't seemed to work, anyways i went with a workaround requiring the json file manually.
I had my tsconfig in the root folder
/tsconfig.json
/gulp-tasks/tsify.js

And tried to use the project option but didn't work for some reason.

@dbwodlf3
Copy link

dbwodlf3 commented Jan 26, 2021

it works. but if you use complex build system.. then it may not works.
almost you can resolve this problem with NODE_PATH flag.
just add extra path.. then maybe it will works.
or just use browserify 'paths' option.

i think using browserify "paths" option is best choice.
like

const browserify_option = { 
    paths: [path.join(frontend, 'src')]
    ...
}

(my 5 hours conclusion.. Xd)

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

No branches or pull requests

6 participants