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.

module.exports instead of global polyfill?

See original GitHub issue

Hi! I’ve tried to use this module by the CommonJS convention, like that:

var setImmediate = require('setimmediate');
setImmediate(function () {});

And found out that this code doesn’t work.

Is there a specific reason you keep to exposing setImmediate to the global scope instead of exporting a module?

It’s quite uncomfortable to use that as a polyfill as a module, because there’s a special service for polyfills, polyfill.io, which ensures the environment and in that a user can avoid importing polyfills as dependencies.

Besides, user can always compile module standalone with browserify -s, so it is not necessary to force him into using global-scope setImmediate.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
domeniccommented, Aug 27, 2015

import 'setimmediate'

0reactions
geyangcommented, Apr 1, 2016

this is fantastic. We should add this to readme.

For the record, I’m using typescript and this works flawlessly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Polyfill node core modules in webpack 5
Modify node_modules/react-scripts/config/webpack.config.js . Here's an example. This is taken from Webpack's docs. module.exports = { ...
Read more >
Shimming - webpack
The libraries might also create globals which need to be exported. These "broken modules" are one instance where shimming comes into play.
Read more >
Modules • JavaScript for impatient programmers (ES2022 ...
A module can have both named exports and a default export, but it's usually better to stick to one export style per module....
Read more >
A horrifying globalThis polyfill in universal JavaScript
The module scope hides the global scope's this value, so the this value ... Note: `var` is used instead of `const` to ensure...
Read more >
Modules: Packages | Node.js v19.3.0 Documentation
In a package's package.json file, two fields can define entry points for a package: "main" and "exports" . Both fields apply to ...
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