gbv / coli-ana

API to analyze DDC numbers
https://coli-conc.gbv.de/coli-ana/app/
MIT License
2 stars 0 forks source link

Node.js 16: Issue with importing JSON in config/index.js #75

Closed stefandesu closed 1 year ago

stefandesu commented 2 years ago

Node.js requires import assertions for importing JSON modules as of v16 (see https://v8.dev/features/import-assertions). However, config/index.js is used both in the backend (Node.js) as well as in the frontend (Vue.js/Vite), and currently Vite doesn't seem to support import assertions, so it's not possible to make this work for both. Also, I think adding import assertions would break v14 compatibility.

I will add a note to README that using v14 is recommended, and also add a .node-version file, but we should figure out how to work around this issue. I haven't done much research though, so I'm sure there's a solution for this.

stefandesu commented 1 year ago

I added a workaround in 562159bed7d9073e26e9a5f4ed7d179a07794510 and it should work in all Node.js >= 14 now, but I think it would be good to require Node.js 16 and use import assertions instead. It would make the code much easier again.

stefandesu commented 1 year ago

Change the code to use modern import assertions (see https://simonplend.com/import-json-in-es-modules/ for example). Fortunately, those were backported to Node.js 16.14, so that's the new minimum required Node.js version.