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

Bug: subpaths for lib format are not generated properly #182

Closed
j3tan opened this issue Mar 4, 2023 · 5 comments · Fixed by #185
Closed

Bug: subpaths for lib format are not generated properly #182

j3tan opened this issue Mar 4, 2023 · 5 comments · Fixed by #185

Comments

@j3tan
Copy link

j3tan commented Mar 4, 2023

I noticed that in one of our packages, subpaths were not being built properly for lib format. ESM seems to work fine. This is highlighted by the fact that the generated exports file paths do not exist in the lib/ folder.

Package JSON example

{
 ...
  "packemon": [
    {
      "format": "esm",
      "platform": "browser",
      "inputs": {
        "index": "src/index.ts",
        "helpers": "src/helpers/index.ts",
        "utils": "src/utils/index.ts"
      }
    },
    {
      "format": "lib",
      "platform": "node",
      "inputs": {
        "index": "src/index.ts",
        "helpers": "src/helpers/index.ts",
        "utils": "src/utils/index.ts"
      }
    }
  ],
  "packageManager": "yarn@3.4.1",
  "types": "./lib/index.d.ts",
  "module": "./esm/index.js",
  "exports": {
    "./package.json": "./package.json",
    ".": {
      "browser": {
        "types": "./esm/index.d.ts",
        "module": "./esm/index.js",
        "import": "./esm/index.js"
      },
      "node": {
        "types": "./lib/index.d.ts",
        "default": "./lib/index.js"
      },
      "default": "./lib/index.js"
    },
    "./helpers": {
      "browser": {
        "types": "./esm/helpers.d.ts",
        "module": "./esm/helpers.js",
        "import": "./esm/helpers.js"
      },
      "node": {
        "types": "./lib/helpers.d.ts", <------ These do not exist
        "default": "./lib/helpers.js" <------ These do not exist 
      },
      "default": "./lib/helpers.js"
    },
    "./utils": {
      "browser": {
        "types": "./esm/utils.d.ts",
        "module": "./esm/utils.js",
        "import": "./esm/utils.js"
      },
      "node": {
        "types": "./lib/utils.d.ts", <------ These do not exist
        "default": "./lib/utils.js" <------ These do not exist
      },
      "default": "./lib/utils.js"
    }
  }
}

Example Repo:
https://github.com/j3tan/packemon-test/tree/main

Let me know if I'm missing a configuration or some important detail

@j3tan
Copy link
Author

j3tan commented Mar 4, 2023

Screenshot 2023-03-03 at 7 13 07 PM

@milesj
Copy link
Owner

milesj commented Mar 5, 2023

@j3tan It looks like esm code is being bundled, while lib is 1:1 file structure? If so, let me dig into the branching logic.

@j3tan
Copy link
Author

j3tan commented Mar 6, 2023

@milesj Yes, exactly, the lib looks to be 1:1 while the other formats provide top-level files for subpath exports

@milesj
Copy link
Owner

milesj commented Mar 6, 2023

@j3tan Dope, I believe this fixes it #185 I also noticed the ESM types were also wrong.

Can you verify before I merge?

@j3tan
Copy link
Author

j3tan commented Mar 6, 2023

@milesj Looks like the fix works! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants