Bug when using `globalThis` from core-js
See original GitHub issueBug report
What is the current behavior?
This code throws in IE8 with : Object doesn't support this action
(typeof globalThis !== "undefined") && (typeof globalThis.String !== "undefined")
If the current behavior is a bug, please provide the steps to reproduce.
Test results : https://mrhenry.github.io/web-tests/#8dda6a67-3527-4f7c-b2ab-0c6a455a1710
Test source code : https://github.com/mrhenry/web-tests/blob/main/specifications/tc39/ecma262/18.1.1.globalThis/test.pure.js
Transpiled/bundled code : https://github.com/mrhenry/web-tests/blob/main/specifications/tc39/ecma262/18.1.1.globalThis/test.babel_webpack.js
Error occurs on line 1092 : https://github.com/mrhenry/web-tests/blob/main/specifications/tc39/ecma262/18.1.1.globalThis/test.babel_webpack.js#L1092
HTML file with this code : https://gist.github.com/romainmenke/f3751b88a50b8433425a1f1058ed552d loading this file in IE8 will illustrate the error
Webpack config : https://github.com/mrhenry/web-tests/blob/main/webpack.config.js
Build with Webpack CLI :
npm run webpack -- --entry $(mkfile_dir)test.pure.js --output-path $(mkfile_dir) --config webpack.config.js
https://github.com/mrhenry/web-tests/blob/main/specifications/tc39/ecma262/18.1.1.globalThis/Makefile#L9
What is the expected behavior?
I expected no interrop issues with core-js
globalThis
Other relevant information: webpack version: 5.52.1 Node.js version: 16.x Operating System: macos Additional tools: babel, core-js, preset-env
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
@romainmenke I didn’t say that this will work in your case, I say that required ESM -> CJS Babel transform that does not use accessors. For my test cases, this transform is enough, you could try to use another - for example, default
babel-plugin-transform-modules-commonjs
(however, I’m not sure that it will work in all cases).You could try to use ESM -> CJS Babel transform that does not use accessors, https://github.com/zloirock/core-js/blob/858461ea1421a53e4fdca91bcac0922f79a3762b/babel.config.js#L26.