-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Symlinked node_modules directory confuses dts-bundle-generator #39
Comments
Hi! It is interesting case. Let me take a look at it, but I'm not sure whether there is easy fix because I get filenames from TypeScript compiler and we do not know whether there were symlinks to file/folder or not. |
After looking over the issue I have the next conclusions:
I'll add this "fix" under cli option (experimental actually), but let's wait @andy-ms in microsoft/TypeScript#12020 (comment) first - it is possible (I hope) that he remember what this can lead to. |
Sounds like they added resolving of symlinks to support an |
- Added experimental `--disable-symlinks-following` cli option - Increased CLI help output max width up to 100 (instead of 80) Fixes #39
Sorry for long delay. Please check #41 and confirm that it fix your problem. There I have added new CLI option to disable resolving symlinks ( I guess that with enabling this option we can get increased memory usage (because multiple files from UPD: See microsoft/TypeScript#12020 (comment) |
After some testing I think this is not (completely) solved. The typings file has the standard ES typings in it when I used a symlinked node_modules directory (e.g. node_modules -> foobar):
I thought it was fixed because it magically works when you use ".node_modules" instead of "foobar" or ".node_modules_develop". |
Try to add symlinked folder ("foobar" or ".node_modules_develop") to exclude list in tsconfig. |
No, that doesn't change anything. I also tried setting the files list to make sure tsc doesn't pick up random files. |
Could you please provide new steps to reproduce to be sure that we talk about the same things? |
Yes, of course. Create a new directory. Place these files: app.tsexport function test(): void { } package.json{
"name": "dts-bundle-generator-bugreport",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "tsc",
"typings": "dts-bundle-generator --verbose --disable-symlinks-following -o app.d.ts app.ts"
},
"dependencies": {},
"devDependencies": {
"dts-bundle-generator": "^1.5.0",
"typescript": "^2.9.1"
}
} tsconfig.json{
"compilerOptions": {
"target": "es5",
"declaration": true,
"lib": ["es2015", "dom"]
},
"files": ["app.ts"]
} Run Move the mv node_modules foobar
ln -s foobar node_modules Run |
Thank you. I found the problem. TypeScript compiler does not use Currently, in I found in TypeScript's code function I have created a feature request to move this function to the public API (see microsoft/TypeScript/issues/25225). After approving the request, I will be able to change the code to use this function and the issue will be fixed. AFAIK this function was added in |
Version 1.6.0 is published. |
I have to admit, this is probably a quite uncommon use case, but still wanted to report it because maybe it can be fixed easily.
This is based on the same example as #37. Rename your node_modules directory and symlink it:
Then extract the typings. You will get a huge definitions file with a lot of inlined types. It seems like the symlink is confusing the logic that figures out how to deal with a dependency.
I've been using the symlink for a long time now as a technique to make it easy and fast to switch between the modules required for my develop and release branches. It hasn't caused any problems with NPM itself or other tools so far.
The text was updated successfully, but these errors were encountered: