Home:ALL Converter>Use babel-polyfill inside phantomjs

Use babel-polyfill inside phantomjs

Ask Time:2017-08-03T00:17:27         Author:diralik

Json Formatter

How can i use babel-polyfill inside phantomjs to get some es6 futures?

I have phantomjs 2.1.1, and babel-polyfill installed (via npm install babel-polyfill).

Here is file main.js:

require('babel-polyfill');
console.log(String.startsWith);

When i run phantomjs main.js it prints undefined to console, however babel-polyfill should add String.startsWith method.

Author:diralik,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/45466047/use-babel-polyfill-inside-phantomjs
yy