How should I include 3rd-party JavaScript Libraries in my ASP.NET Framework SDK-style project?

So I SDKified this ASP.NET Framework 4.8 website. I see that we have lots of nuget packages for 3rd-party libraries like infuser, trafficcop, etc. I also see that we've committed these javascript files wherever we felt like it and referenced everything to those paths. I also see that there appears to be a SO article that says not to use nuget for javascript files, even though you technically can. I recognize that we have a bit of a mess. What is the correct way of including 3rd-party JavaScript libraries? It seems super suspicious that TrafficCop has only one version available, which lends credebility that nugety may not be my best choice for including these libraries. Psst: I'm about to start migrating this crap over to .NET, but I'm trying to get as much of this project up-to-date to minimize the changes necessary to get it to work in .NET.
13 Replies
Optimum
Optimum4d ago
I think regardless, there may be packages not compatible with .NET in general, there will always be a bit of work going from 4.8 > .NET if it's a larger project
What is the correct way of including 3rd-party JavaScript libraries?
Javascript Bundlers, likely? it's not really the scope of nuget in general to manage 3rd party js libs unless it is i've not soon that
Turn2Jesus2
Turn2Jesus2OP4d ago
So should I switch to npm or something?
Optimum
Optimum4d ago
That's completely your choice, i'd personally do that, but u can utilize ASP.NET js bundlers
Turn2Jesus2
Turn2Jesus2OP4d ago
I also need to swap out (I think) the bundling to not use BundlingConfig.cs to something else
Optimum
Optimum4d ago
.NET uses something similar
Turn2Jesus2
Turn2Jesus2OP4d ago
But that's bundling, which I think is a different topic after you have the js files locally, right?
Optimum
Optimum4d ago
It's like grunt bundle javascript together but can be used for specific paths in ur pages so, 1 page can have it's own bundle That's a choice you'll need to make I personally use my own grunt file for bundling js
Turn2Jesus2
Turn2Jesus2OP4d ago
So there's the "I want to get a specific version of a javascript library installed locally on my website" and then there's "I've got a lot of JS files that need to go to the client." Does grunt handle both, or just the bundling aspect?
Optimum
Optimum4d ago
npm grunt sp npm can be the package manager for specific versions etc IDK if asp.net bundler does this
Turn2Jesus2
Turn2Jesus2OP4d ago
ASP.NET Core has a bundler finally?
Angius
Angius4d ago
There is something like that, yeah Can't say I ever used it I either use Gulp (or a Bun script, nowadays) that builds everything in FrontendCode directory and spits it out into /wwwroot
Turn2Jesus2
Turn2Jesus2OP4d ago
I wrote a ton of bundling code for .NET framework. If it's the same thing, then I'll probably try to port that. But when I did my research, that wasn't available in .NET core Is there a reference project that integrates these tools together? Preferably according to best practices.
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?