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

Different bundle behavior when we have .ts files and .d.ts files #15876

Closed
soulcorrosion opened this issue May 16, 2017 · 5 comments
Closed

Different bundle behavior when we have .ts files and .d.ts files #15876

soulcorrosion opened this issue May 16, 2017 · 5 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@soulcorrosion
Copy link

TypeScript Version: 2.2.1

Code

I have the following folder structure in my development environment.

projectB/src/moduleB.ts
packages/projectA/src/moduleA.ts

Both projects have the following tsconfig:

{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "declaration": true,    
    "rootDir": "../"
  },
  "include": [    
    "src/**/*"       
  ]
}

projectB is a dependency of projectA via node_modules. If I make a bundle on projectA, I have the following output:

System.register("projectA/src/moduleA", ["../projectB/src/moduleB"], function (exports_1, context_1) {

The dependency module name which equates to the file path is not OK (../). If I remove the moduleB.ts and leave only the typing file (moduleB.d.ts), then the path becomes "projectB/src/moduleB", which is correct.
Also, if both packages were at the same level, it would also work as expected, even with .ts and .d.ts files present.

Expected behavior:
We should get the same behavior when we have .ts files or .d.ts files.

Actual behavior:
If the packages are not at the same level and we have .ts files, the bundle produces wrong names for depenceny modules.

@mhegazy
Copy link
Contributor

mhegazy commented May 17, 2017

How are your imports defined? can you share a self contained reproduction of the issue?

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label May 17, 2017
@soulcorrosion
Copy link
Author

Sure, you can find a repo here https://github.com/soulcorrosion/typescriptSimpleProject
On projectA please call

npm install

This will link projectA to projectB in node_modules. You can then make the bundle using the target version.

tsc --outFile bundle.js

Thank you for looking into this. At the moment we have to dive in some regex to make the paths ok, but it would be great if we could avoid it.

@mhegazy
Copy link
Contributor

mhegazy commented Jun 2, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Jun 2, 2017
@jpsfs
Copy link

jpsfs commented Jun 2, 2017

@mhegazy
Can you review this please?

@soulcorrosion added more info to the issue after you added the label.
This issue is really annoying, I hope it gets fixed! :)

@pocesar
Copy link

pocesar commented Jun 19, 2017

this shouldn't be closed, I'm having to resort to manually patching the generated files...

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

4 participants