Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit52d41e7

Browse files
committed
Organize the loc stats options.
1 parent097ab91 commit52d41e7

File tree

8 files changed

+52
-28
lines changed

8 files changed

+52
-28
lines changed

‎build-tests/localization-plugin-test-01/webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ module.exports = function(env) {
5555
generatedTsFolder:path.resolve(__dirname,'temp','loc-json-ts'),
5656
sourceRoot:path.resolve(__dirname,'src')
5757
},
58-
localizationStatsDropPath:path.resolve(__dirname,'temp','localization-stats.json')
58+
localizationStats:{
59+
dropPath:path.resolve(__dirname,'temp','localization-stats.json')
60+
}
5961
}),
6062
newBundleAnalyzerPlugin({
6163
openAnalyzer:false,

‎build-tests/localization-plugin-test-02/webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ module.exports = function(env) {
7474
generatedTsFolder:path.resolve(__dirname,'temp','loc-json-ts'),
7575
sourceRoot:path.resolve(__dirname,'src')
7676
},
77-
localizationStatsDropPath:path.resolve(__dirname,'temp','localization-stats.json')
77+
localizationStats:{
78+
dropPath:path.resolve(__dirname,'temp','localization-stats.json')
79+
}
7880
}),
7981
newBundleAnalyzerPlugin({
8082
openAnalyzer:false,

‎build-tests/localization-plugin-test-03/webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ module.exports = function(env) {
9191
sourceRoot:path.resolve(__dirname,'src'),
9292
exportAsDefault:true
9393
},
94-
localizationStatsDropPath:path.resolve(__dirname,'temp','localization-stats.json')
94+
localizationStats:{
95+
dropPath:path.resolve(__dirname,'temp','localization-stats.json')
96+
}
9597
}),
9698
newBundleAnalyzerPlugin({
9799
openAnalyzer:false,

‎common/reviews/api/localization-plugin.api.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,10 @@ export interface ILocaleFileData {
2929

3030
// @public
3131
exportinterfaceILocalizationPluginOptions {
32-
// (undocumented)
33-
exportAsDefault?:boolean;
3432
// (undocumented)
3533
filesToIgnore?:string[];
3634
// (undocumented)
37-
localizationStatsCallback?: (stats:ILocalizationStats)=>void;
38-
// (undocumented)
39-
localizationStatsDropPath?:string;
35+
localizationStats?:ILocalizationStatsOptions;
4036
// (undocumented)
4137
localizedData:ILocalizedData;
4238
// (undocumented)
@@ -71,6 +67,14 @@ export interface ILocalizationStatsEntrypoint {
7167
};
7268
}
7369

70+
// @public (undocumented)
71+
exportinterfaceILocalizationStatsOptions {
72+
// (undocumented)
73+
callback?: (stats:ILocalizationStats)=>void;
74+
// (undocumented)
75+
dropPath?:string;
76+
}
77+
7478
// @public (undocumented)
7579
exportinterfaceILocalizedData {
7680
defaultLocale:IDefaultLocaleOptions;
@@ -140,6 +144,8 @@ export interface _IStringPlaceholder {
140144

141145
// @public (undocumented)
142146
exportinterfaceITypingsGenerationOptions {
147+
// (undocumented)
148+
exportAsDefault?:boolean;
143149
// (undocumented)
144150
generatedTsFolder:string;
145151
// (undocumented)

‎webpack/localization-plugin/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ if translations aren't provided for an intercepted file. To avoid that error, li
101101
by this plugin in this property. Files should be specified as either absolute paths or paths relative
102102
to the Webpack compilation context.
103103

104-
###`localizationStatsDropPath = '...'`
104+
###`localizationStats = { }`
105+
106+
####`localizationStats.dropPath = '...'`
105107

106108
This option is used to designate a path at which a JSON file describing the localized assets produced should be
107109
written. If this property is omitted, the stats file won't be written.
@@ -142,10 +144,10 @@ The file has the following format:
142144

143145
```
144146

145-
###`localizationStatsCallback = (stats) => { ... }`
147+
####`localizationStats.callback = (stats) => { ... }`
146148

147149
This option is used to specify a callback to be called with the stats data that would be dropped at
148-
[`localizationStatsDropPath`](#localizationStatsDropPath--) after compilation completes.
150+
[`localizationStats.dropPath`](#localizationStats.DropPath--) after compilation completes.
149151

150152
###`typingsOptions = { }`
151153

‎webpack/localization-plugin/src/LocalizationPlugin.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,21 @@ export class LocalizationPlugin implements Webpack.Plugin {
254254
}
255255
}
256256

257-
if(this._options.localizationStatsDropPath){
258-
constresolvedLocalizationStatsDropPath:string=path.resolve(
259-
compiler.outputPath,
260-
this._options.localizationStatsDropPath
261-
);
262-
JsonFile.save(localizationStats,resolvedLocalizationStatsDropPath);
263-
}
257+
if(this._options.localizationStats){
258+
if(this._options.localizationStats.dropPath){
259+
constresolvedLocalizationStatsDropPath:string=path.resolve(
260+
compiler.outputPath,
261+
this._options.localizationStats.dropPath
262+
);
263+
JsonFile.save(localizationStats,resolvedLocalizationStatsDropPath,{ensureFolderExists:true});
264+
}
264265

265-
if(this._options.localizationStatsCallback){
266-
try{
267-
this._options.localizationStatsCallback(localizationStats);
268-
}catch(e){
269-
/* swallow errors from the callback */
266+
if(this._options.localizationStats.callback){
267+
try{
268+
this._options.localizationStats.callback(localizationStats);
269+
}catch(e){
270+
/* swallow errors from the callback */
271+
}
270272
}
271273
}
272274
});

‎webpack/localization-plugin/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ export {
1414
ILocalizationStats,
1515
ILocalizationStatsChunkGroup,
1616
ILocalizationStatsEntrypoint,
17+
ILocalizationStatsOptions,
1718
ILocalizedData,
1819
ILocalizedStringas_ILocalizedString,
1920
ILocalizedStrings,
2021
ILocFileas_ILocFile,
21-
IPseudolocalesOptions,
22-
IPseudolocaleOptions,
2322
IPassthroughLocaleOptions,
23+
IPseudolocaleOptions,
24+
IPseudolocalesOptions,
2425
ITypingsGenerationOptions
2526
}from'./interfaces';
2627

‎webpack/localization-plugin/src/interfaces.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ export interface ILocalizedData {
8282
pseudolocales?:IPseudolocalesOptions;
8383
}
8484

85+
/**
86+
*@public
87+
*/
88+
exportinterfaceILocalizationStatsOptions{
89+
dropPath?:string;
90+
91+
callback?:(stats:ILocalizationStats)=>void;
92+
}
93+
8594
/**
8695
* The options for localization.
8796
*
@@ -92,9 +101,7 @@ export interface ILocalizationPluginOptions {
92101

93102
filesToIgnore?:string[];
94103

95-
localizationStatsDropPath?:string;
96-
97-
localizationStatsCallback?:(stats:ILocalizationStats)=>void;
104+
localizationStats?:ILocalizationStatsOptions;
98105

99106
typingsOptions?:ITypingsGenerationOptions;
100107
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp