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

Update TS config for better dependencies navigation #2457

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

CarlosCortizasCT
Copy link
Contributor

Summary

When a user tries to follow one of ui-kit dependency from their IDE, it will be redirected to the Typescript types declaration file. We think most of the time this user would like to be redirected to the actual source code file.

Description

The idea comes from this tweet where it's suggested to add the declarationMap configuration attribute to true.

@changeset-bot
Copy link

changeset-bot bot commented Mar 20, 2023

⚠️ No Changeset found

Latest commit: 7fe8d1b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Mar 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
ui-kit ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 20, 2023 at 4:09PM (UTC)

@CarlosCortizasCT
Copy link
Contributor Author

Not sure if we need a changeset for this one since we're not changing any of them (or maybe all of them if we look it the other way around).

Copy link
Contributor

@chloe0592 chloe0592 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this change 🎉

Copy link
Contributor

@ddouglasz ddouglasz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@emmenko
Copy link
Member

emmenko commented Mar 20, 2023

Interesting find, thanks!

Did you check how the build is affected by this?

@CarlosCortizasCT
Copy link
Contributor Author

Interesting find, thanks!

Did you check how the build is affected by this?

So my idea would be to merge this one and use the canary release to test it in both app-kit and merchant-center monorepo because I'm not sure what to specifically look for.

If you have some ideas where I should put my eye into, please let me know 🙏

@emmenko
Copy link
Member

emmenko commented Mar 20, 2023

I'm wondering how is this supposed to work. When we build the packages we generate bundle files and declaration files. The declarationMap works like a source map from what I understand but the package does not have the original source .ts files, so how is this supposed to work? 🤔

@CarlosCortizasCT
Copy link
Contributor Author

I'm wondering how is this supposed to work. When we build the packages we generate bundle files and declaration files. The declarationMap works like a source map from what I understand but the package does not have the original source .ts files, so how is this supposed to work? 🤔

Ah! I see. Yes, I didn't realize we don't include source files in the published packages.

The ways this works is exactly as you mentioned, mapping files are created for every compiled one.
Example:

{
  "version":3,
  "file":"warning.d.ts",
  "sourceRoot":"../../../src",
  "sources":["warning.ts"],
  "names":[],
  "mappings":"AAKA,KAAK,gBAAgB,GAAG,CACtB,SAAS,EAAE,OAAO,EAClB,OAAO,CAAC,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,KACZ,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC;AAOlC,eAAO,MAAM,OAAO,EAAE,gBAUrB,CAAC;AAEF,eAAO,MAAM,UAAU,cAAe,OAAO,WAAW,MAAM,SAK7D,CAAC"
}

From the tests I did locally within the ui-kit, it seems if the mapped file does not exist, you are redirected to the definitions file (same as what we have now).
I would like to test this from another package though.

So, worst case scenario, if we add this configuration we will be able to navigate to source from within our packages but that will not work from a host package (eg: appkit using uikit), but the experience in this use case would be the same as we currently have (navigate to declarations).

Another option would be for us to include source files in the published package.
I believe it could help ui-kit consumers and since we are already providing the compiled bundles, those source files won't have any affect in runtime bundles size for consumers.
Is this something we can consider?

@emmenko
Copy link
Member

emmenko commented Mar 21, 2023

Including source files could be an option yes. Should we give this a try?

@emmenko emmenko marked this pull request as draft April 4, 2023 14:15
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.

None yet

4 participants