larsgw / citation.js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
https://citation.js.org/
MIT License
219 stars 30 forks source link

Wikidata plugin depends on a deprecated package #230

Closed kamoshi closed 2 weeks ago

kamoshi commented 10 months ago

I get the following warning when updating this package:

 WARN  1 deprecated subdependencies found: wikidata-sdk@8.1.1

This subdependency can be found here: https://github.com/citation-js/citation-js/blob/main/packages/plugin-wikidata/package.json

The package wikidata-sdk has been renamed to wikibase-sdk.

larsgw commented 10 months ago

I am aware of the situation with wikidata-sdk, though I did not realize users of citation-js would get warnings too. wikidata-sdk was a wrapper around wikibase-sdk before v9.0.0 of the latter was released. Since wikibase-sdk v9.0.0 however, the module uses ESM-only instead of CommonJS which would force citation-js (and its users) to switch to ESM-only too. So the deprecated wikidata-sdk is still the latest available version. I will see if I can avoid the deprecation warning anyway.

abalter commented 3 weeks ago

It's more than a warning. I get an error and loss of function.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Wikibase SDK Error Example</title>
</head>
<body>
    <script type="module">
        import { simplify } from 'https://cdn.jsdelivr.net/npm/wikibase-sdk@10.2.1/+esm';
        import Cite from 'https://cdn.jsdelivr.net/npm/citation-js@0.5.0/+esm';

        document.addEventListener('DOMContentLoaded', async function () {
            try {
                // Sample BibTeX string for demonstration
                const bibText = `
                @article{Loomes2017,
                    title={Loomes Title},
                    author={Loomes, Name},
                    journal={Journal of Examples},
                    year={2017}
                }`;

                const citationInstance = new Cite(bibText);
                console.log(citationInstance);

                // Example usage of simplify function from wikibase-sdk
                const simplified = simplify.labels({
                    en: { value: 'example', language: 'en' }
                });
                console.log(simplified);

            } catch (error) {
                console.error("Error:", error);
            }
        });
    </script>
</body>
</html>
larsgw commented 3 weeks ago

Thank you for notifying me. I'm on holiday but I'll work on it when I can.