ember.js icon indicating copy to clipboard operation
ember.js copied to clipboard

Regression in extending from native classes

Open boris-petrov opened this issue 7 years ago • 4 comments

ember new ember-cannot-extend-from-native-classes
cd ember-cannot-extend-from-native-classes

Add the following test to tests/unit/services/store-test.js:

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import EmberObject from '@ember/object';

class Model extends EmberObject {
}

module('Unit | Service | Some', function(hooks) {
  setupTest(hooks);

  return test('it works', function(assert) {
    var record = Model.extend().create();
    assert.equal(record.get('x'), undefined);
  });
});

And then ember test fails. This is due to @babel packages being at version 7.4.0. 7.3.4 works fine.

boris-petrov avatar Mar 27 '19 16:03 boris-petrov

Is there a workaround for this? Just changing the version number of babel in my package lock and rerunning npm install?

Ehaic avatar Mar 29 '19 13:03 Ehaic

Yes, unfortunately the only workaround is changing the versions. But this is very error-prone as there are many packages. Also newer versions of ember-cli-babel also seem to prevent me from pinning babel packages... it's a mess. :(

boris-petrov avatar Mar 29 '19 14:03 boris-petrov

The issue seems to be in @babel/preset-env 7.4.0. Adding this to package.json (when using yarn):

  "resolutions": {
    "@babel/preset-env": "7.3.4"
  }

Fixes the issue. I hope that helps to pinpoint the issue.

boris-petrov avatar Mar 30 '19 08:03 boris-petrov

Is it possible to reproduce issue in babel?

https://babeljs.io/repl#?babili=false&browsers=edge%20%3E%3D%2015&build=&builtIns=false&spec=false&loose=false&code_lz=MYGwhgzhAECyCeB5ARgKwKbAC7QN4ChpoIswsBLYadADy3QDsATACgEo9CjoR0cBhcFGgBeaKEgxa9ZjCwALcjFwBfANxciAJz4BXLQ2iDJGoiq4kylcTrLoWABy0B7BxAA01OlrAcC3bl4BUWgFJVMAnj5ocgZLBmB0EIZ0AHcjdgiAnSx9Q1j4xIjzc3x8CWEAIWdnLxkmGAQUDGxOInxzYGc4514AOhBnAHMWauc-6UZWNj7gW3p2NjUgA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=true&fileSize=false&timeTravel=false&sourceType=module&lineWrap=false&presets=env&prettier=false&targets=&version=7.5.2&externalPlugins=

@rwjblue can it be an ember-cli-babel config issue?

I can reproduce issue with latest lts (3.8) on this https://github.com/boris-petrov/ember-extend-from-native-class-bug

once we change config/targets.js edge >= 15 -> edge >= 18 - there is no issue (and class transform)

lifeart avatar Jul 09 '19 11:07 lifeart