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

Collect isESMImport and propagate through to ResolutionContext #1376

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

robhogan
Copy link
Contributor

@robhogan robhogan commented Oct 25, 2024

Summary

Correct package.json#exports and package.json#imports support requires that we assert an "import" or "require" condition.

From the Node.js (where this spec originated) docs:

"import" - matches when the package is loaded via import or import(), or via any top-level import or resolve operation by the ECMAScript module loader. Applies regardless of the module format of the target file. Always mutually exclusive with "require".
"require" - matches when the package is loaded via require(). The referenced file should be loadable with require() although the condition matches regardless of the module format of the target file. Expected formats include CommonJS, JSON, native addons, and ES modules if --experimental-require-module is enabled. Always mutually exclusive with "import".

Currently, we don't distinguish between import-ish and require-ish dependencies. This modifies collectDependencies to add isESMImport to the collected DependencyData and dependency key (so that for example import('foo') and require('foo') in the same file are considered distinct edges with potentially different resolutions).

Test Plan:
Modified unit tests
Tested E2E further down the stack

Changelog: [Internal]

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 25, 2024
@facebook-github-bot
Copy link
Contributor

@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants