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

enable discussions for dumb questions like this #51

Closed
boneskull opened this issue Mar 11, 2024 · 3 comments
Closed

enable discussions for dumb questions like this #51

boneskull opened this issue Mar 11, 2024 · 3 comments

Comments

@boneskull
Copy link

I added selfLink: false to my tshy config because I saw node_modules in my dist folder and started to worry it'd be published. But--just now--I realized that npm probably would avoid packing that folder unless explicitly instructed to (is that right?).

...but I'm still fuzzy on what selfLink: false implies. What's a local package export? The top search result for this phrase is this site.

@svallory
Copy link

A local package export is an export from the package you are building. Some people avoid using relative imports by doing import X from "my_package" where my_package is the package you are building.

Node will look for that export in the exports field of your package.json, but since tshy manages the exports
for you after the build is done, the temporary package.json it generates to compile your project will not contain it.

The work around is then to symlink your package to a node_modules inside src for compilation and inside dist to support tests that load code from dist instead of src

It will not automatically be published as npm will expect that installing your package will re-create the node_modules with all the required dependencies.

At the very end of the readme there's a Local Package Exports section with a tl;dr with more details if you want to read more.

@isaacs I also found the term "local" confusing at first. Maybe it is better to call it "current package exports" or "Importing package.json exports" ? I don't know 🤷🏻‍♂️

@boneskull
Copy link
Author

boneskull commented Mar 12, 2024

Isn't that what subpath imports are for?

Anyway...

I think this might be easier to pick up on if that TL;DR a) was first and b) was not collapsed by default.

I do wonder how prevalent this setup is, and if selfLink: false should actually be the default behavior? Given selfLink: true is the default behavior, maybe @isaacs uses this himself elsewhere; if so, it'd be helpful to see an example of where & how it's helping.

@isaacs
Copy link
Owner

isaacs commented Mar 28, 2024

I think technically the tl;dr isn't the bit that's collapsed, the tl;dr is the bit you see, and the longer explanation is the bit that's collapsed.

I've seen them referred to as "local package exports" in discussions, but the node docs calls it "self-referencing a package by its name".

@isaacs isaacs closed this as completed Mar 28, 2024
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

No branches or pull requests

3 participants