module.exports instead of global polyfill?
See original GitHub issueHi! 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:
- Created 8 years ago
- Comments:5
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
import 'setimmediate'
this is fantastic. We should add this to readme.
For the record, I’m using typescript and this works flawlessly.