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

Support package.json subpath imports #836

Merged
merged 1 commit into from Sep 14, 2023
Merged

Conversation

dobesv
Copy link
Contributor

@dobesv dobesv commented Sep 13, 2023

Apply imports map from package.json to discovered dependencies. If the
dependency starts with '#' and we have a matching entry in "imports" in
the package.json we'll substitute the possible mapped imports in place of
that dependency.

Conditions can be well-known ones implemented by node, TypeScript, or webpack like
"import", "browser", "types", or "require". They can also be custom ones as configurable
in webpack configuration or using the enhanced-resolve package.

See also:

Fixes #666

@dobesv
Copy link
Contributor Author

dobesv commented Sep 13, 2023

I improved the code docs for that import map thing for the benefit of future maintainers trying to figure out what it's all about.

src/check.js Outdated Show resolved Hide resolved
Copy link
Member

@rumpl rumpl left a comment

Choose a reason for hiding this comment

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

LGTM, @dobesv if you don't mind, could you squash your commits before I merge?

@dobesv
Copy link
Contributor Author

dobesv commented Sep 13, 2023

I'm AFK now, I'll have to do it tomorrow. Doesn't GitHub have a "squash and merge" option? Or does that require a paid plan?

If you specify an "imports" field in package.json it is used to resolved imports starting with "#" in the code.

For more details, see https://nodejs.org/api/packages.html#subpath-imports
@dobesv
Copy link
Contributor Author

dobesv commented Sep 14, 2023

I squashed the commits

@rumpl rumpl merged commit b83d38b into depcheck:main Sep 14, 2023
3 checks passed
@rumpl
Copy link
Member

rumpl commented Sep 14, 2023

Thanks!

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.

Module imports defined in packages.json should not show as missing dependencies
2 participants