Skip to content

Commit

Permalink
Merge pull request #547 from ember-cli/add-more-logging-for-ast-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed May 7, 2020
2 parents 1f44a40 + 116126b commit d4bf542
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/ember-addon-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ module.exports = {
inputTree = debugTree(new ColocatedTemplateProcessor(inputTree), '02-colocated-output');
}

this._addon.logger.debug(`setup *.hbs compiler with ${htmlbarsOptions.pluginNames}`);
const TemplateCompiler = require('./template-compiler-plugin');
return debugTree(new TemplateCompiler(inputTree, htmlbarsOptions), '03-output');
},
Expand Down Expand Up @@ -152,7 +153,9 @@ module.exports = {
let templateCompilerPath = this.templateCompilerPath();

if (pluginInfo.canParallelize) {
this.logger.debug('using parallel API with for babel inline precompilation plugin');
this.logger.debug(
`using babel inline precompilation plugin (parallelized) with ${pluginInfo.pluginNames}`
);

let htmlbarsInlinePrecompilePlugin = utils.buildParalleizedBabelPlugin(
pluginInfo,
Expand All @@ -162,7 +165,9 @@ module.exports = {

babelPlugins.push(htmlbarsInlinePrecompilePlugin);
} else {
this.logger.debug('NOT using parallel API with for babel inline precompilation plugin');
this.logger.debug(
`using babel inline precompilation plugin (NON-parallelized) with ${pluginInfo.pluginNames}`
);
this.logger.debug('Prevented by these plugins: ' + pluginInfo.unparallelizableWrappers);

let htmlBarsPlugin = utils.setup(pluginInfo, {
Expand Down
5 changes: 5 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function buildOptions(projectConfig, templateCompilerPath, pluginInfo) {
templateCompiler: require(templateCompilerPath),
templateCompilerPath: templateCompilerPath,

pluginNames: pluginInfo.pluginNames,
plugins: {
ast: pluginInfo.plugins,
},
Expand Down Expand Up @@ -221,6 +222,7 @@ function makeCacheKey(templateCompilerPath, pluginInfo, extra) {
function setupPlugins(wrappers) {
let plugins = [];
let cacheKeys = [];
let pluginNames = [];
let parallelConfigs = [];
let unparallelizableWrappers = [];
let dependencyInvalidation = false;
Expand All @@ -234,6 +236,8 @@ function setupPlugins(wrappers) {
wrapper = plugin[wrapper.buildUsing](wrapper.params);
}

pluginNames.push(wrapper.name ? wrapper.name : 'unknown plugin');

if (wrapper.parallelBabel) {
parallelConfigs.push(wrapper.parallelBabel);
} else {
Expand Down Expand Up @@ -268,6 +272,7 @@ function setupPlugins(wrappers) {

return {
plugins,
pluginNames,
cacheKeys,
parallelConfigs,
canParallelize,
Expand Down
5 changes: 5 additions & 0 deletions node-tests/utils_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('utils', function () {

assert.deepStrictEqual(actual, {
plugins: [],
pluginNames: [],
cacheKeys: [],
parallelConfigs: [],
canParallelize: true,
Expand All @@ -53,13 +54,15 @@ describe('utils', function () {
it('canParallelize for 1+ plugins with "parallelBabel" property', function () {
let pluginWrappers = [
{
name: 'first',
plugin() {},
cacheKey() {
return this.parallelBabel;
},
parallelBabel: 'something',
},
{
name: 'second',
plugin() {},
cacheKey() {
return this.parallelBabel;
Expand All @@ -72,6 +75,7 @@ describe('utils', function () {

assert.deepStrictEqual(actual, {
plugins: pluginWrappers.map((w) => w.plugin),
pluginNames: ['first', 'second'],
cacheKeys: ['something', 'something else'],
parallelConfigs: ['something', 'something else'],
canParallelize: true,
Expand Down Expand Up @@ -103,6 +107,7 @@ describe('utils', function () {

assert.deepStrictEqual(actual, {
plugins: pluginWrappers.map((w) => w.plugin),
pluginNames: ['first', 'second'],
cacheKeys: ['something', 'something else'],
parallelConfigs: ['something'],
canParallelize: false,
Expand Down

0 comments on commit d4bf542

Please sign in to comment.