question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use the polyfill

See original GitHub issue

What’s the best way to use the polyfill? I couldn’t find the better way but to include it into glob like this:

gulp.task('default', function () {
    var polyfill = './node_modules/gulp-babel/node_modules/babel-core/browser-polyfill.js'

    return gulp.src(['src/**/*.js', polyfill])
    .pipe(sourcemaps.init())
    .pipe(babel())
    .pipe(concat('all.js'))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('dist'));
});

Is there any better way?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:8
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
MikeMcElroycommented, May 13, 2015

This looks like it will re-compile the browser-polyfill through babel, which is probably not what you want? I’d suggest using mergeStream and then concat –

return mergeStream(
  gulp.src(polyfill),
  gulp.src('src/**/*.js')
    .pipe(sourcemaps.init())
    .pipe(babel())
    .pipe(sourcemaps.write('.'))
  )
  .pipe(concat('all.js'))
  .pipe(gulp.dest('dist'));
Read more comments on GitHub >

github_iconTop Results From Across the Web

When and How to Use Polyfills - Bits and Pieces - Bit.dev
The polyfill uses non-standard features in a certain browser to give JavaScript a standards-complaint way to access the feature.
Read more >
How to use polyfill in JavaScript ? - GeeksforGeeks
A polyfill provides the functions and features that the developer expects the browser to offer by default. Polyfill was coined by Remy Sharp....
Read more >
Polyfills and transpilers - The Modern JavaScript Tutorial
A script that updates/adds new functions is called “polyfill”. It “fills in” the gap and adds missing implementations. For this particular case, ...
Read more >
Introduction To Polyfills & Their Usage - Medium
A polyfill (or polyfiller) is a piece of code (or plugin) that provides the technology that we, the developers, expect the browser to...
Read more >
How to use polyfills in your React app - LogRocket Blog
A polyfill allows you to use features that are not supported by a browser (or a specific browser version) by adding a fallback...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found