Wrap wrapNativeSuper helpers in redefining functions for better tree-…#7188
Wrap wrapNativeSuper helpers in redefining functions for better tree-…#7188Andarist merged 1 commit intobabel:masterfrom
Conversation
| if (typeof Class !== "function") { | ||
| throw new TypeError("Super expression must either be null or a function"); | ||
| } | ||
| var _cache = typeof Map === "function" && new Map(); |
There was a problem hiding this comment.
Wouldn't tree-shakers remove this even if it was outside from the function, since Map is known to be pure?
There was a problem hiding this comment.
not every tool unfortunately have sets of pure builtins in their codebases (from what I know), I've tried to get rid of this statement with UglifyJS and couldnt make it work, cc @kzc
There was a problem hiding this comment.
Uglify regards Map as an unresolved global and won't reduce that expression. Even if it did recognize Map it would be conservative and assume that it can be overridden in the worst case:
$ echo '"use strict"; console.log(Map); Map=1; console.log(Map);' | node
[Function: Map]
1
Rollup, on the other hand, might be able to do it as it assumes an ES6 environment and that no builtins can be overridden.
There was a problem hiding this comment.
Then imho we should leave it in the form I've proposed. Thanks for the clarification @kzc!
a16d623 to
6ad5e9a
Compare
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/7256/ |
6ad5e9a to
0bb6204
Compare
0bb6204 to
b3246eb
Compare
* master: (131 commits) v7.0.0-beta.42 Use strict namespace behavior for mjs files. (babel#7545) Remove outdated spec deviation note [skip ci] (babel#7571) Ensure that the backward-compat logic for plugin-utils copies over the version API properly. (babel#7580) Rename actual/expected test files to input/output (babel#7578) Use helper-module-import inside entry plugin too Use helper-module-imports instead of custom import (babel#7457) Fix "Module build failed: Error: Cannot find module '@babel/types'" (babel#7575) Wrap wrapNativeSuper helpers in redefining functions for better tree-shakeability (babel#7188) Favour extends helper over objectWithoutProperties when whole object gets copied anyway (babel#7390) Fix incorrect value of _cache in _wrapNativeSuper (babel#7570) [transform-classes] Fix typo in _wrapNativeSuper helper [typeof-symbol] Guard against undefined built-in globals update to beta.41 (babel#7568) v7.0.0-beta.41 Fix import of type ConfigItem (babel#7561) Run node 9 on circleci and remove from travis (babel#7560) docs: [skip ci] fix proposal link text update preset-env after build-data (babel#7543) Re-add TEST_ONLY and use Jest's -t for TEST_GREP. (babel#7556) ...
…ature/pipe-await * 'master' of https://github.com/valtech-nyc/babel: (131 commits) v7.0.0-beta.42 Use strict namespace behavior for mjs files. (babel#7545) Remove outdated spec deviation note [skip ci] (babel#7571) Ensure that the backward-compat logic for plugin-utils copies over the version API properly. (babel#7580) Rename actual/expected test files to input/output (babel#7578) Use helper-module-import inside entry plugin too Use helper-module-imports instead of custom import (babel#7457) Fix "Module build failed: Error: Cannot find module '@babel/types'" (babel#7575) Wrap wrapNativeSuper helpers in redefining functions for better tree-shakeability (babel#7188) Favour extends helper over objectWithoutProperties when whole object gets copied anyway (babel#7390) Fix incorrect value of _cache in _wrapNativeSuper (babel#7570) [transform-classes] Fix typo in _wrapNativeSuper helper [typeof-symbol] Guard against undefined built-in globals update to beta.41 (babel#7568) v7.0.0-beta.41 Fix import of type ConfigItem (babel#7561) Run node 9 on circleci and remove from travis (babel#7560) docs: [skip ci] fix proposal link text update preset-env after build-data (babel#7543) Re-add TEST_ONLY and use Jest's -t for TEST_GREP. (babel#7556) ...
* master: (140 commits) Update to beta.42 (babel#7609) Disable flow on transformClass, fix preset-env errors (babel#7605) Logical Assignment: ensure computed key isn't recomputed (babel#7604) Remove obsolete max-len eslint rule and reformat some stuff to fit (babel#7602) Centralize Babel's own compilation config to make it easier to follow. (babel#7599) Run prettier to format all JSON. Tweak es2015-related plugin order in preset-env (babel#7586) Refactored quirky inheritance in babel-plugin-transform-classes (babel#7444) Add RegExp support to include/exclude preset-env options (babel#7242) v7.0.0-beta.42 Use strict namespace behavior for mjs files. (babel#7545) Remove outdated spec deviation note [skip ci] (babel#7571) Ensure that the backward-compat logic for plugin-utils copies over the version API properly. (babel#7580) Rename actual/expected test files to input/output (babel#7578) Use helper-module-import inside entry plugin too Use helper-module-imports instead of custom import (babel#7457) Fix "Module build failed: Error: Cannot find module '@babel/types'" (babel#7575) Wrap wrapNativeSuper helpers in redefining functions for better tree-shakeability (babel#7188) Favour extends helper over objectWithoutProperties when whole object gets copied anyway (babel#7390) Fix incorrect value of _cache in _wrapNativeSuper (babel#7570) ...
…shakeability