Reputation: 1675
I have node.js script files which I am trying to re-use inside an ASP.NET application on IE 11.
I follow below steps to use them on IE 11:
browserify Module.js --standalone mymodule -o bundle.js
Convert the ES6 version of bundle.js to ES5 by manually converting it using https://babeljs.io/repl.
Save the converted ES5 script and include the saved .js file as in ASP.NET application.
Is there anyway I can automate step 2? Is there any better way to convert Node.js files to ES5?
Upvotes: 1
Views: 3157
Reputation: 775
Since you use Browserify, you can use Babelify which is a Browserify transform:
npm install --save-dev babelify @babel/core @babel/preset-env
browserify Module.js --standalone mymodule -o bundle.js -t [ babelify --presets [ @babel/preset-env ] ]
See the babel-preset-env documentation to see how to define your target ("ie": 11
), by default all ES2015+ syntax will be transformed.
Upvotes: 3