josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
816 stars 108 forks source link

Fix exports for vanilla package #335

Closed Rob-Negrete closed 7 months ago

Rob-Negrete commented 8 months ago

As described on https://github.com/josdejong/svelte-jsoneditor/issues/334

This attempts to make vanilla-jsoneditor module available, specially when working in monorepos.

josdejong commented 7 months ago

Thanks for working on a fix for this issue Rob!

I'm in doubt whether this is a correct solution: the package.json file has configured "type": "module", and the index.js file in the package is an ESM file. There is no a CommonJS file. It feels like a wrong solution to introduce an entry for require in the package.json pointing to an ESM file, a require entry should point to a CommonJS file (but there is none, so that doesn't make sense) 🤔.

Rob-Negrete commented 7 months ago

Hi @josdejong,

On the contrary, thanks for making some time to review this.

Yeh, I agree there's should be a better solution than this. I tried several alternatives and this one was the first that worked to me.

Rob-Negrete commented 7 months ago

I've updated the PR. I've compared against @tinihttp/app's package.json lib. Which is also a pure ESM and it works fine, so I gave it a try and use the same exports declaration.

Not sure if this makes sense or not, but hopefully it does.

josdejong commented 7 months ago

Thanks for paving the path and debugging this issue Rob! I've worked out the solution that you've found in https://github.com/josdejong/svelte-jsoneditor/commit/3058c66c6536eaf2902f799a2e59054dbb7d4df2, which is now published in v0.19.0 Closing this PR now.