I’m trying to set up Babel with standard ASP.NET BundleConfig.cs (Bundler).
My idea is to:
Have folder with working ES6 files
Folder with components/modules
Folder with pages
ES6 file with main logic for that specific page, imported appropriate components/modules
On every build to trigger “npx babel” (transpile all working files)
Bundle transpiled files using ASP.NET’s BundleConfig.cs
I kind of fully set up the workflow but the issue now is: Babel transpiles my “import” statements, as well as “core-js” imports (which are hooked up automatically) into require('...').
I believe there is no way - not to use require('...') and to be able to support older browsers (specifically I need IE11)?
Then, what would be the best option to support these requires?
It may well transpile import statements to require, but it isn’t a module bundler. All it’s doing there is converting them to a form (commonJS, the Node format) that is easy to bundle up into one (or more) file/s. Babel itself has absolutely no idea what to do with them.
Afaik you’re going to need a (JS) module bundler (eg WebPack) here because the stuff that ships with .Net is, or was last time I used it, not really built to do this out of the box; it uses something similar to Rails asset pipeline, it just naïvely joins all the JS files together one after another, and that is not what modules do; it seems built for a point in time before modules existed (EDIT does it not come set up for Grunt?)
Also note that you’re downloading and installing Babel every time you run that command.