Skip to content

Compiled folder structure wrong when using folder link #10364

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

Closed
k8w opened this issue Aug 16, 2016 · 7 comments · Fixed by #12020
Closed

Compiled folder structure wrong when using folder link #10364

k8w opened this issue Aug 16, 2016 · 7 comments · Fixed by #12020
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@k8w
Copy link

k8w commented Aug 16, 2016

TypeScript Version: 2.0.0 (on Windows)

Project structure

|- shared
    |- abc.ts

|- src
    |- shared (link to ../shared, not real folder)
    |- app.ts
    |- tsconfig.json

Code

//abc.ts
console.log('abc');

//app.ts
import './shared/abc.ts';
console.log('app')

And run cmd on Windows to create folder link:

mklink /J src\shared shared

Finally run compile command:

cd src
tsc -p . --outDir dist

Expected behavior:

file structure in folder dist as below:

|- shared
    |- abc.js
|- app.js

It works well on TypeScript@1.8.0,
and can't work after I updated it to 2.0.0.

Actual behavior:

|- shared
    |- abc.js
|- src
    |- app.js

Note that [shared] and [src] were placed at different with it on 1.8.0

The same problem on Linux

using command below to create folder link

ln -s $(pwd)/shared src/shared
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Aug 16, 2016
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 2.0.1 milestone Aug 16, 2016
@RyanCavanaugh
Copy link
Member

@vladima would you be able to take a look?

@mhegazy
Copy link
Contributor

mhegazy commented Aug 16, 2016

this looks like another manifestation of the issue in #9552.

@mhegazy mhegazy assigned ghost Aug 16, 2016
@mhegazy mhegazy modified the milestones: TypeScript 2.1, TypeScript 2.0.1 Aug 19, 2016
@flts
Copy link

flts commented Sep 23, 2016

I'm using Parallels with Shared Folders and I have symlinked my projects folder to c:\projects.
I see the following path resolving happening with tracing on:

Resolving real path for 'C:/projects/TestProject/node_modules/@angular/router/index.d.ts', result 'UNC/psf/Home/Projects/TESTPROJECT/NODE_MODULES/@angular/router/INDEX.D.TS' ======== Module name '@angular/router' was successfully resolved to 'UNC/psf/Home/Projects/TESTPROJECT/NODE_MODULES/@angular/router/INDEX.D.TS'. ========

This happens for both npm packages and project files.

@btgoodwin
Copy link

@flts I'm seeing the same issue with Typescript 2.0.2 and 2.0.3 when using npm link to pull in modules that are in development into an app's node_modules folder.

@pawelczak
Copy link

I'm facing same issues. It would be nice to have it working in next release.

@jasonswearingen
Copy link

I was able to work around the problem,:

basically the structure is like this:

myNodeApp --> slib --> xlib
            \
            +--> myInteropLib --> xlib
           /
myWebApp --> blib --> xlib

each of the references to xlib and slib are symlinked using npm link

part of the trick (of this workaround) is that you need to make sure that none of the linked module dependencies are installed into the consuming project's folder. for me, this was accomplished by deleting everything under my entire node_modules directory, then npm link xlib, and then finally npm install the remainder of the project.json dependencies.

hope that helps someone. good luck!

@mhegazy mhegazy modified the milestones: TypeScript 2.1, TypeScript 2.1.2 Oct 27, 2016
@ghost
Copy link

ghost commented Nov 1, 2016

I was able to reproduce this.
I modified the example because the import "./shared/abc.ts" syntax does nothing on invalid imports.

mkdir shared
echo 'export const x = 0;' > shared/abc.ts

mkdir src; cd src
ln -s ../shared shared
echo 'import { x } from "./shared/abc"; x + 1;' > app.ts
echo '{ "compilerOptions": { "outDir": "bin" } }' > tsconfig.json
tsc
find bin -type f

Produces:

bin/src/shared/abc.js
bin/src/app.js
bin/shared/abc.js

I would expect just bin/app.js and bin/shared/abc.js.

I also wrote a test case, but the test harness only seems to output 2 files.

// @noImplicitReferences: true
// @traceResolution: true
// Test of GH#10364

// @filename: /shared/abc.ts
// @symlink: /src/shared/abc.ts
export const x = 0;

// @filename: /src/app.ts
import { x } from './shared/abc';
x + 1;

// @filename: /src/tsconfig.json
{
    "compilerOptions": {
        "outDir": "bin"
    }
}

@ghost ghost closed this as completed in #12020 Nov 11, 2016
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Nov 13, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants