mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 15:15:48 +08:00
25fabccd59
Ember CLI will automatically run babel transformations in parallel when the config is 'serializable', and can therefore be applied in multiple processes automatically. If any plugin is defined in an unserializable way, parallelisation will be disabled. Our discourse-widget-hbs transformer was causing parallelisation to be disabled. This commit fixes that, and also enables the throwUnlessParallelizable flag so that we catch this kind of issue more easily in future. This commit also refactors our deprecation silencing system into its own file, and uses a fake babel plugin to ensure deprecations are silenced in babel worker processes. In our GitHub CI jobs, this doubles the speed of ember builds (1m30s -> 45s). It should also improve production deploy times, and cold-start dev builds.
31 lines
730 B
JavaScript
31 lines
730 B
JavaScript
"use strict";
|
|
|
|
const widgetHbsCompilerPath = require.resolve("./lib/widget-hbs-compiler");
|
|
|
|
module.exports = {
|
|
name: require("./package").name,
|
|
|
|
included() {
|
|
this._super.included.apply(this, arguments);
|
|
let addonOptions = this._getAddonOptions();
|
|
addonOptions.babel = addonOptions.babel || {};
|
|
addonOptions.babel.plugins = addonOptions.babel.plugins || [];
|
|
let babelPlugins = addonOptions.babel.plugins;
|
|
|
|
babelPlugins.push({
|
|
_parallelBabel: {
|
|
requireFile: widgetHbsCompilerPath,
|
|
useMethod: "WidgetHbsCompiler",
|
|
},
|
|
});
|
|
},
|
|
|
|
_getAddonOptions() {
|
|
return (
|
|
(this.parent && this.parent.options) ||
|
|
(this.app && this.app.options) ||
|
|
{}
|
|
);
|
|
},
|
|
};
|