# Babel Polyfills with PresetEnv

**URL:** <https://discourse.aurelia.io/t/babel-polyfills-with-presetenv/5005>\
**Category:** Help Requests\
**Created:** [December 2, 2022, 12:17am UTC](https://discourse.aurelia.io/t/babel-polyfills-with-presetenv/5005 "2022-12-02T00:17:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomorrowToday](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/tomorrowtoday/32/2343_2.png) [@TomorrowToday](https://discourse.aurelia.io/u/TomorrowToday)\
**Post date:** [December 2, 2022, 12:17am UTC](https://discourse.aurelia.io/t/babel-polyfills-with-presetenv/5005/1 "2022-12-02T00:17:23Z")

</div>

Since Aurelia only really does the bare minimum polyfilling to get Aurelia running, I’d like to get `@babel/preset-env` working. I keep running into core-js module issues that don’t make sense:

```auto
require.js:168 Uncaught Error: Module name "core-js/modules/es.array.reverse" has not been loaded yet for context: _. Use require([])
https://requirejs.org/docs/errors.html#notloaded
    at makeError (require.js:168:1)
    at Object.localRequire [as require] (require.js:1436:1)
    at requirejs (require.js:1797:1)
    at users.html:1:1

```

The `define` call is in the vendor-bundle.js, but somehow it’s not available to the app-bundle in time for it’s ‘require’ call.

babel.config.json :

```auto
{
  "presets": [
    [
      "@babel/preset-env",
      {
        "loose": true,
        "exclude": [
          "@babel/plugin-proposal-dynamic-import"
        ],
        "useBuiltIns": "usage",
        "corejs": "3.26.1",
        "debug": true
      }
    ]
  ],
  "plugins": [
    [
      "@babel/plugin-proposal-decorators",
      {
        "legacy": true
      }
    ],
    [
      "@babel/plugin-proposal-class-properties",
      {
        "loose": true
      }
    ],
    "@babel/plugin-syntax-dynamic-import"
  ]
}

```

---

<div class="post-metadata">

**Author:** ![TomorrowToday](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/tomorrowtoday/32/2343_2.png) [@TomorrowToday](https://discourse.aurelia.io/u/TomorrowToday)\
**Post date:** [December 5, 2022, 7:59pm UTC](https://discourse.aurelia.io/t/babel-polyfills-with-presetenv/5005/2 "2022-12-05T19:59:50Z")

</div>

Appears to be an open issue with Babel: [AMD modules with useBuiltIns not correctly implemented · Issue #10333 · babel/babel · GitHub](https://github.com/babel/babel/issues/10333)

Anyone here found a good workaround? I’m about to give [transform-amd-to-commonjs](https://github.com/msrose/babel-plugin-transform-amd-to-commonjs) a try

---

<div class="post-metadata">

**Author:** ![TomorrowToday](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/tomorrowtoday/32/2343_2.png) [@TomorrowToday](https://discourse.aurelia.io/u/TomorrowToday)\
**Post date:** [December 6, 2022, 8:18pm UTC](https://discourse.aurelia.io/t/babel-polyfills-with-presetenv/5005/3 "2022-12-06T20:18:48Z")

</div>

Hmmm okay, it’s a little deeper than Babel. They depend heavily on core-js and it does not transpile from cjs to any other format without major breakage. So… I’ll be taking the whole project away from requirejs so I don’t have to prepend/import the whole core-js library anymore. Fingers crossed the webpack migration will go well…

---

<div class="post-metadata">

**Author:** ![airboss001](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/airboss001/32/719_2.png) [@airboss001](https://discourse.aurelia.io/u/airboss001)\
**Post date:** [December 7, 2022, 5:19am UTC](https://discourse.aurelia.io/t/babel-polyfills-with-presetenv/5005/4 "2022-12-07T05:19:53Z")

</div>

I probably would never need this but thanks for documenting your journey on this for others that might.
