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

EntryPointError: libp2p fails to build - exports map support missing? #639

Open
achingbrain opened this issue May 20, 2022 · 3 comments
Open
Assignees

Comments

@achingbrain
Copy link

The libp2p module does not include a main field in it's package.json, instead it uses an export map with a "." property which is the default package entry point.

When trying to look at bundle sizes for this module I see EntryPointError: We could not guess a valid entry point for this package. - does bundlephobia understand export maps or does it only support the "main" field?

@donmccurdy
Copy link

I'm interested in this question too. I noticed the @sindresorhus/safe-stringify package is fine on bundlephobia, specifying:

	"type": "module",
	"exports": "./index.js",

https://github.com/sindresorhus/safe-stringify/blob/b1278c4c45c09a6cd888e0b94dab989ea559a941/package.json#L13-L14

But my own package fails:

  "type": "module",
  "sideEffects": false,
  "exports": "./dist/ktx-parse.modern.js",
  "types": "./dist/index.d.ts",

https://github.com/donmccurdy/KTX-Parse/blob/639716009a382c892dfdf906357b61dd271973f6/package.json#L5-L9

@owenallenaz
Copy link

owenallenaz commented Dec 2, 2022

I booted it up locally and messed around with it, and it looks like the root culprit is two issues.

  • If the package contains an "index.js" file it uses it, regardless of what is in the exports key.
  • If the package doesn't contain an index.js, as yours doesn't, and mine as well, then it just bombs. This is due to webpack version 4 in the loader system. I attempted to update it in a PR, but is really messy because it requires updating a bunch of the loaders and a really complex webpack config file. I think there's a chance if webpack was updated and the breaking changes from webpack v4 to webpack v5 were resolved the solution would "just work" like magic.

pastelsky/package-build-stats@master...owenallenaz:package-build-stats:v5-attempt . Unfortunately the webpack changes are a bit out of my depth with the intent of the package and it's internals...

patrik-csak added a commit to patrik-csak/BB26 that referenced this issue Mar 29, 2023
bundlephobia now fails with the following error message :

> EntryPointError
> We could not guess a valid entry point for this package. Perhaps the author hasn't specified one in its package.json ?

this might be the same issue : pastelsky/bundlephobia#639
Lakuna added a commit to Lakuna/umath that referenced this issue Jul 29, 2023
@achingbrain
Copy link
Author

For those still hitting this problem, I started using https://packagephobia.com instead, it supports modern packaging conventions so works with exports maps.

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

No branches or pull requests

4 participants