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

feat(jsii): enable source maps for declaration files #3521

Merged
merged 3 commits into from
May 10, 2022

Conversation

andrestone
Copy link
Contributor

@andrestone andrestone commented May 5, 2022

Generates declaration maps when compiling.

This is useful to help navigate source files when developing against a JSII library's repo (e.g using yarn link).


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@RomainMuller
Copy link
Contributor

Hey @andrestone - can you elaborate on why you're making this change?

Depending on the rationale (you might have thought into this a bit more than I have), I wonder if we should just always turn the flag on, instead of making it customizable? I doubt it's very expensive to have, and it's "strongly recommended" by the TypeScript documentation...

@andrestone
Copy link
Contributor Author

andrestone commented May 5, 2022

Hi @RomainMuller, thanks for your attention on this.

I think the only downside for having it always on is the fact that, depending on how developers bundle the JS package, the files might be included in the bundle, since they're emitted to outDir (and there's no use for declaration maps if you're not bundling the source files).

In my specific case, it wouldn't really make a difference (as long as I'm getting the declaration maps).

@andrestone
Copy link
Contributor Author

andrestone commented May 5, 2022

Sorry I missed your first question. This is basically to help navigate source files when developing against a JSII library's repo (e.g using yarn link).

@RomainMuller
Copy link
Contributor

Are these emitted as separate files? If so, they could be added to .npmignore...

In any case, I don't think there is much harm in actually shipping the declarations... If the corresponding sources aren't present, IDE integrations would just fall back to the "usual" process...

They could be seen as dead-weight... but I doubt that'd be very heavy, so maybe this can be ignored?

@andrestone
Copy link
Contributor Author

andrestone commented May 6, 2022

Yes, they're separate files with the extension .d.ts.map. And yes, language servers would fall back to d.ts files so it should be ok. Gonna make the changes.

@andrestone andrestone changed the title feat(jsii): allow setting declarationMap via project info feat(jsii): enable source maps for declaration files May 6, 2022
@andrestone
Copy link
Contributor Author

andrestone commented May 6, 2022

@RomainMuller I'm unsure if we rely on tsconfig-base.json for anything related to the compiler, but I've added the option there too as recommended since we're using project references in JSII itself (hence the many map files).

@RomainMuller
Copy link
Contributor

That's okay, but you should not check in all the .d.ts.map files :)

@RomainMuller RomainMuller self-assigned this May 6, 2022
@RomainMuller RomainMuller self-requested a review May 6, 2022 13:16
@andrestone
Copy link
Contributor Author

That's okay, but you should not check in all the .d.ts.map files :)

Of course! I think I checked the root .gitignore entries for *.d.ts and since I couldn't find it there I assumed the declarations were checked in for some reason which doesn't make sense.

Should be ok now.

@andrestone
Copy link
Contributor Author

Hey @RomainMuller! Sorry for the ping, just wanted to make sure there isn't anything else I could do here.

@RomainMuller
Copy link
Contributor

Hey @andrestone -- sorry I got caught up in other stuff and forgot to check back here...

At this stage, this looks good to go for me.
We can let Mergify handle it from there (unless PR validations somehow break).

@RomainMuller
Copy link
Contributor

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented May 10, 2022

update

✅ Branch has been successfully updated

@mergify
Copy link
Contributor

mergify bot commented May 10, 2022

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label May 10, 2022
@mergify
Copy link
Contributor

mergify bot commented May 10, 2022

Merging (with squash)...

@mergify mergify bot merged commit 2751ca8 into aws:main May 10, 2022
@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label May 10, 2022
RomainMuller added a commit that referenced this pull request May 20, 2022
Instead of enabling declarations maps everywhere as was done in #3521,
allow customers to define their desired source-map related configuration
in the `jsii.tsc` stanza of `package.json`.

This change in stance is motivated by how introduction of declarations
map causes broad asset hash changes in consumer code, which effectively
breaks many snapshot-based regression tests, and this feature should
hence be opt-in.
mergify bot pushed a commit that referenced this pull request Jun 1, 2022
Instead of enabling declarations maps everywhere as was done in #3521,
allow customers to define their desired source-map related configuration
in the `jsii.tsc` stanza of `package.json`.

This change in stance is motivated by how introduction of declarations
map causes broad asset hash changes in consumer code, which effectively
breaks many snapshot-based regression tests, and this feature should
hence be opt-in.



---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants