We have an ASP.NET MVC application that has a lot of JavaScript code.
To cut down the amount of unnecessary JS loaded to the browser, we use the BundleConfig.cs file to generate multiple bundles. Then on the View, we have logic to say:
"If user can user Feature A, then include Bundle A"
So, not only does the end-user get only the JS that is pertinent to their requirements, the JS also only exists on the pages where it is relevant. This gives us the very easy way to initialize our code when the page loads:
$(featureA.init);
Migrating to TypeScript (current version 3.3) ...
In Visual Studio 2017, under the Project's TypeScript Build tab, I see a check-box "Combine JavaScript output into file:" where one can specify the file name (which can be used for bundling).
- This gives me a single, site-wide JS bundle which would require me to give everyone everything.
- The on-page-load event isn't a great option anymore because the JS file is available on pages that aren't relevant, and so the jQuery selectors that fire in the 'init()' function of course now complain about not finding certain objects in the DOM because the user's not viewing the relevant page.
Am I missing something? Can TypeScript in Visual Studion 2017 handle these requirements?