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

Failed to resolve entry for package "d3-graphviz" #263

Closed
Vithanco opened this issue Dec 26, 2022 · 11 comments · Fixed by #265
Closed

Failed to resolve entry for package "d3-graphviz" #263

Vithanco opened this issue Dec 26, 2022 · 11 comments · Fixed by #265

Comments

@Vithanco
Copy link

Hi Magjac!
Thanks for version 5.0.0. Great work!
Tried to make use of it and run into issue. Hope it's a real issue and I don't waste your time.

I get the error message
Failed to resolve entry for package "d3-graphviz". The package may have incorrect main/module/exports specified in its package.json.

Not fully sure what it means, but my understanding is that the main definition in package.json is faulty.
I found these parts in package.json that all look slightly odd:

  "main": "build/d3-graphviz.cjs",
  "type": "module",
  "exports": "./src/index.js",
  "jsnext:main": "index",

Two things that I see that might be tricky.

  1. There are two main definitions that seem to differ (standard vs. jsnext)
  2. Type is module but main file is cjs, so CommonJS, aka not module.

How to reproduce? I use the package in Vita setup, and it is the vite:import-analysis plugin that is throwing the issue.

Thanks!
Klaus

magjac added a commit that referenced this issue Dec 27, 2022
This was a temporary solution while porting the test cases to ESM
introduced in 04af0ab instead of
removing it in abc5c51. Once the
porting was done, the "main" entry should have been removed.

Fixes #263.
@magjac
Copy link
Owner

magjac commented Dec 27, 2022

Thanks for the kind words. Sorry about this. I hope I've fixed it in v5.0.1. I don't know how to test it. All this package.json stuff is a bit of black magic to me.

Please let me know how it goes.

@Vithanco
Copy link
Author

I am new to the world of Javascript myself, hence I totally get the black magic part. On top, it is a struggle with a constantly evolving stack.

I changed your package.json locally to

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

which was fixing the next issue.

I assume that jsnext:main would benefit from the .js but I don't really know.

@Vithanco
Copy link
Author

sorry, forgot to mention that the package wasn't accessible at all without this local change.

@magjac
Copy link
Owner

magjac commented Dec 27, 2022

Is this with v5.0.1? If so, you might want to go through https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c to ensure your application can handle pure ESM. Does it work with D3 v7?

@magjac
Copy link
Owner

magjac commented Dec 27, 2022

I see now that e.g. d3-selection uses:

  "main": "src/index.js",

Maybe the FAQ is wrong?

@magjac
Copy link
Owner

magjac commented Dec 27, 2022

Wait a minute, perhaps

  "exports": "./src/index.js",

is the culprit? There's no such file. I see now that you've changed that as well. Do you need also the "main" and "jsnext:main" entries to make it work?

@Vithanco
Copy link
Author

Vithanco commented Dec 27, 2022 via email

@magjac
Copy link
Owner

magjac commented Dec 27, 2022

Can you try without and let me know?

@Vithanco
Copy link
Author

Vithanco commented Dec 27, 2022 via email

@magjac magjac reopened this Dec 27, 2022
@magjac magjac closed this as completed in ccd6b90 Dec 27, 2022
@magjac
Copy link
Owner

magjac commented Dec 27, 2022

I released v5.0.2 with a fix for the "exports" problem. I also added a test so it won't happen again. Hopefully this works for you.

@Vithanco
Copy link
Author

It does! Thank you so much. I am well impressed by your speed and attention.

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