swc icon indicating copy to clipboard operation
swc copied to clipboard

bundler: Support exports in package.json to determine entry points

Open tmpfs opened this issue 4 years ago • 1 comments

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.

tmpfs avatar Aug 10 '21 05:08 tmpfs

Does this has some work already done?

flickyiyo avatar Sep 06 '22 22:09 flickyiyo