Skip to content

Is there a way to opt out of ember-cli-babel entirely? #446

@NullVoxPopuli

Description

@NullVoxPopuli

Related issue: #418

just wondering, given the inability to use custom babel plugins, or not transpile class properties, (and a bunch of other bugs (some as old as 2019!), that seems to have been the result of ecosystem complacency in this tool in that it is "good enough", but ultimately does too much (babel-wise)).

Does it even make sense to not use ember-cli-babel?

minimally, this is all that's needed for the style of JS we write:

export default {
 presets: ['@babel/preset-env'],
 plugins: [
   ['@babel/plugin-proposal-decorators', { legacy: true }],
   // ... @ember/debug removal
   // ... @ember/deprecations removal
   // ... ESM to AMD
 ]
};

What I removed from the above:

  • class-properties -- this isn't needed because proposal-decorators doesn't need it, and browsers all natively support class properties. At least for development, removing this could speed up builds
  • ember modules api polyfill -- since ember 3.27, the modules polyfill isn't needed. Less plugins, less faster build.

Eventually, given that I could eventually customize ember-cli-babel, I'd like to experiment with removing the ESM to AMD transform.

I know that addons can provide their own babel plugins / transforms, but, I don't think I'm at a point yet there addons' own configs even matter as I'm just trying to build the app and keep the Router in router.js as a native class with native properties, but today it looks like this:

;define("minimal-babel-demo/router", ["exports", "@ember/routing/router", "minimal-babel-demo/config/environment"], function (_exports, _router, _environment) {
 "use strict";

 Object.defineProperty(_exports, "__esModule", {
   value: true
 });
 _exports.default = void 0;

 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

 class Router extends _router.default {
   constructor(...args) {
     super(...args);

     _defineProperty(this, "location", _environment.default.locationType);

     _defineProperty(this, "rootURL", _environment.default.rootURL);
   }

 }

 _exports.default = Router;
 Router.map(function () {});
});

IF we could use custom bebel configs, then the above could be minimally,

;define("minimal-babel-demo/router", ["exports", "@ember/routing/router", "minimal-babel-demo/config/environment"], function (_exports, _router, _environment) {
"use strict";

Object.defineProperty(_exports, "__esModule", {
  value: true
});
_exports.default = void 0;

class Router extends _router.default {
  location = _environment.default.locationType;
  rootURL = _environment.default.rootURL;
}

_exports.default = Router;
Router.map(function () {});
});

Which is _significantly smaller, and should be way less boot time for apps as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions