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

Commit7aa499f

Browse files
authored
Merge pull requestmicrosoft#1758 from iclanton/ianc/loc-plugin-wrapup
[localization-plugin] Fix a few issues with localized asset path renaming.
2 parents4655bf6 +6d63954 commit7aa499f

File tree

10 files changed

+35
-23
lines changed

10 files changed

+35
-23
lines changed

‎build-tests/localization-plugin-test-02/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"webpack-bundle-analyzer":"~3.6.0",
1919
"webpack-cli":"~3.3.2",
2020
"webpack-dev-server":"~3.9.0",
21-
"html-webpack-plugin":"~3.2.0"
21+
"html-webpack-plugin":"~3.2.0",
22+
"@types/lodash":"4.14.116",
23+
"lodash":"~4.17.15"
2224
}
2325
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import*aslodashfrom'lodash';
2+
13
import*asstringsfrom'./strings2.loc.json';
24

35
exportclassChunkWithStringsClass{
46
publicdoStuff():void{
5-
console.log(strings.string1);
7+
console.log(lodash.escape(strings.string1));
68
}
79
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import*aslodashfrom'lodash';
2+
13
exportclassChunkWithoutStringsClass{
24
publicdoStuff():void{
3-
console.log('STATIC STRING');
5+
console.log(lodash.escape('STATIC STRING'));
46
}
57
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// DO NOT ADD COMMENTS IN THIS FILE. They will be lost when the Rush tool resaves it.
22
{
33
"$schema":"https://developer.microsoft.com/json-schemas/rush/v5/approved-packages.schema.json",
4-
"packages": [
5-
]
4+
"packages": []
65
}

‎common/config/rush/nonbrowser-approved-packages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@
452452
},
453453
{
454454
"name":"lodash",
455-
"allowedCategories": ["libraries" ]
455+
"allowedCategories": ["libraries","tests" ]
456456
},
457457
{
458458
"name":"lodash.merge",

‎common/config/rush/pnpm-lock.yaml

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎rush.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@
863863
"packageName":"@rushstack/localization-plugin",
864864
"projectFolder":"webpack/localization-plugin",
865865
"reviewCategory":"libraries",
866-
"shouldPublish":false
866+
"shouldPublish":true
867867
},
868868
{
869869
"packageName":"@microsoft/loader-raw-script",

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ interface IExtendedChunk extends Webpack.compilation.Chunk {
5555
}
5656

5757
interfaceIAssetPathOptions{
58-
chunk:{};
58+
chunk:Webpack.compilation.Chunk;
5959
contentHashType:string;
6060
}
6161

@@ -194,10 +194,18 @@ export class LocalizationPlugin implements Webpack.Plugin {
194194
options.contentHashType==='javascript'&&
195195
assetPath.match(Constants.LOCALE_FILENAME_PLACEHOLDER_REGEX)
196196
){
197-
returnassetPath.replace(
198-
Constants.LOCALE_FILENAME_PLACEHOLDER_REGEX,
199-
`" +${Constants.JSONP_PLACEHOLDER} + "`
197+
// Does this look like an async chunk URL generator?
198+
if(typeofoptions.chunk.id==='string'&&options.chunk.id.match(/^\"\+/)){
199+
returnassetPath.replace(
200+
Constants.LOCALE_FILENAME_PLACEHOLDER_REGEX,
201+
`" +${Constants.JSONP_PLACEHOLDER} + "`
202+
);
203+
}else{
204+
returnassetPath.replace(
205+
Constants.LOCALE_FILENAME_PLACEHOLDER_REGEX,
206+
Constants.LOCALE_NAME_PLACEHOLDER
200207
);
208+
}
201209
}else{
202210
returnassetPath;
203211
}
@@ -307,7 +315,6 @@ export class LocalizationPlugin implements Webpack.Plugin {
307315
}
308316

309317
if(EntityMarker.getMark(chunk)){
310-
311318
processChunkJsFile((chunkFilename)=>{
312319
if(chunkFilename.indexOf(Constants.LOCALE_NAME_PLACEHOLDER)===-1){
313320
thrownewError(`Asset${chunkFilename} is expected to be localized, but is missing a locale placeholder`);
@@ -356,10 +363,6 @@ export class LocalizationPlugin implements Webpack.Plugin {
356363
});
357364
}else{
358365
processChunkJsFile((chunkFilename)=>{
359-
if(chunkFilename.indexOf(Constants.LOCALE_NAME_PLACEHOLDER)!==-1){
360-
thrownewError(`Asset${chunkFilename} is not expected to be localized, but has a locale placeholder`);
361-
}
362-
363366
constasset:IAsset=compilation.assets[chunkFilename];
364367

365368
constresultingAsset:IProcessAssetResult=AssetProcessor.processNonLocalizedAsset({

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,15 @@ export class TypingsGenerator {
8181
constlocFilePaths:string[]=glob.sync(
8282
path.join('**','*+(.resx|.loc.json)'),
8383
{
84-
root:this._options.srcFolder,
85-
absolute:true
84+
cwd:this._options.srcFolder,
85+
absolute:true,
86+
nosort:true,
87+
nodir:true
8688
}
8789
);
8890

8991
for(letlocFilePathoflocFilePaths){
90-
locFilePath=path.resolve(locFilePath);
92+
locFilePath=path.resolve(this._options.srcFolder,locFilePath);
9193

9294
if(filesToIgnore.has(locFilePath)){
9395
continue;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp