Skip to content

Commit

Permalink
build: print module errors in webpack:i18n task
Browse files Browse the repository at this point in the history
  • Loading branch information
bastimeyer committed Aug 25, 2021
1 parent 42f7fa9 commit d81277e
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions build/tasks/webpack/plugins/i18n-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ module.exports = class WebpackI18nCoveragePlugin {
this._BabelTraverse = require( "@babel/traverse" ).default;
this._Glimmer = require( "@glimmer/syntax" );

/** @type {Array<webpack.NormalModule>} */
this.moduleErrors = [];
/** @type {Map<string, Map<string, {vars: Set<string>, hasHTMLTags: boolean}>>} */
this.localeData = new Map();
/** @type {Map<string, Array<{params: string[], htmlSafe: boolean}>>>} */
Expand All @@ -37,11 +39,21 @@ module.exports = class WebpackI18nCoveragePlugin {
}

_onDone() {
const { grunt, localeData, translationKeys, defaultLocale, exclude } = this;

if ( this.moduleErrors.length ) {
grunt.log.writeln();
for ( const { resource, error: { name: errName, message } } of this.moduleErrors ) {
grunt.log.error( `${errName}: ${resource}\n${message}` );
grunt.log.writeln();
}
grunt.fail.fatal();
return;
}

const diff = require( "lodash/difference" );
const diffWith = require( "lodash/differenceWith" );

const { grunt, localeData, translationKeys, defaultLocale, exclude } = this;

if ( !localeData.has( defaultLocale ) ) {
throw new Error( "Missing default locale data" );
}
Expand Down Expand Up @@ -158,6 +170,11 @@ module.exports = class WebpackI18nCoveragePlugin {
return;
}

if ( module.error ) {
this.moduleErrors.push( module );
return;
}

// get built module content
const content = module.originalSource().source();

Expand Down

0 comments on commit d81277e

Please sign in to comment.