@automattic/i18n-check-webpack-plugin 1.0.1 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +3 -0
- package/CHANGELOG.md +20 -0
- package/package.json +1 -1
- package/src/I18nCheckPlugin.js +26 -12
package/.eslintignore
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.5] - 2022-02-16
|
|
9
|
+
### Added
|
|
10
|
+
- Add timing info to debug output.
|
|
11
|
+
|
|
12
|
+
## [1.0.4] - 2022-01-27
|
|
13
|
+
### Changed
|
|
14
|
+
- Updated package dependencies.
|
|
15
|
+
|
|
16
|
+
## [1.0.3] - 2022-01-25
|
|
17
|
+
### Changed
|
|
18
|
+
- Updated package dependencies.
|
|
19
|
+
|
|
20
|
+
## [1.0.2] - 2022-01-18
|
|
21
|
+
### Changed
|
|
22
|
+
- General: update required node version to v16.13.2
|
|
23
|
+
|
|
8
24
|
## [1.0.1] - 2022-01-04
|
|
9
25
|
### Changed
|
|
10
26
|
- Updated package dependencies
|
|
@@ -22,5 +38,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
22
38
|
### Added
|
|
23
39
|
- Initial release.
|
|
24
40
|
|
|
41
|
+
[1.0.5]: https://github.com/Automattic/i18n-check-webpack-plugin/compare/v1.0.4...v1.0.5
|
|
42
|
+
[1.0.4]: https://github.com/Automattic/i18n-check-webpack-plugin/compare/v1.0.3...v1.0.4
|
|
43
|
+
[1.0.3]: https://github.com/Automattic/i18n-check-webpack-plugin/compare/v1.0.2...v1.0.3
|
|
44
|
+
[1.0.2]: https://github.com/Automattic/i18n-check-webpack-plugin/compare/v1.0.1...v1.0.2
|
|
25
45
|
[1.0.1]: https://github.com/Automattic/i18n-check-webpack-plugin/compare/v1.0.0...v1.0.1
|
|
26
46
|
[1.0.0]: https://github.com/Automattic/i18n-check-webpack-plugin/compare/v0.1.0...v1.0.0
|
package/package.json
CHANGED
package/src/I18nCheckPlugin.js
CHANGED
|
@@ -7,6 +7,7 @@ const GettextEntries = require( './GettextEntries.js' );
|
|
|
7
7
|
const GettextExtractor = require( './GettextExtractor.js' );
|
|
8
8
|
|
|
9
9
|
const debug = require( 'debug' )( PLUGIN_NAME + ':plugin' );
|
|
10
|
+
const debugtiming = require( 'debug' )( PLUGIN_NAME + ':timing' );
|
|
10
11
|
|
|
11
12
|
const schema = {
|
|
12
13
|
title: `${ PLUGIN_NAME } plugin options`,
|
|
@@ -193,11 +194,14 @@ class I18nCheckPlugin {
|
|
|
193
194
|
additionalAssets: true,
|
|
194
195
|
},
|
|
195
196
|
assets => {
|
|
197
|
+
const t0 = Date.now();
|
|
196
198
|
const promises = [];
|
|
197
199
|
for ( const filename of Object.keys( assets ) ) {
|
|
198
200
|
promises.push( this.#processAsset( compilation, filename, moduleCache ) );
|
|
199
201
|
}
|
|
200
|
-
return Promise.all( promises )
|
|
202
|
+
return Promise.all( promises ).finally( () => {
|
|
203
|
+
debugtiming( `Processed all assets in ${ Date.now() - t0 }ms` );
|
|
204
|
+
} );
|
|
201
205
|
}
|
|
202
206
|
);
|
|
203
207
|
} );
|
|
@@ -211,6 +215,7 @@ class I18nCheckPlugin {
|
|
|
211
215
|
* @param {Map} moduleCache - Cache for processed modules.
|
|
212
216
|
*/
|
|
213
217
|
async #processAsset( compilation, filename, moduleCache ) {
|
|
218
|
+
const t0 = Date.now();
|
|
214
219
|
const asset = compilation.getAsset( filename );
|
|
215
220
|
|
|
216
221
|
// Detemine if we even need to process this asset. JavaScript assets seem to always
|
|
@@ -226,28 +231,36 @@ class I18nCheckPlugin {
|
|
|
226
231
|
|
|
227
232
|
// Extract strings from the source resources.
|
|
228
233
|
const sourceEntries = new Set();
|
|
234
|
+
const promises = [];
|
|
229
235
|
for ( const resource of asset.info.resources ) {
|
|
230
236
|
if ( ! moduleCache.has( resource ) ) {
|
|
231
|
-
const promise =
|
|
232
|
-
|
|
233
|
-
.extractFromFile( resource, {
|
|
234
|
-
filename: npath.relative( compilation.compiler.context, resource ),
|
|
235
|
-
} )
|
|
236
|
-
.then( resolve );
|
|
237
|
+
const promise = this.#extractor.extractFromFile( resource, {
|
|
238
|
+
filename: npath.relative( compilation.compiler.context, resource ),
|
|
237
239
|
} );
|
|
238
240
|
moduleCache.set( resource, promise );
|
|
239
241
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
promises.push(
|
|
243
|
+
moduleCache.get( resource ).then( resourceEntries => {
|
|
244
|
+
resourceEntries.forEach( e => sourceEntries.add( e ) );
|
|
245
|
+
} )
|
|
246
|
+
);
|
|
242
247
|
}
|
|
243
248
|
|
|
244
249
|
// Extract strings from the asset.
|
|
245
250
|
const lintLogger = s => {
|
|
246
251
|
compilation[ this.#reportkey ].push( new Error( s ) );
|
|
247
252
|
};
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
253
|
+
let babelFile, assetEntries;
|
|
254
|
+
promises.push(
|
|
255
|
+
( async () => {
|
|
256
|
+
const source = asset.source.source();
|
|
257
|
+
babelFile = await this.#extractor.parse( source, { filename, lintLogger } );
|
|
258
|
+
assetEntries = this.#extractor.extractFromAst( babelFile, { filename, lintLogger } );
|
|
259
|
+
} )()
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
// Wait for all the extractions to complete.
|
|
263
|
+
await Promise.all( promises );
|
|
251
264
|
|
|
252
265
|
// Analyze. First, collect the missing entries and report any entries with lost translator comments.
|
|
253
266
|
const missingEntries = new GettextEntries();
|
|
@@ -348,6 +361,7 @@ class I18nCheckPlugin {
|
|
|
348
361
|
)
|
|
349
362
|
);
|
|
350
363
|
}
|
|
364
|
+
debugtiming( `Processed asset ${ filename } in ${ Date.now() - t0 }ms` );
|
|
351
365
|
}
|
|
352
366
|
}
|
|
353
367
|
|