ES Module download with Nuget
ES Module download with Nuget

Hi
Is there or will there be a way to to get the .mjs files with Nuget in visual studio ?
We are currently trying to move to using ES Modules and I can see that CDN has a .mjs version of datatables (https://cdn.datatables.net/2.3.2/js/dataTables.mjs).
Is that something they have done or are you providing two scripts ?
If you are creating the .mjs file will it be available on nuget ?
This question has accepted answers - jump to:
Answers
Sorry if it has already been answered. I could not find anything about it on the site or forums.
Sorry, it looks like I haven't updated by Nuget build script to include the ESM file. Apologies for that. I'll take a look at getting that done. I might need to take a look at some other Nuget package which provides both UMD and ESM files to see how each should be registered...
Thanks for letting me know about that.
Allan
Thanks for your answer.
Most projects I have seen does not provide .mjs files though nuget. It may be because they are old projects. Or that the developers use NPM themselves, but you are definitely not alone.
Thanks again.
By the way on the Download page the link created is only for the UMD version.
It would be nice to have a .mjs version also.
But that may be more confusing for people just wanting the minimum download.
I've just had a look at the Bootstrap Nuget package and they just put both the ESM and UDM files into the package, but there is no specification in the spec file for which files to use.
In npm we use
main
for the UDM andmodule
for the ESM file (example). As a Nuget user, perhaps you can help me out here - when you import a package, do you then need to specify which file you want to import from that package? I can't see anything in the nuspec file that would tell the bundler which file from those in the package it should use.Regarding the download builder - I can certainly look at that as an option, but from experience, those using ESM are almost always using npm or similar and a bundler. I've very rarely come across someone wanting to download the ESM files and then import them. A while back I looked into Import Maps which I thought might help (CDN or downloaded), but at the time they had too many limitations. I should go back and see what the state of play is there...
Allan
That's a commit made to all of my distribution repos to include the ESM files in the Nuget packages. They will start being included with the next release of each piece of software.
Allan
Thank you.
I don't know of any way to specify how to specify what files to download in Nuget.
You just get the files and then it's your problem. I don't think Nuget is geared towards js distribution but that is what i'm stuck with so far. I'm personally pushing for NPM and Webpack but one step at a time...
I think you are right about the download builder. It would just be an easy way for me to get/test datatables es modules since i could not get them from Nuget.
Thanks for the insight.
I'm aiming to tag a release of DataTables towards the end of the week, which will include the ESM files
Allan