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

Convenience module for CommonJS #131

Closed
larsgw opened this issue Nov 1, 2023 · 8 comments
Closed

Convenience module for CommonJS #131

larsgw opened this issue Nov 1, 2023 · 8 comments

Comments

@larsgw
Copy link
Contributor

larsgw commented Nov 1, 2023

Now that wikidata-sdk is deprecated on npm, could we have a convenience module (akin to wikibase-sdk/wikidata.org) for the CommonJS release line? I cannot convert my libraries to ESM-only.

@EdJoPaTo
Copy link
Contributor

EdJoPaTo commented Nov 1, 2023

v9 switched to ES modules which is from my personal view also the future. You should also go there in the long run. Until then v8 and the wikidata-sdk convenience module are the way to go?

But thats my own opinion. Maybe maxlath has other opinions.

@larsgw
Copy link
Contributor Author

larsgw commented Nov 1, 2023

wikidata-sdk is now marked as deprecated on npm, which means people who use my packages are getting warnings (larsgw/citation.js#230). I am also hesitant to convert to ES modules because that means all my users have to switch too, and I do not see that happening right now.

@larsgw
Copy link
Contributor Author

larsgw commented Nov 1, 2023

(So, I will indeed continue to use v8 but I was wondering if it was possible to get a wikibase-sdk/wikidata.org-like export there as well.)

@maxlath
Copy link
Owner

maxlath commented Nov 2, 2023

If wikibase-sdk@v8 works for you, that would be the recommended way indeed. You can then recreate the equivalent of wikidata-sdk with

const wdk = require('wikibase-sdk')({
  instance: 'https://www.wikidata.org',
  sparqlEndpoint: 'https://query.wikidata.org/sparql'
})

or is there any added benefit of wikibase-sdk/wikidata.org export that I'm missing?

I can't look deeper into that these days, sorry, but I guess as Typescript compiles the code anyway, it could also produce a CJS build, no? It would add to the already much increased complexity of this module though, so if we can avoid it, I would indeed prefer that.

@larsgw
Copy link
Contributor Author

larsgw commented Nov 2, 2023

or is there any added benefit of wikibase-sdk/wikidata.org export that I'm missing?

Not really.

@larsgw larsgw closed this as completed Nov 2, 2023
@EdJoPaTo
Copy link
Contributor

EdJoPaTo commented Nov 2, 2023

I guess as Typescript compiles the code anyway, it could also produce a CJS build, no?

TypeScript can do that but it would be vastly different from "just removing the type annotations". As its already ES module output and its closer to the input I would also stay at ES module output for simplicity.

All major runtimes and browsers support ES modules for years now (if it doesn't it's probably a security nightmare) and basically everything is migrating towards ES modules. It would be weird to return to CommonJS after already migrating to ESM with this library.

@larsgw
Copy link
Contributor Author

larsgw commented Nov 2, 2023

basically everything is migrating towards ES modules

Do you have statistics to back that up? Again, I don't have a problem with ES modules except that I don't want to force the users of my libraries to use them.

@EdJoPaTo
Copy link
Contributor

EdJoPaTo commented Nov 2, 2023

Do you have statistics to back that up?

No I don't have actual numbers for that. But it is what I observe. Also other pre-ESM systems get removed like Gnome 45 does with their move from GJS to ESM so its not only CommonJS that gets replaced by JavaScripts own module system.

Again, I don't have a problem with ES modules except that I don't want to force the users of my libraries to use them.

I didn't question that. Its a good cause and the reason why I haven't migrated my own libraries so far. (But I probably should on breaking changes?)

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

No branches or pull requests

3 participants