ember-cli / ember-cli-babel-polyfills

Split-build polyfills for evergreen and legacy browsers
MIT License
34 stars 6 forks source link

Issue with processing regenerator-runtime? #9

Closed dbashford closed 5 years ago

dbashford commented 5 years ago

Stab in the dark on the title.

When running this code

module.exports = class TransformAmd extends Filter {
  processString(contents, relativePath) {
    let file = path.basename(relativePath);

    if (DEFINE_REGEXP.test(contents) === false) {
      throw new Error(`ember-cli-babel-polyfills: unable to remap: ${file}`);
    }

That Error gets throw.

It is processing regenerator-runtime at the time, and when I print out the contents, it looks like this

define(['exports', 'core-js/stable'], function (exports, stable) { 'use strict';
  stable = stable && stable.hasOwnProperty('default') ? stable['default'] : stable;
 ...

DEFINE_REGEXP doesn't match that define statement. I'm sure I'm doing something wrong somewhere, but I sort of have no idea where to start.

dbashford commented 5 years ago

should mention, because as I dig it feels related, prior to this, I get this

'core-js/stable' is imported by ../../../../../private/var/folders/jn/r4b7mkbn6cs132g7h6tftxy86q0jcy/T/broccoli-4456DD5R4a3232CP/cache-0554-rollup/build/evergreen.js, but could not be resolved – treating it as an external dependency
'core-js/stable' is imported by ../../../../../private/var/folders/jn/r4b7mkbn6cs132g7h6tftxy86q0jcy/T/broccoli-4456DD5R4a3232CP/cache-0554-rollup/build/legacy.js, but could not be resolved – treating it as an external dependency
'core-js/stable' is imported by commonjs-external-core-js/stable, but could not be resolved – treating it as an external dependency
dbashford commented 5 years ago

Closing this. I had assumed that this library having core-js as a dependency was all that was necessary, but at least in my case I needed to add it to my own dependency list. Think I'm good.

pzuraq commented 5 years ago

I don't think you should have to add core-js yourself, that definitely seems like a bug, will dig in. Was this for an addon or an app?

dbashford commented 5 years ago

Huge app. Busy updating to latest Babel. This happened in the engine I was using as the initial guinea pig for the updates. Bunch of other libraries in my dependency graph include core-js. My best guess is the wrong one was getting yanked in and there's good chance that /stable doesn't resolve in core-js@2? Regardless, something about listing it as a top-level dependency fixed it.

image