-
-
Notifications
You must be signed in to change notification settings - Fork 120
Description
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)).
useBabelConfig
on fresh ember-app doesn't work #444- [Bug] browserslist and targets have no effect on the output of the build (potential performance problems as well) #417
- Challenges using babel.config.js directly #418
- Unable to override targets #296
- Error: Decorating class property failed. Please ensure that proposal-class-properties is enabled and runs after the decorators transform. #447
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.