Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NullVoxPopuli opened this issue Jun 5, 2022 · 0 comments
Open

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

NullVoxPopuli opened this issue Jun 5, 2022 · 0 comments

Comments

@NullVoxPopuli
Copy link
Contributor

NullVoxPopuli commented Jun 5, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant