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
Summary
Correct
package.json#exports
andpackage.json#imports
support requires that we assert an"import"
or"require"
condition.From the Node.js (where this spec originated) docs:
Currently, we don't distinguish between import-ish and require-ish dependencies. This modifies
collectDependencies
to addisESMImport
to the collectedDependencyData
and dependency key (so that for exampleimport('foo')
andrequire('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]