Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(endo): Infer the module map a package exports
Packages may export any number of modules. In package.json, a library developer can specifically call out a "main" module to represent the package as a whole. For example, "./src/main.js" for the package named "ses" exports a module simply named "ses" that refers to "./src/main.js" in the "ses" package. What modules a package exports may depend on the "tags" of the host environment, like "import" for environments that support ECMAScript modules, "require" for environments that only support CommonJS modules, or "browser" for web front-ends. The "browser" property in "package.json" overrides "main" when the "browser" build tag is present. The "browser" property has broad adoption, starting with first packages to lean on Browserify. Most packages technically export every one of their modules and most environments do not enforce any notion of private modules. In Node.js 14+, the "exports" property in package.json allows a package to express exactly which modules are public, parameterized by arbitrary tags. With this change, `inferExports` only accounts for explicitly exported modules. To support most existing packages, a future change will need to take all of the files in the package into account if the "exports" property is absent.
- Loading branch information