From 0f7250d6da92361331f3c696f4ca146cc2bd95cc Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 13 Apr 2022 11:22:11 +0200 Subject: [PATCH 1/2] Add support for running the HTMLBars AST plugin on multiple files in parallel --- index.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 68727bcc..ba16ec9e 100644 --- a/index.js +++ b/index.js @@ -11,13 +11,15 @@ module.exports = { let options = app.options || {}; let config = options['ember-hbs-minifier'] || {}; - let HbsMinifierPlugin = require('./hbs-minifier-plugin').createRegistryPlugin(config); - registry.add('htmlbars-ast-plugin', { - name: 'hbs-minifier-plugin', - plugin: HbsMinifierPlugin, - baseDir() { return __dirname; }, - cacheKey() { return cacheKeyForConfig(config); } - }); + let pluginObj = this._buildPlugin(config); + + pluginObj.parallelBabel = { + requireFile: __filename, + buildUsing: '_buildPlugin', + params: config, + }; + + registry.add('htmlbars-ast-plugin', pluginObj); }, included(app) { @@ -27,7 +29,18 @@ module.exports = { Refer PR: https://github.com/ember-cli/ember-cli/pull/7059 */ this._setupPreprocessorRegistry(app); - } + }, + + _buildPlugin(config) { + let HbsMinifierPlugin = require('./hbs-minifier-plugin').createRegistryPlugin(config); + + return { + name: 'hbs-minifier-plugin', + plugin: HbsMinifierPlugin, + baseDir() { return __dirname; }, + cacheKey() { return cacheKeyForConfig(config); } + }; + }, }; function cacheKeyForConfig(config) { From 2f034415e3fb0eaf1f618b3b6cd4f99da0ebf925 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 13 Apr 2022 11:22:26 +0200 Subject: [PATCH 2/2] Enable `throwUnlessParallelizable` flag to prevent regressions --- ember-cli-build.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ember-cli-build.js b/ember-cli-build.js index 83787db4..aebd89c3 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -13,7 +13,11 @@ module.exports = function(defaults) { classes: ['description'], components: ['foo-bar', 'no-minify'] } - } + }, + + 'ember-cli-babel': { + throwUnlessParallelizable: true, + }, }); /*