-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Typescript build not working as expected with symlinks. #9552
Comments
This appears to be a problem on Mac/Linux. Symlinked node_modules do not build the same way installed node_modules do. This was not a problem in ts 1.8.x. This comes up for me because I am working on three libraries where two depend on the other. So I have library The alternatives would be-
So i'd much prefer symlinks if possible. |
+1 |
The problem here is that the compiler will follow an import to An alternative is to use intermediate .d.ts files for your projects. i.e. have Ultimately the fix would be the compiler to understand symlinks for all files, and unify files that come from the same real path. this is not a simple change, and would require some major changes to how programs are created and used. |
I am experiencing the same issue. Looking forward to a fix. |
have similar issue when using |
Here's what I tried to reproduce this: mkdir test; cd test
echo 'export const x = 0;' > foo.ts
echo '{ "name": "test" }' > package.json
cd ..; mkdir app; cd app
npm link ../test
echo 'import { x } from "test/foo"; x + 1;' > index.ts
echo '{ "compilerOptions": { "outDir": "bld" }, "exclude": [] }' > tsconfig.json
tsc This writes to Could you provide exact instructions to reproduce your problem? As an aside, trying to compile the output of |
I am using typescript 2.0.6 and having the same issues with symbolic links. I have put together a simple example that demonstrates the problem https://github.com/jmc420/typescript_examples/tree/master/symlink_problem The README explains the issue. The question is whether it is possible to get the compiler |
Have you tried changing the module resolution in your tsconfig to "classic"? https://www.typescriptlang.org/docs/handbook/module-resolution.html |
Thanks. Using "classic" module resolution is the answer. |
classic module resolution generates the code in the way that I want but using "classic" means that typings in the node_modules directory are not found. Is it possible to use classic module resolution and find the typings in the node_modules directory? |
Fixed by #12020 |
I think it's not working in 2.2.0-dev.20161113 version. Which version will include this functionality? The code works fine when I don't use npm link library |
@ert78gb Please provide steps to reproduce your error. |
If I use IntelliJ to auto build, or if I use ng serve, ng build I got the same error. If I don't use linked library the builds work the app is running with the expected result |
That may be because of the TypeScript version used by IntelliJ / angular-cli. This fix is in |
TypeScript Version: 2.0.0-dev.20160630
Code
When I use a symlink in Windows I'm getting different build results. I haven't tested this with Mac/Linux yet.
Builds to:
Using symlink
Builds to:
Expected behavior:
Building with and without a symlink should build the same.
Actual behavior:
Building without a symlink behaves normally. Building with a symlink does not treat the directory as a link but uses the actual location of the linked directory. This causes problems with module resolution.
The text was updated successfully, but these errors were encountered: