swc
swc copied to clipboard
bundler: Support exports in package.json to determine entry points
See the node exports documentation.
The interesting thing about implementing this is that it excludes access to nested imports for files that are not explicitly mapped as exported by the package. Also conditional exports:
{
"main": "./main-require.cjs",
"exports": {
"import": "./main-module.js",
"require": "./main-require.cjs"
},
"type": "module"
}
Would mean that NodeModulesResolver::resolve would now need to know whether the calling context is ESM or CommonJS in order to choose the appropriate file.
Does this has some work already done?