Cannot forcefully include core-js polyfill esnext.*
- Dominant language
- TypeScript
- Stars
- 44k
- Forks
- 6k
- Avg merge
- 5d 15h
- Merged PRs (30d)
- 23
Description
## Bug Report
- [ ] I would like to work on a fix!
**Current behavior**
I'd like to include certain stage-x core-js polyfills, e.g. `esnext.aggregate-error` (stage 4) or `esnext.symbol.observable`. I specify these in the `include` option, and I've also tried to import `core-js/modules/esnext.aggregate-error` manually. No error is thrown by Babel. But Babel doesn't just not include the import when expanding the `core-js` import, it actively _removes_ the explicit import, meaning there doesn't seem to be _any_ way to include a stage-4 polyfill in an application.
**Input Code**
```js
import 'core-js'
```
```js
import 'core-js'
import 'core-js/modules/esnext.aggregate-error'
const error = new AggregateError()
```
**Expected behavior**
One of these two ways should result in this import in the output file:
```js
import 'core-js/modules/esnext.aggregate-error'
```
**Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)**
- Filename: `babel.config.js`
```js
[
'@babel/preset-env',
{
useBuiltIns: 'entry',
include: [
'esnext.symbol.observable',
'esnext.aggregate-error',
],
corejs: 3,
},
```
**Environment**
```
System:
OS: macOS 10.15.5
Binaries:
Node: 14.5.0 - ~/.local/share/powershell/Modules/nvm/2.4.0/vs/v14.5.0/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.13.4 - ~/git/sourcegraph/node_modules/.bin/npm
npmPackages:
@babel/core: ^7.10.5 => 7.10.5
@babel/preset-env: ^7.10.4 => 7.10.4
```
Contributor guide
Research direction
Start with the babel.config.js configuration and reproduce both import examples using @babel/preset-env with useBuiltIns: "entry", corejs: 3, and the listed include values. Trace how Babel handles the core-js import and explicit esnext.aggregate-error import; done means the expected core-js/modules/esnext.aggregate-error import remains in the output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100