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

Parse subpath exports from exports sugar #86

Closed
huozhi opened this issue Jul 21, 2022 · 0 comments · Fixed by #87
Closed

Parse subpath exports from exports sugar #86

huozhi opened this issue Jul 21, 2022 · 0 comments · Fixed by #87

Comments

@huozhi
Copy link
Owner

huozhi commented Jul 21, 2022

Today we need to add a package.json for a subpath folder if you want to build based on that working directory, for instance:

// pkg/a/package.json

{
   "name": "pkg-a",
   "exports": {}
}

In this way, you can build the assets based on the subpath pkg/a and generate output according to "exports" path in that package.json. Then we refer those outputs in the toplevel package.json for the corresponding subpath imports.
But this might confuse some tooling to understand the structure of the library better. Since node.js introduced the exports sugar, any subpath needs to provide a package.json just for getting assets output paths. bunchee should be able to auto detect it

Proposal

Introducing a new exports paths auto-detection feature for top level package.json.

Example

Assume we have a toplevel package foo with package.json which contains a subpath import foo/die

{
   "name": "foo",
   "exports": {
      "./die": {
          "import": "...",
          "require": "...",
          "types": "...",
      }
   }
}

Then you have your source folder of foo/die/ with entry file foo/die/index.js. In this case bunchee should read the output paths infomation from exports field if the current build working directory matches the any exports path

@huozhi huozhi linked a pull request Aug 7, 2022 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant