Skip to content

feat(resolve): only use exports field when defined in package.json#8484

Closed
aleclarson wants to merge 1 commit intovitejs:mainfrom
aleclarson:feat/strict-exports
Closed

feat(resolve): only use exports field when defined in package.json#8484
aleclarson wants to merge 1 commit intovitejs:mainfrom
aleclarson:feat/strict-exports

Conversation

@aleclarson
Copy link
Contributor

Description

Match how Node's resolution algorithm works and only consider pkg.exports when it's defined.

From the Node docs:

The "exports" field provides an alternative to "main" where the package main entry point can be defined while also encapsulating the package, preventing any other entry points besides those defined in "exports".

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@bluwy
Copy link
Member

bluwy commented Jul 5, 2022

Looks like this fixes the svelte node condition issue I stumbled on recently, where pkg.module was preferred over pkg.exports because the latter ended with .mjs. I can add some tests for this soon.

@aleclarson
Copy link
Contributor Author

@bluwy awesome! 🧇

@aleclarson
Copy link
Contributor Author

Merged into #10504

@aleclarson aleclarson closed this Oct 18, 2022
@bluwy
Copy link
Member

bluwy commented Oct 18, 2022

Sorry I never got to writing the tests 😅

@aleclarson
Copy link
Contributor Author

Sorry I never got to writing the tests 😅

Honestly, I totally forgot about this PR, so no apology required :)

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