Ember.js: Regression in extending from native classes

Created on 27 Mar 2019  路  4Comments  路  Source: emberjs/ember.js

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.

Bug Has Reproduction

Most helpful comment

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.

All 4 comments

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

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. :(

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.

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)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MelSumner picture MelSumner  路  33Comments

wycats picture wycats  路  47Comments

fivetanley picture fivetanley  路  44Comments

GendelfLugansk picture GendelfLugansk  路  43Comments

olivia picture olivia  路  36Comments