You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Certain ESNext features are possible to transpile or polyfill, but it may be undesirable to do so because:
the resulting code is inefficient and the benefits aren't worth it; OR
the language feature is experimental or otherwise deprecated; OR
the polyfill is not 100% correct and maybe causes more problems than it solves (for example, the polyfilled WeakMap doesn't actually get garbage collected)
In these situations, we'd prefer for the toolchain to report an error instead of transforming the expression. This would inform the developer that their code will fail on some devices, so they know to find a different approach.
Does Babel provide a way to reject certain expressions rather than transforming them?
We found an ESLint rule eslint-plugin-compat that seems to do this. But ESLint is designed to be applied to source code; it might not work very well when applied to external bundles, for example. And ESLint rules can be relatively slow because analyzes syntax, not just semantics.
Given that Babel specializes in detecting ESNext features, maybe there's a way to use Babel to solve this problem?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Certain ESNext features are possible to transpile or polyfill, but it may be undesirable to do so because:
WeakMap
doesn't actually get garbage collected)In these situations, we'd prefer for the toolchain to report an error instead of transforming the expression. This would inform the developer that their code will fail on some devices, so they know to find a different approach.
Does Babel provide a way to reject certain expressions rather than transforming them?
We found an ESLint rule eslint-plugin-compat that seems to do this. But ESLint is designed to be applied to source code; it might not work very well when applied to external bundles, for example. And ESLint rules can be relatively slow because analyzes syntax, not just semantics.
Given that Babel specializes in detecting ESNext features, maybe there's a way to use Babel to solve this problem?
CC @hbo-iecheruo
Beta Was this translation helpful? Give feedback.
All reactions