TypeStrong / dts-bundle

Export TypeScript .d.ts files as an external module definition
MIT License
308 stars 57 forks source link

file not found error if both .d.ts file and a folder with the same name exist #51

Closed elsasslegend closed 7 years ago

elsasslegend commented 7 years ago

Hello,

I run into an issue, using the following command : dts-bundle --name myApp --main dts/**/*.d.ts --out bundle.d.ts

in dts folder, I have both a file called application.d.ts and a folder application. I get the following error, and don't know how to solve it (excepted by renaming the folder or the file) :

Error: ENOENT: no such file or directory, open 'D:\(...)\dts\application\index.d.ts'

Thanks !

esugoi commented 7 years ago

I'm having this same problem. Indeed, renaming the folder or file resolves the problem. But this is not an option when bundling third party dts files.

tolemac commented 7 years ago

Sorry about that, I have no much free time lately, and I'm involved in others projects, ... In addition I have stopped using "dts-bundle" in personal projects 1 year ago, I think is not needed currently.

Can you make a pull request with the solution?

elsasslegend commented 7 years ago

Thanks for your answer. Personally, I haven't found a better solution than using your plugin to bundle all definition files into a single one. It's the only way to expose and consume easily classes accross several modules, without having to hand-create a huge hierarchy of definition files. But maybe you found something better in the meantime ?
That said, I'm not sure what the solution is, but I suspect that at line 587, you just check if the file is a directory, but you should probably also test that there is no file with the same name. What do you think about this ?

esugoi commented 7 years ago

No need to apologize, @tolemac , this is an open project. Thanks a lot for your time spent here. ;) I don't have much time available too, but I'll try to take a look when possible. Thanks.

tolemac commented 7 years ago

@esugoi the slowest part is to build a test case ... :(

@djflex68 Most of projects used to distribute several .d.ts files, Angular for example, you can take a look to my project tolefocus where I distribute .d.ts and .js files and is easy to use from npm.

tolemac commented 7 years ago

I have merged the pull request by @esugoi that fixes it. If you have any problem tell me here.

Best regards!

esugoi commented 7 years ago

Glad I could help. :) In my case I bundled dts files of the angular project and it worked like a charm. ;) Thanks for your work, @tolemac .

elsasslegend commented 7 years ago

Many thanks @esugoi and @tolemac for the work and help :-)