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

JSII does not work properly with out of source build #1273

Closed
3 of 4 tasks
jpmartin2 opened this issue Feb 18, 2020 · 2 comments · Fixed by #1344
Closed
3 of 4 tasks

JSII does not work properly with out of source build #1273

jpmartin2 opened this issue Feb 18, 2020 · 2 comments · Fixed by #1344
Assignees
Labels
bug This issue is a bug. in-progress Issue is being actively worked on. p1

Comments

@jpmartin2
Copy link

🐛 Bug Report

Affected Languages

This bug affects the generation of jsii assemblies

  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...)

General Information

  • JSII Version: 0.22.0 (build 14afdde), typescript 3.7.5
  • Platform: OSX 10.14.6

What is the problem?

When using the jsii options to override tsc outDir, no types are included in the .jsii assembly. This appears to be because of how the main file for the assembly is located:

const mainFile = path.resolve(this.projectInfo.projectRoot, this.projectInfo.types.replace(/\.d\.ts(x?)$/, '.ts$1'));
The use of the regex here to replace .d.ts with .ts assumes that the source file that created the typings file is in the same directory, which it won't be when tsc outDir is set. It seems jsii should either use the typings file as is (if that's possible), or have a separate configuration option for where the main source file is.

Verbose Log

No useful logs.

@jpmartin2 jpmartin2 added the bug This issue is a bug. label Feb 18, 2020
@jpmartin2
Copy link
Author

Also, when mainFile here doesn't exist (as in this case because of the difference in path between the types file and the source file), there's no indication that anything went wrong, jsii just silently does nothing, which seems undesirable.

@jpmartin2 jpmartin2 changed the title JSII does work properly with out of source build JSII does not work properly with out of source build Feb 19, 2020
@RomainMuller RomainMuller added the p1 label Mar 9, 2020
@RomainMuller
Copy link
Contributor

Hey @jpmartin2 - thanks for reporting. This logic is definitely buggy after the introduction of support for customizing outDir.

Feel free to submit a pull request to correct that (it shouldn't be all too hard)... Otherwise, I'll try to get to it soon!

RomainMuller added a commit that referenced this issue Mar 17, 2020
When configuring tsc.outDir, the jsii compiler would not look for the
correct source file and captured no types from the module. This
commit fixes this problem by reversing the types attribute in order
to resolve back to the corresponding source file.

Fixes #1273
@SomayaB SomayaB added the in-progress Issue is being actively worked on. label Mar 19, 2020
@mergify mergify bot closed this as completed in #1344 Mar 19, 2020
mergify bot added a commit that referenced this issue Mar 19, 2020
* fix: out-of-source builds are broken

When configuring tsc.outDir, the jsii compiler would not look for the
correct source file and captured no types from the module. This
commit fixes this problem by reversing the types attribute in order
to resolve back to the corresponding source file.

Fixes #1273

* PR feedback

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. in-progress Issue is being actively worked on. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants