magjac / d3-graphviz

Graphviz DOT rendering and animated transitions using D3
BSD 3-Clause "New" or "Revised" License
1.69k stars 103 forks source link

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

Closed Vithanco closed 1 year ago

Vithanco commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

magjac commented 1 year ago

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 commented 1 year ago

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

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

Maybe the FAQ is wrong?

magjac commented 1 year ago

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 commented 1 year ago

That part I don’t know neither, but I assume so

On Tue, 27 Dec 2022 at 16.51, Magnus Jacobsson @.***> wrote:

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 the "main" and "jsnext:main" entries to make it work?

— Reply to this email directly, view it on GitHub https://github.com/magjac/d3-graphviz/issues/263#issuecomment-1366004066, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFFOMD5KUMPJEDO2ZZDIU3WPMGAXANCNFSM6AAAAAATJ4A7BA . You are receiving this because you authored the thread.Message ID: @.***>

-- Klaus Kneupner http://www.kneupner.de "Denn von allen Gedanken, schätz' ich doch am meisten, die interessanten" Die Sterne

magjac commented 1 year ago

Can you try without and let me know?

Vithanco commented 1 year ago

I tried earlier, and struggled with the whole. I undid my changes and it worked.., didn’t make sense. I suggest you wait until someone with more experience complaints 😇

On Tue, 27 Dec 2022 at 18.23, Magnus Jacobsson @.***> wrote:

Can you try without and let me know?

— Reply to this email directly, view it on GitHub https://github.com/magjac/d3-graphviz/issues/263#issuecomment-1366060464, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFFOMA2UV5DJN5W3VSAVX3WPMQ2LANCNFSM6AAAAAATJ4A7BA . You are receiving this because you authored the thread.Message ID: @.***>

-- Klaus Kneupner http://www.kneupner.de "Denn von allen Gedanken, schätz' ich doch am meisten, die interessanten" Die Sterne

magjac commented 1 year ago

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 commented 1 year ago

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