Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE8 hacks included in output, despite Internet Explorer is not a target #1031

Closed
dilyanpalauzov opened this issue Jan 2, 2022 · 2 comments
Closed
Labels

Comments

@dilyanpalauzov
Copy link

My target are recent-browsers: browserslist 'edge > 84, firefox > 79, chrome > 84, safari > 13.1' does not print Internet Explorer. I bundle using @rollup/plugin-babel:

babel.default({
    skipPreflightCheck: false,
    babelHelpers: 'bundled',
    exclude: 'node_modules/core-js/**',
    presets: [
        ['@babel/preset-env', {
            bugfixes: true,
            useBuiltIns: 'usage',
            corejs: 3,
            targets: 'edge > 84, firefox > 79, chrome > 84, safari > 13.1'
        }]
    ],
    compact: false,
})

The output contains:

// Detect IE8's incomplete defineProperty implementation
var descriptors = !fails$9(function () {
  // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
});

var objectDefineProperty = {};

var DESCRIPTORS$6 = descriptors;
var fails$8 = fails$c;
var createElement = documentCreateElement$2;

// Thank's IE8 for his funny defineProperty
var ie8DomDefine = !DESCRIPTORS$6 && !fails$8(function () {
  // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  return Object.defineProperty(createElement('div'), 'a', {
    get: function () { return 7; }
  }).a != 7;
});

from core-js/packages/core-js/internals/ie8-dom-define.js and core-js/packages/core-js/internals/descriptors.js.

  • IE8 code shall not be included in the output, since IE8 is out of scope.
  • In “Thank's IE8 for his funny defineProperty” the apostrophe shall be removed.
@zloirock
Copy link
Owner

zloirock commented Jan 2, 2022

Thanks for the issue. Yes, it's a known issue, but now, with the current architecture, it can't be properly fixed.

core-js contains thousands of cases of specific features detection. Now, core-js contains ~600 internal and external modules, moving all such cases of features detection to separate files will increase this number to some thousands. It will make mappings of modules almost unsupportable and will increase the size of any significant bundles by tens of percent.

In core-js@4, ES3 / IE8 support will be removed, some cases of such workarounds will be moved to entry points and it will significantly reduce such dead code in bundles.

@zloirock
Copy link
Owner

zloirock commented Jan 2, 2022

In “Thank's IE8 for his funny defineProperty” the apostrophe shall be removed.

Thanks, good catch.

zloirock added a commit that referenced this issue Jan 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants