@rushstack/webpack5-localization-plugin 0.5.9 → 0.5.10
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/LICENSE +24 -24
- package/README.md +209 -209
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/AssetProcessor.js.map +1 -1
- package/lib/LocalizationPlugin.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/loaders/IResxLoaderOptions.js.map +1 -1
- package/lib/loaders/LoaderFactory.js.map +1 -1
- package/lib/loaders/default-locale-loader.js.map +1 -1
- package/lib/loaders/loc-loader.js.map +1 -1
- package/lib/loaders/locjson-loader.js.map +1 -1
- package/lib/loaders/resjson-loader.js.map +1 -1
- package/lib/loaders/resx-loader.js.map +1 -1
- package/lib/utilities/Constants.js.map +1 -1
- package/lib/utilities/EntityMarker.js.map +1 -1
- package/lib/utilities/LoaderTerminalProvider.js.map +1 -1
- package/lib/webpackInterfaces.js.map +1 -1
- package/package.json +3 -3
package/LICENSE
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
@rushstack/webpack5-localization-plugin
|
2
|
-
|
3
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
4
|
-
|
5
|
-
MIT License
|
6
|
-
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
8
|
-
a copy of this software and associated documentation files (the
|
9
|
-
"Software"), to deal in the Software without restriction, including
|
10
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
11
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
-
permit persons to whom the Software is furnished to do so, subject to
|
13
|
-
the following conditions:
|
14
|
-
|
15
|
-
The above copyright notice and this permission notice shall be
|
16
|
-
included in all copies or substantial portions of the Software.
|
17
|
-
|
18
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
@rushstack/webpack5-localization-plugin
|
2
|
+
|
3
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
4
|
+
|
5
|
+
MIT License
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
a copy of this software and associated documentation files (the
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be
|
16
|
+
included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
@@ -1,209 +1,209 @@
|
|
1
|
-
# @rushstack/webpack5-localization-plugin
|
2
|
-
|
3
|
-
## Installation
|
4
|
-
|
5
|
-
`npm install @rushstack/webpack5-localization-plugin --save-dev`
|
6
|
-
|
7
|
-
## Overview
|
8
|
-
|
9
|
-
This Webpack plugin produces bundles that have multiple locales' variants of strings embedded. It also
|
10
|
-
has out-of-box support for RESX files in addition to JSON strings files (with the extensions `.loc.json` or `.resjson`).
|
11
|
-
|
12
|
-
The loaders can also be chained with other loaders that convert the content to one of the known formats.
|
13
|
-
|
14
|
-
# Plugin
|
15
|
-
|
16
|
-
To use the plugin, add it to the `plugins` array of your Webpack config, and specify one or more loaders. For example:
|
17
|
-
|
18
|
-
```JavaScript
|
19
|
-
import { LocalizationPlugin } from '@rushstack/webpack5-localization-plugin';
|
20
|
-
|
21
|
-
{
|
22
|
-
plugins: [
|
23
|
-
new LocalizationPlugin( /* options */ )
|
24
|
-
],
|
25
|
-
module: {
|
26
|
-
rules: [{
|
27
|
-
test: /\.resjson$/,
|
28
|
-
use: {
|
29
|
-
// All loaders are available in `@rushstack/webpack5-localization-plugin/lib/loaders/`
|
30
|
-
// Loaders for specific formats: `resjson-loader`, `locjson-loader`, `resx-loader`
|
31
|
-
// Loader that switches on file extension: `loc-loader`
|
32
|
-
// Loader that switches on file extension and skips localization: `default-locale-loader`
|
33
|
-
loader: require.resolve('@rushstack/webpack5-localization-plugin/lib/loaders/resjson-loader')
|
34
|
-
},
|
35
|
-
// Can be one of `javascript/esm`, `javascript/dynamic`, or `json`
|
36
|
-
// `javascript/esm` will produce the smallest bundle sizes, while `json` will produce faster code for large string tables
|
37
|
-
type: 'javascript/esm',
|
38
|
-
sideEffects: false
|
39
|
-
}]
|
40
|
-
}
|
41
|
-
}
|
42
|
-
```
|
43
|
-
|
44
|
-
***A note about the dev server:*** When Webpack is being run by the Webpack dev server, this plugin pipes
|
45
|
-
the strings in the loc files in the source (the `.loc.json` and the `.resx` files) to the output without
|
46
|
-
any translations.
|
47
|
-
|
48
|
-
## Options
|
49
|
-
|
50
|
-
### `localizedData = { }`
|
51
|
-
|
52
|
-
#### `localizedData.defaultLocale = { }`
|
53
|
-
|
54
|
-
This option has a required property (`localeName`), to specify the name of the locale used in the
|
55
|
-
`.resx` and `.loc.json` files in the source.
|
56
|
-
|
57
|
-
##### `localizedData.defaultLocale.fillMissingTranslationStrings = true | false`
|
58
|
-
|
59
|
-
If this option is set to `true`, strings that are missing from `localizedData.translatedStrings` will be
|
60
|
-
provided by the default locale (the strings in the `.resx` and `.loc.json` files in the source). If
|
61
|
-
this option is unset or set to `false`, an error will be emitted if a string is missing from
|
62
|
-
`localizedData.translatedStrings`.
|
63
|
-
|
64
|
-
#### `localizedData.translatedStrings = { }`
|
65
|
-
|
66
|
-
This option is used to specify the localization data to be used in the build. This object has the following
|
67
|
-
structure:
|
68
|
-
|
69
|
-
- Locale name
|
70
|
-
- Compilation context-relative or absolute localization file path
|
71
|
-
- Translated strings
|
72
|
-
|
73
|
-
For example:
|
74
|
-
|
75
|
-
```JavaScript
|
76
|
-
translatedStrings: {
|
77
|
-
"en-us": {
|
78
|
-
"./src/strings1.loc.json": {
|
79
|
-
"string1": "the first string"
|
80
|
-
}
|
81
|
-
},
|
82
|
-
"es-es": {
|
83
|
-
"./src/strings1.loc.json": {
|
84
|
-
"string1": "la primera cadena"
|
85
|
-
}
|
86
|
-
}
|
87
|
-
}
|
88
|
-
```
|
89
|
-
|
90
|
-
Alternatively, instead of directly specifying the translations, a path to a translated resource file can be
|
91
|
-
specified. For example:
|
92
|
-
|
93
|
-
```JavaScript
|
94
|
-
translatedStrings: {
|
95
|
-
"en-us": {
|
96
|
-
"./src/strings1.loc.json": "./localization/en-us/strings1.loc.json"
|
97
|
-
},
|
98
|
-
"es-es": {
|
99
|
-
"./src/strings1.loc.json": "./localization/es-es/strings1.loc.json"
|
100
|
-
}
|
101
|
-
}
|
102
|
-
```
|
103
|
-
|
104
|
-
#### `localizedData.resolveMissingTranslatedStrings = (locales: string[], filePath: string, context: LoaderContext<{}>) => { ... }`
|
105
|
-
|
106
|
-
This optional option can be used to resolve translated data that is missing from data that is provided
|
107
|
-
in the `localizedData.translatedStrings` option. Set this option with a function expecting two parameters:
|
108
|
-
the first, an array of locale names, and second, a fully-qualified path to the localized file in source. The
|
109
|
-
function should synchronously or asynchronously (as a promise) return an object (or map) with locale names as keys and localized
|
110
|
-
data as values. The localized data value should be one of:
|
111
|
-
|
112
|
-
- a string: The absolute path to the translated data in `.resx`, `.loc.json`, or `.resjson` format
|
113
|
-
- an object: An object containing the translated data
|
114
|
-
- a map: A map containing the translated data
|
115
|
-
|
116
|
-
Note that these values are the same as the values that can be specified for translations for a localized
|
117
|
-
resource in `localizedData.translatedStrings`.
|
118
|
-
|
119
|
-
If the function returns data that is missing locales or individual strings, the plugin will fall back to the
|
120
|
-
default locale if `localizedData.defaultLocale.fillMissingTranslationStrings` is set to `true`. If
|
121
|
-
`localizedData.defaultLocale.fillMissingTranslationStrings` is set to `false`, an error will result.
|
122
|
-
|
123
|
-
#### `localizedData.passthroughLocale = { }`
|
124
|
-
|
125
|
-
This option is used to specify how and if a passthrough locale should be generated. A passthrough locale
|
126
|
-
is a generated locale in which each string's value is its name. This is useful for debugging and for identifying
|
127
|
-
cases where a locale is missing.
|
128
|
-
|
129
|
-
This option takes two optional properties:
|
130
|
-
|
131
|
-
##### `localizedData.passthroughLocale.usePassthroughLocale = true | false`
|
132
|
-
|
133
|
-
If `passthroughLocale.usePassthroughLocale` is set to `true`, a passthrough locale will be included in the output.
|
134
|
-
By default, the passthrough locale's name is "passthrough."
|
135
|
-
|
136
|
-
##### `localizedData.passthroughLocale.passthroughLocaleName = '...'`
|
137
|
-
|
138
|
-
If `passthroughLocale.usePassthroughLocale` is set to `true`, the "passthrough" locale name can be overridden
|
139
|
-
by setting a value on `passthroughLocale.passthroughLocaleName`.
|
140
|
-
|
141
|
-
#### `localizedData.pseudolocales = { }`
|
142
|
-
|
143
|
-
This option allows pseudolocales to be generated from the strings in the default locale. This option takes
|
144
|
-
an option with pseudolocales as keys and options for the
|
145
|
-
[pseudolocale package](https://www.npmjs.com/package/pseudolocale) as values.
|
146
|
-
|
147
|
-
### `noStringsLocaleName = '...'`
|
148
|
-
|
149
|
-
The value to replace the `[locale]` token with for chunks without localized strings. Defaults to "none"
|
150
|
-
|
151
|
-
### `runtimeLocaleExpression = '...'`
|
152
|
-
|
153
|
-
A chunk of raw ECMAScript to inject into the webpack runtime to resolve the current locale at execution time. Allows
|
154
|
-
multiple locales to share the same runtime chunk if it does not directly contain localized strings.
|
155
|
-
|
156
|
-
### `localizationStats = { }`
|
157
|
-
|
158
|
-
#### `localizationStats.dropPath = '...'`
|
159
|
-
|
160
|
-
This option is used to designate a path at which a JSON file describing the localized assets produced should be
|
161
|
-
written. If this property is omitted, the stats file won't be written.
|
162
|
-
|
163
|
-
The file has the following format:
|
164
|
-
|
165
|
-
```JSON
|
166
|
-
{
|
167
|
-
"entrypoints": {
|
168
|
-
"<BUNDLE NAME>": {
|
169
|
-
"localizedAssets": {
|
170
|
-
"<LOCALE NAME>": "<ASSET NAME>",
|
171
|
-
"<LOCALE NAME>": "<ASSET NAME>"
|
172
|
-
}
|
173
|
-
},
|
174
|
-
"<BUNDLE NAME>": {
|
175
|
-
"localizedAssets": {
|
176
|
-
"<LOCALE NAME>": "<ASSET NAME>",
|
177
|
-
"<LOCALE NAME>": "<ASSET NAME>"
|
178
|
-
}
|
179
|
-
}
|
180
|
-
},
|
181
|
-
"namedChunkGroups": {
|
182
|
-
"<CHUNK NAME>": {
|
183
|
-
"localizedAssets": {
|
184
|
-
"<LOCALE NAME>": "<ASSET NAME>",
|
185
|
-
"<LOCALE NAME>": "<ASSET NAME>"
|
186
|
-
}
|
187
|
-
},
|
188
|
-
"<CHUNK NAME>": {
|
189
|
-
"localizedAssets": {
|
190
|
-
"<LOCALE NAME>": "<ASSET NAME>",
|
191
|
-
"<LOCALE NAME>": "<ASSET NAME>"
|
192
|
-
}
|
193
|
-
}
|
194
|
-
}
|
195
|
-
}
|
196
|
-
|
197
|
-
```
|
198
|
-
|
199
|
-
#### `localizationStats.callback = (stats) => { ... }`
|
200
|
-
|
201
|
-
This option is used to specify a callback to be called with the stats data that would be dropped at
|
202
|
-
[`localizationStats.dropPath`](#localizationStats.DropPath--) after compilation completes.
|
203
|
-
|
204
|
-
## Links
|
205
|
-
|
206
|
-
- [CHANGELOG.md](https://github.com/microsoft/rushstack/blob/main/webpack/localization-plugin/CHANGELOG.md) - Find
|
207
|
-
out what's new in the latest version
|
208
|
-
|
209
|
-
`@rushstack/webpack5-localization-plugin` is part of the [Rush Stack](https://rushstack.io/) family of projects.
|
1
|
+
# @rushstack/webpack5-localization-plugin
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
`npm install @rushstack/webpack5-localization-plugin --save-dev`
|
6
|
+
|
7
|
+
## Overview
|
8
|
+
|
9
|
+
This Webpack plugin produces bundles that have multiple locales' variants of strings embedded. It also
|
10
|
+
has out-of-box support for RESX files in addition to JSON strings files (with the extensions `.loc.json` or `.resjson`).
|
11
|
+
|
12
|
+
The loaders can also be chained with other loaders that convert the content to one of the known formats.
|
13
|
+
|
14
|
+
# Plugin
|
15
|
+
|
16
|
+
To use the plugin, add it to the `plugins` array of your Webpack config, and specify one or more loaders. For example:
|
17
|
+
|
18
|
+
```JavaScript
|
19
|
+
import { LocalizationPlugin } from '@rushstack/webpack5-localization-plugin';
|
20
|
+
|
21
|
+
{
|
22
|
+
plugins: [
|
23
|
+
new LocalizationPlugin( /* options */ )
|
24
|
+
],
|
25
|
+
module: {
|
26
|
+
rules: [{
|
27
|
+
test: /\.resjson$/,
|
28
|
+
use: {
|
29
|
+
// All loaders are available in `@rushstack/webpack5-localization-plugin/lib/loaders/`
|
30
|
+
// Loaders for specific formats: `resjson-loader`, `locjson-loader`, `resx-loader`
|
31
|
+
// Loader that switches on file extension: `loc-loader`
|
32
|
+
// Loader that switches on file extension and skips localization: `default-locale-loader`
|
33
|
+
loader: require.resolve('@rushstack/webpack5-localization-plugin/lib/loaders/resjson-loader')
|
34
|
+
},
|
35
|
+
// Can be one of `javascript/esm`, `javascript/dynamic`, or `json`
|
36
|
+
// `javascript/esm` will produce the smallest bundle sizes, while `json` will produce faster code for large string tables
|
37
|
+
type: 'javascript/esm',
|
38
|
+
sideEffects: false
|
39
|
+
}]
|
40
|
+
}
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
44
|
+
***A note about the dev server:*** When Webpack is being run by the Webpack dev server, this plugin pipes
|
45
|
+
the strings in the loc files in the source (the `.loc.json` and the `.resx` files) to the output without
|
46
|
+
any translations.
|
47
|
+
|
48
|
+
## Options
|
49
|
+
|
50
|
+
### `localizedData = { }`
|
51
|
+
|
52
|
+
#### `localizedData.defaultLocale = { }`
|
53
|
+
|
54
|
+
This option has a required property (`localeName`), to specify the name of the locale used in the
|
55
|
+
`.resx` and `.loc.json` files in the source.
|
56
|
+
|
57
|
+
##### `localizedData.defaultLocale.fillMissingTranslationStrings = true | false`
|
58
|
+
|
59
|
+
If this option is set to `true`, strings that are missing from `localizedData.translatedStrings` will be
|
60
|
+
provided by the default locale (the strings in the `.resx` and `.loc.json` files in the source). If
|
61
|
+
this option is unset or set to `false`, an error will be emitted if a string is missing from
|
62
|
+
`localizedData.translatedStrings`.
|
63
|
+
|
64
|
+
#### `localizedData.translatedStrings = { }`
|
65
|
+
|
66
|
+
This option is used to specify the localization data to be used in the build. This object has the following
|
67
|
+
structure:
|
68
|
+
|
69
|
+
- Locale name
|
70
|
+
- Compilation context-relative or absolute localization file path
|
71
|
+
- Translated strings
|
72
|
+
|
73
|
+
For example:
|
74
|
+
|
75
|
+
```JavaScript
|
76
|
+
translatedStrings: {
|
77
|
+
"en-us": {
|
78
|
+
"./src/strings1.loc.json": {
|
79
|
+
"string1": "the first string"
|
80
|
+
}
|
81
|
+
},
|
82
|
+
"es-es": {
|
83
|
+
"./src/strings1.loc.json": {
|
84
|
+
"string1": "la primera cadena"
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
```
|
89
|
+
|
90
|
+
Alternatively, instead of directly specifying the translations, a path to a translated resource file can be
|
91
|
+
specified. For example:
|
92
|
+
|
93
|
+
```JavaScript
|
94
|
+
translatedStrings: {
|
95
|
+
"en-us": {
|
96
|
+
"./src/strings1.loc.json": "./localization/en-us/strings1.loc.json"
|
97
|
+
},
|
98
|
+
"es-es": {
|
99
|
+
"./src/strings1.loc.json": "./localization/es-es/strings1.loc.json"
|
100
|
+
}
|
101
|
+
}
|
102
|
+
```
|
103
|
+
|
104
|
+
#### `localizedData.resolveMissingTranslatedStrings = (locales: string[], filePath: string, context: LoaderContext<{}>) => { ... }`
|
105
|
+
|
106
|
+
This optional option can be used to resolve translated data that is missing from data that is provided
|
107
|
+
in the `localizedData.translatedStrings` option. Set this option with a function expecting two parameters:
|
108
|
+
the first, an array of locale names, and second, a fully-qualified path to the localized file in source. The
|
109
|
+
function should synchronously or asynchronously (as a promise) return an object (or map) with locale names as keys and localized
|
110
|
+
data as values. The localized data value should be one of:
|
111
|
+
|
112
|
+
- a string: The absolute path to the translated data in `.resx`, `.loc.json`, or `.resjson` format
|
113
|
+
- an object: An object containing the translated data
|
114
|
+
- a map: A map containing the translated data
|
115
|
+
|
116
|
+
Note that these values are the same as the values that can be specified for translations for a localized
|
117
|
+
resource in `localizedData.translatedStrings`.
|
118
|
+
|
119
|
+
If the function returns data that is missing locales or individual strings, the plugin will fall back to the
|
120
|
+
default locale if `localizedData.defaultLocale.fillMissingTranslationStrings` is set to `true`. If
|
121
|
+
`localizedData.defaultLocale.fillMissingTranslationStrings` is set to `false`, an error will result.
|
122
|
+
|
123
|
+
#### `localizedData.passthroughLocale = { }`
|
124
|
+
|
125
|
+
This option is used to specify how and if a passthrough locale should be generated. A passthrough locale
|
126
|
+
is a generated locale in which each string's value is its name. This is useful for debugging and for identifying
|
127
|
+
cases where a locale is missing.
|
128
|
+
|
129
|
+
This option takes two optional properties:
|
130
|
+
|
131
|
+
##### `localizedData.passthroughLocale.usePassthroughLocale = true | false`
|
132
|
+
|
133
|
+
If `passthroughLocale.usePassthroughLocale` is set to `true`, a passthrough locale will be included in the output.
|
134
|
+
By default, the passthrough locale's name is "passthrough."
|
135
|
+
|
136
|
+
##### `localizedData.passthroughLocale.passthroughLocaleName = '...'`
|
137
|
+
|
138
|
+
If `passthroughLocale.usePassthroughLocale` is set to `true`, the "passthrough" locale name can be overridden
|
139
|
+
by setting a value on `passthroughLocale.passthroughLocaleName`.
|
140
|
+
|
141
|
+
#### `localizedData.pseudolocales = { }`
|
142
|
+
|
143
|
+
This option allows pseudolocales to be generated from the strings in the default locale. This option takes
|
144
|
+
an option with pseudolocales as keys and options for the
|
145
|
+
[pseudolocale package](https://www.npmjs.com/package/pseudolocale) as values.
|
146
|
+
|
147
|
+
### `noStringsLocaleName = '...'`
|
148
|
+
|
149
|
+
The value to replace the `[locale]` token with for chunks without localized strings. Defaults to "none"
|
150
|
+
|
151
|
+
### `runtimeLocaleExpression = '...'`
|
152
|
+
|
153
|
+
A chunk of raw ECMAScript to inject into the webpack runtime to resolve the current locale at execution time. Allows
|
154
|
+
multiple locales to share the same runtime chunk if it does not directly contain localized strings.
|
155
|
+
|
156
|
+
### `localizationStats = { }`
|
157
|
+
|
158
|
+
#### `localizationStats.dropPath = '...'`
|
159
|
+
|
160
|
+
This option is used to designate a path at which a JSON file describing the localized assets produced should be
|
161
|
+
written. If this property is omitted, the stats file won't be written.
|
162
|
+
|
163
|
+
The file has the following format:
|
164
|
+
|
165
|
+
```JSON
|
166
|
+
{
|
167
|
+
"entrypoints": {
|
168
|
+
"<BUNDLE NAME>": {
|
169
|
+
"localizedAssets": {
|
170
|
+
"<LOCALE NAME>": "<ASSET NAME>",
|
171
|
+
"<LOCALE NAME>": "<ASSET NAME>"
|
172
|
+
}
|
173
|
+
},
|
174
|
+
"<BUNDLE NAME>": {
|
175
|
+
"localizedAssets": {
|
176
|
+
"<LOCALE NAME>": "<ASSET NAME>",
|
177
|
+
"<LOCALE NAME>": "<ASSET NAME>"
|
178
|
+
}
|
179
|
+
}
|
180
|
+
},
|
181
|
+
"namedChunkGroups": {
|
182
|
+
"<CHUNK NAME>": {
|
183
|
+
"localizedAssets": {
|
184
|
+
"<LOCALE NAME>": "<ASSET NAME>",
|
185
|
+
"<LOCALE NAME>": "<ASSET NAME>"
|
186
|
+
}
|
187
|
+
},
|
188
|
+
"<CHUNK NAME>": {
|
189
|
+
"localizedAssets": {
|
190
|
+
"<LOCALE NAME>": "<ASSET NAME>",
|
191
|
+
"<LOCALE NAME>": "<ASSET NAME>"
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
197
|
+
```
|
198
|
+
|
199
|
+
#### `localizationStats.callback = (stats) => { ... }`
|
200
|
+
|
201
|
+
This option is used to specify a callback to be called with the stats data that would be dropped at
|
202
|
+
[`localizationStats.dropPath`](#localizationStats.DropPath--) after compilation completes.
|
203
|
+
|
204
|
+
## Links
|
205
|
+
|
206
|
+
- [CHANGELOG.md](https://github.com/microsoft/rushstack/blob/main/webpack/localization-plugin/CHANGELOG.md) - Find
|
207
|
+
out what's new in the latest version
|
208
|
+
|
209
|
+
`@rushstack/webpack5-localization-plugin` is part of the [Rush Stack](https://rushstack.io/) family of projects.
|
package/dist/tsdoc-metadata.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AssetProcessor.js","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAI3D,iEAAmD;AA6DtC,QAAA,iBAAiB,GAAW,IAAI,MAAM,CACjD,GAAG,SAAS,CAAC,yBAAyB,8BAA8B,EACpE,GAAG,CACJ,CAAC;AAEF,SAAgB,qBAAqB,CAAC,OAAsC;IAC1E,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;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I,EAAE,SAAS;oBACf,KAAK;oBACL,GAAG;oBACH,gBAAgB;oBAChB,OAAO,EAAE,eAAe;iBACzB,CAAC;gBACF,8BAA8B,GAAG,cAAc,CAAC;gBAChD,MAAM;aACP;YAED,KAAK,SAAS,CAAC,uBAAuB,CAAC,CAAC;gBACtC,MAAM,cAAc,GAAkC;oBACpD,IAAI,EAAE,SAAS;oBACf,KAAK;oBACL,GAAG;oBACH,gBAAgB;oBAChB,OAAO,EAAE,gBAAgB;iBAC1B,CAAC;gBACF,8BAA8B,GAAG,cAAc,CAAC;gBAChD,MAAM;aACP;YAED,OAAO,CAAC,CAAC;gBACP,MAAM,IAAI,KAAK,CAAC,oBAAoB,YAAY,EAAE,CAAC,CAAC;aACrD;SACF;QAED,oBAAoB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;KAC3D;IAED,OAAO;QACL,MAAM;QACN,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { Asset, AssetInfo, Chunk, Compilation, sources } from 'webpack';\n\nimport * as Constants from './utilities/Constants';\nimport type { LocalizationPlugin, IStringPlaceholder } from './LocalizationPlugin';\nimport type { ILocalizedWebpackChunk, IAssetPathOptions } from './webpackInterfaces';\n\ninterface ILocalizedReconstructionElement {\n kind: 'localized';\n start: number;\n end: number;\n escapedBackslash: string;\n data: IStringPlaceholder;\n}\n\ninterface IDynamicReconstructionElement {\n kind: 'dynamic';\n start: number;\n end: number;\n escapedBackslash: string;\n valueFn: (locale: string) => string;\n}\n\ntype IReconstructionElement = ILocalizedReconstructionElement | IDynamicReconstructionElement;\n\ninterface IParseResult {\n issues: string[];\n reconstructionSeries: IReconstructionElement[];\n}\n\ninterface ILocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\ninterface INonLocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\nexport interface IProcessAssetOptionsBase {\n plugin: LocalizationPlugin;\n compilation: Compilation;\n chunk: Chunk;\n asset: Asset;\n}\n\nexport interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {\n fileName: string;\n noStringsLocaleName: string;\n}\n\nexport interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase {\n locales: Set<string>;\n fillMissingTranslationStrings: boolean;\n defaultLocale: string;\n filenameTemplate: Parameters<typeof Compilation.prototype.getAssetPath>[0];\n}\n\nexport interface IProcessAssetResult {\n filename: string;\n asset: sources.Source;\n}\n\nexport const PLACEHOLDER_REGEX: RegExp = new RegExp(\n `${Constants.STRING_PLACEHOLDER_PREFIX}_(\\\\\\\\*)_([A-C])_([0-9a-f]+)`,\n 'g'\n);\n\nexport function processLocalizedAsset(options: IProcessLocalizedAssetOptions): Record<string, string> {\n const { compilation, asset, chunk, filenameTemplate, locales } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const rawSource: sources.CachedSource = new sources.CachedSource(asset.source);\n const assetSource: string = rawSource.source().toString();\n\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(options.plugin, assetSource);\n\n const { issues } = parsedAsset;\n\n const localizedFiles: Record<string, string> = {};\n (chunk as ILocalizedWebpackChunk).localizedFiles = localizedFiles;\n\n const { info: originInfo, name: originName } = asset;\n if (!originInfo.related) {\n originInfo.related = {};\n }\n\n for (const locale of locales) {\n const { issues: localeIssues, result: localeResult } = _reconstructLocalized(\n new sources.ReplaceSource(rawSource, locale),\n parsedAsset.reconstructionSeries,\n locale,\n options.fillMissingTranslationStrings ? options.defaultLocale : undefined\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n const data: IAssetPathOptions = {\n chunk,\n contentHashType: 'javascript',\n // The locale property will get processed by the extension to the getAssetPath hook\n locale\n };\n\n const fileName: string = compilation.getAssetPath(filenameTemplate, data);\n\n originInfo.related[locale] = fileName;\n\n const info: AssetInfo = {\n ...originInfo,\n locale\n };\n\n const wrapped: sources.CachedSource = new sources.CachedSource(localeResult);\n localizedFiles[locale] = fileName;\n\n if (originName === fileName) {\n // This helper throws if the asset doesn't already exist\n compilation.updateAsset(fileName, wrapped, info);\n } else {\n // This helper throws if the asset already exists\n compilation.emitAsset(fileName, wrapped, info);\n }\n }\n\n if (issues.length > 0) {\n compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n return localizedFiles;\n}\n\nexport function processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): void {\n const { asset, fileName, compilation } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const rawSource: sources.CachedSource = new sources.CachedSource(asset.source);\n const assetSource: string = rawSource.source().toString();\n\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(options.plugin, assetSource);\n\n const { info: originInfo } = asset;\n const { issues } = parsedAsset;\n\n const locale: string = options.noStringsLocaleName;\n const { issues: localeIssues, result } = _reconstructNonLocalized(\n new sources.ReplaceSource(rawSource, locale),\n parsedAsset.reconstructionSeries,\n locale\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n const info: AssetInfo = {\n ...originInfo,\n locale\n };\n\n const wrapped: sources.CachedSource = new sources.CachedSource(result);\n compilation.updateAsset(fileName, wrapped, info);\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n}\n\nconst ESCAPE_MAP: Map<string, string> = new Map([\n ['\\r', 'r'],\n ['\\n', 'n'],\n ['\\t', 't'],\n ['\"', 'u0022'],\n [\"'\", 'u0027']\n]);\n\nconst BACKSLASH_REGEX: RegExp = /\\\\/g;\nconst ESCAPE_REGEX: RegExp = /[\\r\\n\\t\"']/g;\n\nfunction _reconstructLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n locale: string,\n fallbackLocale: string | undefined\n): ILocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n const { data } = element;\n let newValue: string | undefined = data.valuesByLocale.get(locale);\n if (newValue === undefined) {\n if (fallbackLocale) {\n newValue = data.valuesByLocale.get(fallbackLocale)!;\n } else {\n issues.push(\n `The string \"${data.stringName}\" in \"${data.locFilePath}\" is missing in ` +\n `the locale ${locale}`\n );\n\n newValue = '-- MISSING STRING --';\n }\n }\n\n const escapedBackslash: string = element.escapedBackslash || '\\\\';\n\n // Replace backslashes with the properly escaped backslash\n BACKSLASH_REGEX.lastIndex = -1;\n newValue = newValue.replace(BACKSLASH_REGEX, escapedBackslash);\n\n // @todo: look into using JSON.parse(...) to get the escaping characters\n const escapingCharacterSequence: string = escapedBackslash.slice(escapedBackslash.length / 2);\n\n // Ensure the the quotemark, apostrophe, tab, and newline characters are properly escaped\n ESCAPE_REGEX.lastIndex = -1;\n newValue = newValue.replace(\n ESCAPE_REGEX,\n (match) => `${escapingCharacterSequence}${ESCAPE_MAP.get(match)}`\n );\n\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(locale);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _reconstructNonLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n noStringsLocaleName: string\n): INonLocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n issues.push(\n `The string \"${element.data.stringName}\" in \"${element.data.locFilePath}\" appeared in an asset ` +\n 'that is not expected to contain localized resources.'\n );\n\n const newValue: string = '-- NOT EXPECTED TO BE LOCALIZED --';\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(noStringsLocaleName);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _rawLocaleToken(locale: string): string {\n return locale;\n}\n\nfunction _jsonLocaleToken(locale: string): string {\n return JSON.stringify(locale);\n}\n\nfunction _parseStringToReconstructionSequence(plugin: LocalizationPlugin, source: string): IParseResult {\n const issues: string[] = [];\n const reconstructionSeries: IReconstructionElement[] = [];\n\n let regexResult: RegExpExecArray | null;\n PLACEHOLDER_REGEX.lastIndex = -1;\n while ((regexResult = PLACEHOLDER_REGEX.exec(source))) {\n const [placeholder, escapedBackslash, elementLabel, placeholderSerialNumber] = regexResult;\n const start: number = regexResult.index;\n const end: number = start + placeholder.length;\n\n let localizedReconstructionElement: IReconstructionElement;\n switch (elementLabel) {\n case Constants.STRING_PLACEHOLDER_LABEL: {\n const stringData: IStringPlaceholder | undefined =\n plugin.getDataForSerialNumber(placeholderSerialNumber);\n if (!stringData) {\n issues.push(`Missing placeholder ${placeholder}`);\n continue;\n } else {\n const localizedElement: ILocalizedReconstructionElement = {\n kind: 'localized',\n start,\n end,\n escapedBackslash,\n data: stringData\n };\n localizedReconstructionElement = localizedElement;\n }\n break;\n }\n\n case Constants.LOCALE_NAME_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n escapedBackslash,\n valueFn: _rawLocaleToken\n };\n localizedReconstructionElement = dynamicElement;\n break;\n }\n\n case Constants.JSONP_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n escapedBackslash,\n valueFn: _jsonLocaleToken\n };\n localizedReconstructionElement = dynamicElement;\n break;\n }\n\n default: {\n throw new Error(`Unexpected label ${elementLabel}`);\n }\n }\n\n reconstructionSeries.push(localizedReconstructionElement);\n }\n\n return {\n issues,\n reconstructionSeries\n };\n}\n"]}
|
1
|
+
{"version":3,"file":"AssetProcessor.js","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAI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,GAAoC;wBACxD,IAAI,EAAE,WAAW;wBACjB,KAAK;wBACL,GAAG;wBACH,gBAAgB;wBAChB,IAAI,EAAE,UAAU;qBACjB,CAAC;oBACF,8BAA8B,GAAG,gBAAgB,CAAC;iBACnD;gBACD,MAAM;aACP;YAED,KAAK,SAAS,CAAC,6BAA6B,CAAC,CAAC;gBAC5C,MAAM,cAAc,GAAkC;oBACpD,IAAI,EAAE,SAAS;oBACf,KAAK;oBACL,GAAG;oBACH,gBAAgB;oBAChB,OAAO,EAAE,eAAe;iBACzB,CAAC;gBACF,8BAA8B,GAAG,cAAc,CAAC;gBAChD,MAAM;aACP;YAED,KAAK,SAAS,CAAC,uBAAuB,CAAC,CAAC;gBACtC,MAAM,cAAc,GAAkC;oBACpD,IAAI,EAAE,SAAS;oBACf,KAAK;oBACL,GAAG;oBACH,gBAAgB;oBAChB,OAAO,EAAE,gBAAgB;iBAC1B,CAAC;gBACF,8BAA8B,GAAG,cAAc,CAAC;gBAChD,MAAM;aACP;YAED,OAAO,CAAC,CAAC;gBACP,MAAM,IAAI,KAAK,CAAC,oBAAoB,YAAY,EAAE,CAAC,CAAC;aACrD;SACF;QAED,oBAAoB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;KAC3D;IAED,OAAO;QACL,MAAM;QACN,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { Asset, AssetInfo, Chunk, Compilation, sources } from 'webpack';\r\n\r\nimport * as Constants from './utilities/Constants';\r\nimport type { LocalizationPlugin, IStringPlaceholder } from './LocalizationPlugin';\r\nimport type { ILocalizedWebpackChunk, IAssetPathOptions } from './webpackInterfaces';\r\n\r\ninterface ILocalizedReconstructionElement {\r\n kind: 'localized';\r\n start: number;\r\n end: number;\r\n escapedBackslash: string;\r\n data: IStringPlaceholder;\r\n}\r\n\r\ninterface IDynamicReconstructionElement {\r\n kind: 'dynamic';\r\n start: number;\r\n end: number;\r\n escapedBackslash: string;\r\n valueFn: (locale: string) => string;\r\n}\r\n\r\ntype IReconstructionElement = ILocalizedReconstructionElement | IDynamicReconstructionElement;\r\n\r\ninterface IParseResult {\r\n issues: string[];\r\n reconstructionSeries: IReconstructionElement[];\r\n}\r\n\r\ninterface ILocalizedReconstructionResult {\r\n result: sources.ReplaceSource;\r\n issues: string[];\r\n}\r\n\r\ninterface INonLocalizedReconstructionResult {\r\n result: sources.ReplaceSource;\r\n issues: string[];\r\n}\r\n\r\nexport interface IProcessAssetOptionsBase {\r\n plugin: LocalizationPlugin;\r\n compilation: Compilation;\r\n chunk: Chunk;\r\n asset: Asset;\r\n}\r\n\r\nexport interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {\r\n fileName: string;\r\n noStringsLocaleName: string;\r\n}\r\n\r\nexport interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase {\r\n locales: Set<string>;\r\n fillMissingTranslationStrings: boolean;\r\n defaultLocale: string;\r\n filenameTemplate: Parameters<typeof Compilation.prototype.getAssetPath>[0];\r\n}\r\n\r\nexport interface IProcessAssetResult {\r\n filename: string;\r\n asset: sources.Source;\r\n}\r\n\r\nexport const PLACEHOLDER_REGEX: RegExp = new RegExp(\r\n `${Constants.STRING_PLACEHOLDER_PREFIX}_(\\\\\\\\*)_([A-C])_([0-9a-f]+)`,\r\n 'g'\r\n);\r\n\r\nexport function processLocalizedAsset(options: IProcessLocalizedAssetOptions): Record<string, string> {\r\n const { compilation, asset, chunk, filenameTemplate, locales } = options;\r\n\r\n const { sources, WebpackError } = compilation.compiler.webpack;\r\n\r\n const rawSource: sources.CachedSource = new sources.CachedSource(asset.source);\r\n const assetSource: string = rawSource.source().toString();\r\n\r\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(options.plugin, assetSource);\r\n\r\n const { issues } = parsedAsset;\r\n\r\n const localizedFiles: Record<string, string> = {};\r\n (chunk as ILocalizedWebpackChunk).localizedFiles = localizedFiles;\r\n\r\n const { info: originInfo, name: originName } = asset;\r\n if (!originInfo.related) {\r\n originInfo.related = {};\r\n }\r\n\r\n for (const locale of locales) {\r\n const { issues: localeIssues, result: localeResult } = _reconstructLocalized(\r\n new sources.ReplaceSource(rawSource, locale),\r\n parsedAsset.reconstructionSeries,\r\n locale,\r\n options.fillMissingTranslationStrings ? options.defaultLocale : undefined\r\n );\r\n\r\n for (const issue of localeIssues) {\r\n issues.push(issue);\r\n }\r\n\r\n const data: IAssetPathOptions = {\r\n chunk,\r\n contentHashType: 'javascript',\r\n // The locale property will get processed by the extension to the getAssetPath hook\r\n locale\r\n };\r\n\r\n const fileName: string = compilation.getAssetPath(filenameTemplate, data);\r\n\r\n originInfo.related[locale] = fileName;\r\n\r\n const info: AssetInfo = {\r\n ...originInfo,\r\n locale\r\n };\r\n\r\n const wrapped: sources.CachedSource = new sources.CachedSource(localeResult);\r\n localizedFiles[locale] = fileName;\r\n\r\n if (originName === fileName) {\r\n // This helper throws if the asset doesn't already exist\r\n compilation.updateAsset(fileName, wrapped, info);\r\n } else {\r\n // This helper throws if the asset already exists\r\n compilation.emitAsset(fileName, wrapped, info);\r\n }\r\n }\r\n\r\n if (issues.length > 0) {\r\n compilation.errors.push(\r\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\r\n );\r\n }\r\n\r\n return localizedFiles;\r\n}\r\n\r\nexport function processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): void {\r\n const { asset, fileName, compilation } = options;\r\n\r\n const { sources, WebpackError } = compilation.compiler.webpack;\r\n\r\n const rawSource: sources.CachedSource = new sources.CachedSource(asset.source);\r\n const assetSource: string = rawSource.source().toString();\r\n\r\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(options.plugin, assetSource);\r\n\r\n const { info: originInfo } = asset;\r\n const { issues } = parsedAsset;\r\n\r\n const locale: string = options.noStringsLocaleName;\r\n const { issues: localeIssues, result } = _reconstructNonLocalized(\r\n new sources.ReplaceSource(rawSource, locale),\r\n parsedAsset.reconstructionSeries,\r\n locale\r\n );\r\n\r\n for (const issue of localeIssues) {\r\n issues.push(issue);\r\n }\r\n\r\n const info: AssetInfo = {\r\n ...originInfo,\r\n locale\r\n };\r\n\r\n const wrapped: sources.CachedSource = new sources.CachedSource(result);\r\n compilation.updateAsset(fileName, wrapped, info);\r\n\r\n if (issues.length > 0) {\r\n options.compilation.errors.push(\r\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\r\n );\r\n }\r\n}\r\n\r\nconst ESCAPE_MAP: Map<string, string> = new Map([\r\n ['\\r', 'r'],\r\n ['\\n', 'n'],\r\n ['\\t', 't'],\r\n ['\"', 'u0022'],\r\n [\"'\", 'u0027']\r\n]);\r\n\r\nconst BACKSLASH_REGEX: RegExp = /\\\\/g;\r\nconst ESCAPE_REGEX: RegExp = /[\\r\\n\\t\"']/g;\r\n\r\nfunction _reconstructLocalized(\r\n result: sources.ReplaceSource,\r\n reconstructionSeries: IReconstructionElement[],\r\n locale: string,\r\n fallbackLocale: string | undefined\r\n): ILocalizedReconstructionResult {\r\n const issues: string[] = [];\r\n\r\n for (const element of reconstructionSeries) {\r\n switch (element.kind) {\r\n case 'localized': {\r\n const { data } = element;\r\n let newValue: string | undefined = data.valuesByLocale.get(locale);\r\n if (newValue === undefined) {\r\n if (fallbackLocale) {\r\n newValue = data.valuesByLocale.get(fallbackLocale)!;\r\n } else {\r\n issues.push(\r\n `The string \"${data.stringName}\" in \"${data.locFilePath}\" is missing in ` +\r\n `the locale ${locale}`\r\n );\r\n\r\n newValue = '-- MISSING STRING --';\r\n }\r\n }\r\n\r\n const escapedBackslash: string = element.escapedBackslash || '\\\\';\r\n\r\n // Replace backslashes with the properly escaped backslash\r\n BACKSLASH_REGEX.lastIndex = -1;\r\n newValue = newValue.replace(BACKSLASH_REGEX, escapedBackslash);\r\n\r\n // @todo: look into using JSON.parse(...) to get the escaping characters\r\n const escapingCharacterSequence: string = escapedBackslash.slice(escapedBackslash.length / 2);\r\n\r\n // Ensure the the quotemark, apostrophe, tab, and newline characters are properly escaped\r\n ESCAPE_REGEX.lastIndex = -1;\r\n newValue = newValue.replace(\r\n ESCAPE_REGEX,\r\n (match) => `${escapingCharacterSequence}${ESCAPE_MAP.get(match)}`\r\n );\r\n\r\n result.replace(element.start, element.end - 1, newValue);\r\n break;\r\n }\r\n\r\n case 'dynamic': {\r\n const newValue: string = element.valueFn(locale);\r\n result.replace(element.start, element.end - 1, newValue);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return {\r\n issues,\r\n result\r\n };\r\n}\r\n\r\nfunction _reconstructNonLocalized(\r\n result: sources.ReplaceSource,\r\n reconstructionSeries: IReconstructionElement[],\r\n noStringsLocaleName: string\r\n): INonLocalizedReconstructionResult {\r\n const issues: string[] = [];\r\n\r\n for (const element of reconstructionSeries) {\r\n switch (element.kind) {\r\n case 'localized': {\r\n issues.push(\r\n `The string \"${element.data.stringName}\" in \"${element.data.locFilePath}\" appeared in an asset ` +\r\n 'that is not expected to contain localized resources.'\r\n );\r\n\r\n const newValue: string = '-- NOT EXPECTED TO BE LOCALIZED --';\r\n result.replace(element.start, element.end - 1, newValue);\r\n break;\r\n }\r\n\r\n case 'dynamic': {\r\n const newValue: string = element.valueFn(noStringsLocaleName);\r\n result.replace(element.start, element.end - 1, newValue);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return {\r\n issues,\r\n result\r\n };\r\n}\r\n\r\nfunction _rawLocaleToken(locale: string): string {\r\n return locale;\r\n}\r\n\r\nfunction _jsonLocaleToken(locale: string): string {\r\n return JSON.stringify(locale);\r\n}\r\n\r\nfunction _parseStringToReconstructionSequence(plugin: LocalizationPlugin, source: string): IParseResult {\r\n const issues: string[] = [];\r\n const reconstructionSeries: IReconstructionElement[] = [];\r\n\r\n let regexResult: RegExpExecArray | null;\r\n PLACEHOLDER_REGEX.lastIndex = -1;\r\n while ((regexResult = PLACEHOLDER_REGEX.exec(source))) {\r\n const [placeholder, escapedBackslash, elementLabel, placeholderSerialNumber] = regexResult;\r\n const start: number = regexResult.index;\r\n const end: number = start + placeholder.length;\r\n\r\n let localizedReconstructionElement: IReconstructionElement;\r\n switch (elementLabel) {\r\n case Constants.STRING_PLACEHOLDER_LABEL: {\r\n const stringData: IStringPlaceholder | undefined =\r\n plugin.getDataForSerialNumber(placeholderSerialNumber);\r\n if (!stringData) {\r\n issues.push(`Missing placeholder ${placeholder}`);\r\n continue;\r\n } else {\r\n const localizedElement: ILocalizedReconstructionElement = {\r\n kind: 'localized',\r\n start,\r\n end,\r\n escapedBackslash,\r\n data: stringData\r\n };\r\n localizedReconstructionElement = localizedElement;\r\n }\r\n break;\r\n }\r\n\r\n case Constants.LOCALE_NAME_PLACEHOLDER_LABEL: {\r\n const dynamicElement: IDynamicReconstructionElement = {\r\n kind: 'dynamic',\r\n start,\r\n end,\r\n escapedBackslash,\r\n valueFn: _rawLocaleToken\r\n };\r\n localizedReconstructionElement = dynamicElement;\r\n break;\r\n }\r\n\r\n case Constants.JSONP_PLACEHOLDER_LABEL: {\r\n const dynamicElement: IDynamicReconstructionElement = {\r\n kind: 'dynamic',\r\n start,\r\n end,\r\n escapedBackslash,\r\n valueFn: _jsonLocaleToken\r\n };\r\n localizedReconstructionElement = dynamicElement;\r\n break;\r\n }\r\n\r\n default: {\r\n throw new Error(`Unexpected label ${elementLabel}`);\r\n }\r\n }\r\n\r\n reconstructionSeries.push(localizedReconstructionElement);\r\n }\r\n\r\n return {\r\n issues,\r\n reconstructionSeries\r\n };\r\n}\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LocalizationPlugin.js","sourceRoot":"","sources":["../src/LocalizationPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAe7B,8EAA6G;AAE7G,iEAAmD;AASnD,2DAA+D;AAC/D,qDAAmF;AA4BnF,MAAM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AAQ,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBAC/C,IAAI,GAAG,EAAE;oBACP,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;iBACpB;qBAAM,IAAI,CAAC,IAAI,EAAE;oBAChB,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,cAAc,aAAa,EAAE,CAAC,CAAC,CAAC;iBACzD;gBACD,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,gBAAgB,GAAsB,IAAA,qCAAY,EAAC;YACvD,QAAQ,EAAE,aAAa;YACvB,OAAO;SACR,CAAC,CAAC;QAEH,OAAO,gCAAgC,CAAC,gBAAgB,CAAC,CAAC;KAC3D;SAAM;QACL,OAAO,aAAa,YAAY,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KAC9F;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'path';\n\nimport type {\n Asset,\n Chunk,\n ChunkGraph,\n Compilation,\n Compiler,\n LoaderContext,\n Module,\n runtime,\n WebpackError,\n WebpackPluginInstance\n} from 'webpack';\n\nimport { getPseudolocalizer, type ILocalizationFile, parseResJson } from '@rushstack/localization-utilities';\n\nimport * as Constants from './utilities/Constants';\nimport type {\n ILocalizationPluginOptions,\n ILocalizationStats,\n ILocaleFileData,\n ILocaleFileObject,\n IResolvedMissingTranslations\n} from './interfaces';\nimport type { IAssetPathOptions } from './webpackInterfaces';\nimport { markEntity, getMark } from './utilities/EntityMarker';\nimport { processLocalizedAsset, processNonLocalizedAsset } from './AssetProcessor';\n\n/**\n * @public\n */\nexport interface IStringPlaceholder {\n /**\n * The literal string that will be injected for later replacement.\n */\n value: string;\n /**\n * The identifier for this particular placeholder, for lookup.\n */\n suffix: string;\n /**\n * The values of this string in each output locale.\n */\n valuesByLocale: Map<string, string>;\n /**\n * The key used to identify the source file containing the string.\n */\n locFilePath: string;\n /**\n * The identifier of the string within its original source file.\n */\n stringName: string;\n}\n\nconst PLUGIN_NAME: 'localization' = 'localization';\n\nconst pluginForCompiler: WeakMap<Compiler, LocalizationPlugin> = new WeakMap();\n\n/**\n * Gets the instance of the LocalizationPlugin bound to the specified webpack compiler.\n * Used by loaders.\n */\nexport function getPluginInstance(compiler: Compiler | undefined): LocalizationPlugin {\n const instance: LocalizationPlugin | undefined = compiler && pluginForCompiler.get(compiler);\n if (!instance) {\n throw new Error(`Could not find a LocalizationPlugin instance for the current webpack compiler!`);\n }\n return instance;\n}\n\n/**\n * This plugin facilitates localization in webpack.\n *\n * @public\n */\nexport class LocalizationPlugin implements WebpackPluginInstance {\n public readonly stringKeys: Map<string, IStringPlaceholder> = new Map();\n\n private readonly _options: ILocalizationPluginOptions;\n private readonly _resolvedTranslatedStringsFromOptions: Map<\n string,\n Map<string, ILocaleFileObject | string | ReadonlyMap<string, string>>\n > = new Map();\n private _stringPlaceholderCounter: number = 0;\n private readonly _stringPlaceholderMap: Map<string, IStringPlaceholder> = new Map();\n private _passthroughLocaleName!: string;\n private _defaultLocale!: string;\n private _noStringsLocaleName!: string;\n private _fillMissingTranslationStrings!: boolean;\n private readonly _pseudolocalizers: Map<string, (str: string) => string> = new Map();\n\n /**\n * The outermost map's keys are the locale names.\n * The middle map's keys are the resolved, file names.\n * The innermost map's keys are the string identifiers and its values are the string values.\n */\n private _resolvedLocalizedStrings: Map<string, Map<string, Map<string, string>>> = new Map();\n\n public constructor(options: ILocalizationPluginOptions) {\n this._options = options;\n }\n\n /**\n * Apply this plugin to the specified webpack compiler.\n */\n public apply(compiler: Compiler): void {\n pluginForCompiler.set(compiler, this);\n\n // https://github.com/webpack/webpack-dev-server/pull/1929/files#diff-15fb51940da53816af13330d8ce69b4eR66\n const isWebpackDevServer: boolean = process.env.WEBPACK_DEV_SERVER === 'true';\n\n const { errors, warnings } = this._initializeAndValidateOptions(compiler, isWebpackDevServer);\n\n if (errors.length > 0 || warnings.length > 0) {\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation: Compilation) => {\n compilation.errors.push(...errors);\n compilation.warnings.push(...warnings);\n });\n\n if (errors.length > 0) {\n // If there are any errors, just pass through the resources in source and don't do any\n // additional configuration\n return;\n }\n }\n\n const {\n WebpackError,\n runtime: { GetChunkFilenameRuntimeModule }\n } = compiler.webpack;\n\n // Side-channel for async chunk URL generator chunk, since the actual chunk is completely inaccessible\n // from the assetPath hook below when invoked to build the async URL generator\n let chunkWithAsyncURLGenerator: Chunk | undefined;\n\n const originalGenerate: typeof GetChunkFilenameRuntimeModule.prototype.generate =\n GetChunkFilenameRuntimeModule.prototype.generate;\n GetChunkFilenameRuntimeModule.prototype.generate = function (\n this: runtime.GetChunkFilenameRuntimeModule\n ) {\n // `originalGenerate` will invoke `getAssetPath` to produce the async URL generator\n // Need to know the identity of the containing chunk to correctly produce the asset path expression\n chunkWithAsyncURLGenerator = this.chunk;\n const result: string = originalGenerate.call(this);\n // Unset after the call finishes because we are no longer generating async URL generators\n chunkWithAsyncURLGenerator = undefined;\n return result;\n };\n\n const asyncGeneratorTest: RegExp = /^\\\" \\+/;\n\n const { runtimeLocaleExpression } = this._options;\n\n compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation: Compilation) => {\n compilation.hooks.assetPath.tap(\n PLUGIN_NAME,\n (assetPath: string, options: IAssetPathOptions): string => {\n const { chunkGraph } = compilation;\n\n if (\n options.contentHashType === 'javascript' &&\n assetPath.match(Constants.LOCALE_FILENAME_TOKEN_REGEX)\n ) {\n // Does this look like an async chunk URL generator?\n if (typeof options.chunk?.id === 'string' && options.chunk.id.match(asyncGeneratorTest)) {\n const chunkIdsWithStrings: Set<number | string> = new Set<number | string>();\n const chunkIdsWithoutStrings: Set<number | string> = new Set<number | string>();\n\n if (!chunkWithAsyncURLGenerator) {\n compilation.errors.push(\n new WebpackError(`No active chunk while constructing async chunk URL generator!`)\n );\n return assetPath;\n }\n\n const asyncChunks: Set<Chunk> = chunkWithAsyncURLGenerator!.getAllAsyncChunks();\n for (const asyncChunk of asyncChunks) {\n const chunkId: number | string | null = asyncChunk.id;\n\n if (chunkId === null || chunkId === undefined) {\n throw new Error(`Chunk \"${asyncChunk.name}\"'s ID is null or undefined.`);\n }\n\n if (_chunkHasLocalizedModules(chunkGraph, asyncChunk, runtimeLocaleExpression)) {\n chunkIdsWithStrings.add(chunkId);\n } else {\n chunkIdsWithoutStrings.add(chunkId);\n }\n }\n\n return assetPath.replace(Constants.LOCALE_FILENAME_TOKEN_REGEX, () => {\n // Use a replacer function so that we don't need to escape anything in the return value\n\n // If the runtime chunk is itself localized, forcibly match the locale of the runtime chunk\n // Otherwise prefer the runtime expression if specified\n const localeExpression: string =\n (!_chunkHasLocalizedModules(\n chunkGraph,\n chunkWithAsyncURLGenerator!,\n runtimeLocaleExpression\n ) &&\n runtimeLocaleExpression) ||\n Constants.JSONP_PLACEHOLDER;\n\n if (chunkIdsWithStrings.size === 0) {\n return this._noStringsLocaleName;\n } else if (chunkIdsWithoutStrings.size === 0) {\n return `\" + ${localeExpression} + \"`;\n } else {\n // Generate an object that is used to select between <locale> and <nostrings locale> for each chunk ID\n // Method: pick the smaller set of (localized, non-localized) and map that to 1 (a truthy value)\n // All other IDs map to `undefined` (a falsy value), so we then use the ternary operator to select\n // the appropriate token\n //\n // This can be improved in the future. We can maybe sort the chunks such that the chunks below a certain ID\n // number are localized and the those above are not.\n const chunkMapping: { [chunkId: string]: 1 } = {};\n // Use the map with the fewest values to shorten the expression\n const isLocalizedSmaller: boolean = chunkIdsWithStrings.size <= chunkIdsWithoutStrings.size;\n // These are the ids for which the expression should evaluate to a truthy value\n const smallerSet: Set<number | string> = isLocalizedSmaller\n ? chunkIdsWithStrings\n : chunkIdsWithoutStrings;\n for (const id of smallerSet) {\n chunkMapping[id] = 1;\n }\n\n const noLocaleExpression: string = JSON.stringify(this._noStringsLocaleName);\n\n return `\" + (${JSON.stringify(chunkMapping)}[chunkId]?${\n isLocalizedSmaller ? localeExpression : noLocaleExpression\n }:${isLocalizedSmaller ? noLocaleExpression : localeExpression}) + \"`;\n }\n });\n } else {\n let locale: string | undefined = options.locale;\n if (!locale) {\n const isLocalized: boolean = _chunkHasLocalizedModules(\n chunkGraph,\n options.chunk as Chunk,\n runtimeLocaleExpression\n );\n // Ensure that the initial name maps to a file that should exist in the final output\n locale = isLocalized ? this._defaultLocale : this._noStringsLocaleName;\n }\n return assetPath.replace(Constants.LOCALE_FILENAME_TOKEN_REGEX, locale);\n }\n } else {\n return assetPath;\n }\n }\n );\n\n const { outputOptions } = compilation;\n\n // For compatibility with minifiers, need to generate the additional assets after the optimize process runs\n compilation.hooks.processAssets.tapPromise(\n {\n name: PLUGIN_NAME,\n // Generating derived assets, but explicitly want to create them *after* asset optimization\n stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE - 1\n },\n async (): Promise<void> => {\n const locales: Set<string> = new Set(this._resolvedLocalizedStrings.keys());\n\n const { chunkGraph, chunks } = compilation;\n\n const filesByChunkName: Map<string, Record<string, string>> = new Map();\n const localizedEntryPointNames: string[] = [];\n const localizedChunkNames: string[] = [];\n\n const { localizationStats: statsOptions } = this._options;\n\n for (const chunk of chunks) {\n const isLocalized: boolean = _chunkHasLocalizedModules(\n chunkGraph,\n chunk,\n runtimeLocaleExpression\n );\n\n const template: Parameters<typeof Compilation.prototype.getAssetPath>[0] =\n chunk.filenameTemplate ||\n (chunk.hasRuntime() ? outputOptions.filename : outputOptions.chunkFilename)!;\n\n const defaultAssetName: string = compilation.getPath(template, {\n chunk,\n contentHashType: 'javascript'\n // Without locale this should return the name of the default asset\n });\n\n const asset: Asset | undefined = compilation.getAsset(defaultAssetName);\n if (!asset) {\n compilation.errors.push(new WebpackError(`Missing expected chunk asset ${defaultAssetName}`));\n continue;\n }\n\n if (isLocalized) {\n const localizedAssets: Record<string, string> = processLocalizedAsset({\n // Global values\n plugin: this,\n compilation,\n locales,\n defaultLocale: this._defaultLocale,\n fillMissingTranslationStrings: this._fillMissingTranslationStrings,\n // Chunk-specific values\n chunk,\n asset,\n filenameTemplate: template\n });\n\n if (statsOptions) {\n if (chunk.name) {\n filesByChunkName.set(chunk.name, localizedAssets);\n (chunk.hasRuntime() ? localizedEntryPointNames : localizedChunkNames).push(chunk.name);\n }\n }\n } else {\n processNonLocalizedAsset({\n // Global values\n plugin: this,\n compilation,\n noStringsLocaleName: this._noStringsLocaleName,\n // Chunk-specific values\n chunk,\n asset,\n fileName: defaultAssetName\n });\n }\n }\n\n // Since the stats generation doesn't depend on content, do it immediately\n if (statsOptions) {\n const localizationStats: ILocalizationStats = {\n entrypoints: {},\n namedChunkGroups: {}\n };\n\n // Sort in lexicographic order to ensure stable output\n localizedChunkNames.sort();\n for (const chunkName of localizedChunkNames) {\n localizationStats.namedChunkGroups[chunkName] = {\n localizedAssets: filesByChunkName.get(chunkName)!\n };\n }\n\n // Sort in lexicographic order to ensure stable output\n localizedEntryPointNames.sort();\n for (const chunkName of localizedEntryPointNames) {\n localizationStats.entrypoints[chunkName] = {\n localizedAssets: filesByChunkName.get(chunkName)!\n };\n }\n\n const { dropPath, callback } = statsOptions;\n\n if (dropPath) {\n compilation.emitAsset(\n dropPath,\n new compiler.webpack.sources.RawSource(JSON.stringify(localizationStats))\n );\n }\n\n if (callback) {\n try {\n callback(localizationStats);\n } catch (e) {\n /* swallow errors from the callback */\n }\n }\n }\n }\n );\n });\n }\n\n /**\n * @public\n *\n * @returns An object mapping the string keys to placeholders\n */\n public async addDefaultLocFileAsync(\n context: LoaderContext<{}>,\n localizedFileKey: string,\n localizedResourceData: ILocalizationFile\n ): Promise<Record<string, string>> {\n const locFileData: ReadonlyMap<string, string> = convertLocalizationFileToLocData(localizedResourceData);\n const resultObject: Record<string, string> = this._addLocFileAndGetPlaceholders(\n this._defaultLocale,\n localizedFileKey,\n locFileData\n );\n\n const missingLocales: string[] = [];\n for (const [translatedLocaleName, translatedStrings] of this._resolvedTranslatedStringsFromOptions) {\n const translatedLocFileFromOptions: ILocaleFileData | undefined =\n translatedStrings.get(localizedFileKey);\n\n if (!translatedLocFileFromOptions) {\n missingLocales.push(translatedLocaleName);\n } else {\n const translatedLocFileData: ReadonlyMap<string, string> = await normalizeLocalizedData(\n context,\n translatedLocFileFromOptions\n );\n this._addTranslations(translatedLocaleName, localizedFileKey, translatedLocFileData);\n }\n }\n\n const { resolveMissingTranslatedStrings } = this._options.localizedData;\n\n if (missingLocales.length > 0 && resolveMissingTranslatedStrings) {\n let resolvedTranslatedData: IResolvedMissingTranslations | undefined = undefined;\n try {\n resolvedTranslatedData = await resolveMissingTranslatedStrings(\n missingLocales,\n localizedFileKey,\n context\n );\n } catch (e) {\n context.emitError(e);\n }\n\n if (resolvedTranslatedData) {\n const iterable: Iterable<[string, ILocaleFileData]> =\n resolvedTranslatedData instanceof Map\n ? resolvedTranslatedData.entries()\n : Object.entries(resolvedTranslatedData);\n for (const [resolvedLocaleName, resolvedLocaleData] of iterable) {\n if (resolvedLocaleData) {\n const translatedLocFileData: ReadonlyMap<string, string> = await normalizeLocalizedData(\n context,\n resolvedLocaleData\n );\n this._addTranslations(resolvedLocaleName, localizedFileKey, translatedLocFileData);\n }\n }\n }\n }\n\n for (const [pseudolocaleName, pseudolocalizer] of this._pseudolocalizers) {\n const pseudolocFileData: Map<string, string> = new Map();\n\n for (const [stringName, stringValue] of locFileData) {\n pseudolocFileData.set(stringName, pseudolocalizer(stringValue));\n }\n\n this._addTranslations(pseudolocaleName, localizedFileKey, pseudolocFileData);\n }\n\n markEntity(context._module!, true);\n\n return resultObject;\n }\n\n /**\n * @public\n */\n public getPlaceholder(localizedFileKey: string, stringName: string): IStringPlaceholder | undefined {\n const stringKey: string = `${localizedFileKey}?${stringName}`;\n return this.stringKeys.get(stringKey);\n }\n\n /**\n * @internal\n */\n public getDataForSerialNumber(serialNumber: string): IStringPlaceholder | undefined {\n return this._stringPlaceholderMap.get(serialNumber);\n }\n\n private _addLocFileAndGetPlaceholders(\n localeName: string,\n localizedFileKey: string,\n localizedFileData: ReadonlyMap<string, string>\n ): Record<string, string> {\n const filesMap: Map<string, ReadonlyMap<string, string>> = this._resolvedLocalizedStrings.get(\n localeName\n )!;\n\n filesMap.set(localizedFileKey, localizedFileData);\n\n const resultObject: Record<string, string> = {};\n for (const [stringName, stringValue] of localizedFileData) {\n const stringKey: string = `${localizedFileKey}?${stringName}`;\n let placeholder: IStringPlaceholder | undefined = this.stringKeys.get(stringKey);\n if (!placeholder) {\n // TODO: This may need to be a deterministic identifier to support watch / incremental compilation\n const suffix: string = `${this._stringPlaceholderCounter++}`;\n\n const values: Map<string, string> = new Map();\n values.set(this._passthroughLocaleName, stringName);\n\n placeholder = {\n value: `${Constants.STRING_PLACEHOLDER_PREFIX}_\\\\_${Constants.STRING_PLACEHOLDER_LABEL}_${suffix}`,\n suffix,\n valuesByLocale: values,\n locFilePath: localizedFileKey,\n stringName\n };\n\n this.stringKeys.set(stringKey, placeholder);\n this._stringPlaceholderMap.set(suffix, placeholder);\n }\n\n resultObject[stringName] = placeholder.value;\n\n placeholder.valuesByLocale.set(localeName, stringValue);\n }\n\n return resultObject;\n }\n\n private _addTranslations(\n localeName: string,\n localizedFileKey: string,\n localizedFileData: ReadonlyMap<string, string>\n ): void {\n for (const [stringName, stringValue] of localizedFileData) {\n const stringKey: string = `${localizedFileKey}?${stringName}`;\n const placeholder: IStringPlaceholder | undefined = this.stringKeys.get(stringKey);\n if (placeholder) {\n placeholder.valuesByLocale.set(localeName, stringValue);\n }\n }\n }\n\n private _initializeAndValidateOptions(\n compiler: Compiler,\n isWebpackDevServer: boolean\n ): { errors: WebpackError[]; warnings: WebpackError[] } {\n const errors: WebpackError[] = [];\n const warnings: WebpackError[] = [];\n\n const { WebpackError } = compiler.webpack;\n const { options: configuration } = compiler;\n\n const LOCALE_NAME_REGEX: RegExp = /[a-z-]/i;\n function ensureValidLocaleName(localeName: string): boolean {\n if (!localeName.match(LOCALE_NAME_REGEX)) {\n errors.push(\n new WebpackError(\n `Invalid locale name: ${localeName}. Locale names may only contain letters and hyphens.`\n )\n );\n return false;\n } else {\n return true;\n }\n }\n\n // START configuration\n if (\n !configuration.output ||\n !configuration.output.filename ||\n typeof configuration.output.filename !== 'string' ||\n configuration.output.filename.indexOf(Constants.LOCALE_FILENAME_TOKEN) === -1\n ) {\n errors.push(\n new WebpackError(\n 'The configuration.output.filename property must be provided, must be a string, and must include ' +\n `the ${Constants.LOCALE_FILENAME_TOKEN} placeholder`\n )\n );\n }\n // END configuration\n\n // START misc options\n // START options.localizedData\n const { localizedData } = this._options;\n if (localizedData) {\n // START options.localizedData.passthroughLocale\n const { passthroughLocale } = localizedData;\n if (passthroughLocale) {\n const { usePassthroughLocale, passthroughLocaleName = 'passthrough' } = passthroughLocale;\n if (usePassthroughLocale) {\n this._passthroughLocaleName = passthroughLocaleName;\n this._resolvedLocalizedStrings.set(passthroughLocaleName, new Map());\n }\n }\n // END options.localizedData.passthroughLocale\n\n // START options.localizedData.translatedStrings\n const resolveRelativeToContext: (relative: string) => string = (\n configuration.context?.startsWith('/') ? path.posix.resolve : path.resolve\n ).bind(0, configuration.context!);\n const { translatedStrings } = localizedData;\n this._resolvedTranslatedStringsFromOptions.clear();\n if (translatedStrings) {\n for (const [localeName, locale] of Object.entries(translatedStrings)) {\n if (this._resolvedLocalizedStrings.has(localeName)) {\n errors.push(\n new WebpackError(\n `The locale \"${localeName}\" appears multiple times. ` +\n 'There may be multiple instances with different casing.'\n )\n );\n return { errors, warnings };\n }\n\n if (!ensureValidLocaleName(localeName)) {\n return { errors, warnings };\n }\n\n this._resolvedLocalizedStrings.set(localeName, new Map());\n const resolvedFromOptionsForLocale: Map<string, ILocaleFileData> = new Map();\n this._resolvedTranslatedStringsFromOptions.set(localeName, resolvedFromOptionsForLocale);\n\n for (const [locFilePath, locFileDataFromOptions] of Object.entries(locale)) {\n const normalizedLocFilePath: string = resolveRelativeToContext(locFilePath);\n\n if (resolvedFromOptionsForLocale.has(normalizedLocFilePath)) {\n errors.push(\n new WebpackError(\n `The localization file path \"${locFilePath}\" appears multiple times in locale ${localeName}. ` +\n 'There may be multiple instances with different casing.'\n )\n );\n return { errors, warnings };\n }\n\n const normalizedLocFileDataFromOptions: ILocaleFileData =\n typeof locFileDataFromOptions === 'string'\n ? resolveRelativeToContext(locFileDataFromOptions)\n : locFileDataFromOptions;\n\n resolvedFromOptionsForLocale.set(normalizedLocFilePath, normalizedLocFileDataFromOptions);\n }\n }\n }\n // END options.localizedData.translatedStrings\n\n // START options.localizedData.defaultLocale\n const { defaultLocale } = localizedData;\n if (defaultLocale) {\n const { localeName, fillMissingTranslationStrings } = defaultLocale;\n if (localeName) {\n if (this._resolvedLocalizedStrings.has(localeName)) {\n errors.push(new WebpackError('The default locale is also specified in the translated strings.'));\n return { errors, warnings };\n } else if (!ensureValidLocaleName(localeName)) {\n return { errors, warnings };\n }\n\n this._resolvedLocalizedStrings.set(localeName, new Map());\n this._defaultLocale = localeName;\n this._fillMissingTranslationStrings = !!fillMissingTranslationStrings;\n } else {\n errors.push(new WebpackError('Missing default locale name'));\n return { errors, warnings };\n }\n } else {\n errors.push(new WebpackError('Missing default locale options.'));\n return { errors, warnings };\n }\n // END options.localizedData.defaultLocale\n\n // START options.localizedData.pseudoLocales\n const { pseudolocales } = localizedData;\n if (pseudolocales) {\n for (const [pseudolocaleName, pseudoLocaleOpts] of Object.entries(pseudolocales)) {\n if (this._defaultLocale === pseudolocaleName) {\n errors.push(\n new WebpackError(`A pseudolocale (${pseudolocaleName}) name is also the default locale name.`)\n );\n return { errors, warnings };\n }\n\n if (this._resolvedLocalizedStrings.has(pseudolocaleName)) {\n errors.push(\n new WebpackError(\n `A pseudolocale (${pseudolocaleName}) name is also specified in the translated strings.`\n )\n );\n return { errors, warnings };\n }\n\n this._pseudolocalizers.set(pseudolocaleName, getPseudolocalizer(pseudoLocaleOpts));\n this._resolvedLocalizedStrings.set(pseudolocaleName, new Map<string, Map<string, string>>());\n }\n }\n // END options.localizedData.pseudoLocales\n } else if (!isWebpackDevServer) {\n throw new Error('Localized data must be provided unless webpack dev server is running.');\n }\n // END options.localizedData\n\n // START options.noStringsLocaleName\n const { noStringsLocaleName } = this._options;\n if (\n noStringsLocaleName === undefined ||\n noStringsLocaleName === null ||\n !ensureValidLocaleName(noStringsLocaleName)\n ) {\n this._noStringsLocaleName = 'none';\n } else {\n this._noStringsLocaleName = noStringsLocaleName;\n }\n // END options.noStringsLocaleName\n\n return { errors, warnings };\n }\n}\n\nfunction _chunkHasLocalizedModules(\n chunkGraph: ChunkGraph,\n chunk: Chunk,\n runtimeLocaleExpression: string | undefined\n): boolean {\n let chunkHasAnyLocModules: boolean | undefined = getMark(chunk);\n if (chunkHasAnyLocModules === undefined) {\n chunkHasAnyLocModules = false;\n const candidateModules: Iterable<Module> | undefined = chunkGraph.getChunkModulesIterableBySourceType(\n chunk,\n 'javascript'\n );\n if (candidateModules) {\n outer: for (const module of candidateModules) {\n const moduleMark: boolean | undefined = getMark(module);\n if (moduleMark) {\n chunkHasAnyLocModules = true;\n break;\n } else if (moduleMark === false) {\n continue;\n }\n\n // Is this a concatenated module?\n const { _modules: modules } = module as { _modules?: Iterable<Module> };\n if (modules) {\n for (const nestedModule of modules) {\n if (getMark(nestedModule)) {\n markEntity(module, true);\n chunkHasAnyLocModules = true;\n break outer;\n }\n }\n markEntity(module, false);\n }\n }\n }\n\n // If this chunk doesn't directly contain any localized resources, it still\n // needs to be localized if it's an entrypoint chunk (i.e. - it has a runtime)\n // and it loads localized async chunks.\n // In that case, the generated chunk URL generation code needs to contain\n // the locale name.\n if (!chunkHasAnyLocModules && !runtimeLocaleExpression && chunk.hasRuntime()) {\n for (const asyncChunk of chunk.getAllAsyncChunks()) {\n if (_chunkHasLocalizedModules(chunkGraph, asyncChunk, runtimeLocaleExpression)) {\n chunkHasAnyLocModules = true;\n break;\n }\n }\n }\n\n markEntity(chunk, chunkHasAnyLocModules);\n }\n\n return chunkHasAnyLocModules;\n}\n\nfunction convertLocalizationFileToLocData(locFile: ILocalizationFile): ReadonlyMap<string, string> {\n const locFileData: Map<string, string> = new Map();\n for (const [stringName, locFileEntry] of Object.entries(locFile)) {\n locFileData.set(stringName, locFileEntry.value);\n }\n\n return locFileData;\n}\n\nasync function normalizeLocalizedData(\n context: LoaderContext<{}>,\n localizedData: ILocaleFileData\n): Promise<ReadonlyMap<string, string>> {\n if (typeof localizedData === 'string') {\n // The value is the path to a file. Add it as a file dependency\n context.addDependency(localizedData);\n const content: string = await new Promise((resolve, reject) => {\n // Use context.fs so that the plugin is compatible with overriding compiler.inputFileSystem\n context.fs.readFile(localizedData, (err, data) => {\n if (err) {\n return reject(err);\n } else if (!data) {\n return reject(new Error(`No data in ${localizedData}`));\n }\n resolve(data.toString());\n });\n });\n\n const localizationFile: ILocalizationFile = parseResJson({\n filePath: localizedData,\n content\n });\n\n return convertLocalizationFileToLocData(localizationFile);\n } else {\n return localizedData instanceof Map ? localizedData : new Map(Object.entries(localizedData));\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"LocalizationPlugin.js","sourceRoot":"","sources":["../src/LocalizationPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAe7B,8EAA6G;AAE7G,iEAAmD;AASnD,2DAA+D;AAC/D,qDAAmF;AA4BnF,MAAM,WAAW,GAAmB,cAAc,CAAC;AAEnD,MAAM,iBAAiB,GAA0C,IAAI,OAAO,EAAE,CAAC;AAE/E;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,QAA8B;IAC9D,MAAM,QAAQ,GAAmC,QAAQ,IAAI,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7F,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,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,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,gBAAgB,GAAsB,IAAA,qCAAY,EAAC;YACvD,QAAQ,EAAE,aAAa;YACvB,OAAO;SACR,CAAC,CAAC;QAEH,OAAO,gCAAgC,CAAC,gBAAgB,CAAC,CAAC;KAC3D;SAAM;QACL,OAAO,aAAa,YAAY,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KAC9F;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport * as path from 'path';\r\n\r\nimport type {\r\n Asset,\r\n Chunk,\r\n ChunkGraph,\r\n Compilation,\r\n Compiler,\r\n LoaderContext,\r\n Module,\r\n runtime,\r\n WebpackError,\r\n WebpackPluginInstance\r\n} from 'webpack';\r\n\r\nimport { getPseudolocalizer, type ILocalizationFile, parseResJson } from '@rushstack/localization-utilities';\r\n\r\nimport * as Constants from './utilities/Constants';\r\nimport type {\r\n ILocalizationPluginOptions,\r\n ILocalizationStats,\r\n ILocaleFileData,\r\n ILocaleFileObject,\r\n IResolvedMissingTranslations\r\n} from './interfaces';\r\nimport type { IAssetPathOptions } from './webpackInterfaces';\r\nimport { markEntity, getMark } from './utilities/EntityMarker';\r\nimport { processLocalizedAsset, processNonLocalizedAsset } from './AssetProcessor';\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface IStringPlaceholder {\r\n /**\r\n * The literal string that will be injected for later replacement.\r\n */\r\n value: string;\r\n /**\r\n * The identifier for this particular placeholder, for lookup.\r\n */\r\n suffix: string;\r\n /**\r\n * The values of this string in each output locale.\r\n */\r\n valuesByLocale: Map<string, string>;\r\n /**\r\n * The key used to identify the source file containing the string.\r\n */\r\n locFilePath: string;\r\n /**\r\n * The identifier of the string within its original source file.\r\n */\r\n stringName: string;\r\n}\r\n\r\nconst PLUGIN_NAME: 'localization' = 'localization';\r\n\r\nconst pluginForCompiler: WeakMap<Compiler, LocalizationPlugin> = new WeakMap();\r\n\r\n/**\r\n * Gets the instance of the LocalizationPlugin bound to the specified webpack compiler.\r\n * Used by loaders.\r\n */\r\nexport function getPluginInstance(compiler: Compiler | undefined): LocalizationPlugin {\r\n const instance: LocalizationPlugin | undefined = compiler && pluginForCompiler.get(compiler);\r\n if (!instance) {\r\n throw new Error(`Could not find a LocalizationPlugin instance for the current webpack compiler!`);\r\n }\r\n return instance;\r\n}\r\n\r\n/**\r\n * This plugin facilitates localization in webpack.\r\n *\r\n * @public\r\n */\r\nexport class LocalizationPlugin implements WebpackPluginInstance {\r\n public readonly stringKeys: Map<string, IStringPlaceholder> = new Map();\r\n\r\n private readonly _options: ILocalizationPluginOptions;\r\n private readonly _resolvedTranslatedStringsFromOptions: Map<\r\n string,\r\n Map<string, ILocaleFileObject | string | ReadonlyMap<string, string>>\r\n > = new Map();\r\n private _stringPlaceholderCounter: number = 0;\r\n private readonly _stringPlaceholderMap: Map<string, IStringPlaceholder> = new Map();\r\n private _passthroughLocaleName!: string;\r\n private _defaultLocale!: string;\r\n private _noStringsLocaleName!: string;\r\n private _fillMissingTranslationStrings!: boolean;\r\n private readonly _pseudolocalizers: Map<string, (str: string) => string> = new Map();\r\n\r\n /**\r\n * The outermost map's keys are the locale names.\r\n * The middle map's keys are the resolved, file names.\r\n * The innermost map's keys are the string identifiers and its values are the string values.\r\n */\r\n private _resolvedLocalizedStrings: Map<string, Map<string, Map<string, string>>> = new Map();\r\n\r\n public constructor(options: ILocalizationPluginOptions) {\r\n this._options = options;\r\n }\r\n\r\n /**\r\n * Apply this plugin to the specified webpack compiler.\r\n */\r\n public apply(compiler: Compiler): void {\r\n pluginForCompiler.set(compiler, this);\r\n\r\n // https://github.com/webpack/webpack-dev-server/pull/1929/files#diff-15fb51940da53816af13330d8ce69b4eR66\r\n const isWebpackDevServer: boolean = process.env.WEBPACK_DEV_SERVER === 'true';\r\n\r\n const { errors, warnings } = this._initializeAndValidateOptions(compiler, isWebpackDevServer);\r\n\r\n if (errors.length > 0 || warnings.length > 0) {\r\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation: Compilation) => {\r\n compilation.errors.push(...errors);\r\n compilation.warnings.push(...warnings);\r\n });\r\n\r\n if (errors.length > 0) {\r\n // If there are any errors, just pass through the resources in source and don't do any\r\n // additional configuration\r\n return;\r\n }\r\n }\r\n\r\n const {\r\n WebpackError,\r\n runtime: { GetChunkFilenameRuntimeModule }\r\n } = compiler.webpack;\r\n\r\n // Side-channel for async chunk URL generator chunk, since the actual chunk is completely inaccessible\r\n // from the assetPath hook below when invoked to build the async URL generator\r\n let chunkWithAsyncURLGenerator: Chunk | undefined;\r\n\r\n const originalGenerate: typeof GetChunkFilenameRuntimeModule.prototype.generate =\r\n GetChunkFilenameRuntimeModule.prototype.generate;\r\n GetChunkFilenameRuntimeModule.prototype.generate = function (\r\n this: runtime.GetChunkFilenameRuntimeModule\r\n ) {\r\n // `originalGenerate` will invoke `getAssetPath` to produce the async URL generator\r\n // Need to know the identity of the containing chunk to correctly produce the asset path expression\r\n chunkWithAsyncURLGenerator = this.chunk;\r\n const result: string = originalGenerate.call(this);\r\n // Unset after the call finishes because we are no longer generating async URL generators\r\n chunkWithAsyncURLGenerator = undefined;\r\n return result;\r\n };\r\n\r\n const asyncGeneratorTest: RegExp = /^\\\" \\+/;\r\n\r\n const { runtimeLocaleExpression } = this._options;\r\n\r\n compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation: Compilation) => {\r\n compilation.hooks.assetPath.tap(\r\n PLUGIN_NAME,\r\n (assetPath: string, options: IAssetPathOptions): string => {\r\n const { chunkGraph } = compilation;\r\n\r\n if (\r\n options.contentHashType === 'javascript' &&\r\n assetPath.match(Constants.LOCALE_FILENAME_TOKEN_REGEX)\r\n ) {\r\n // Does this look like an async chunk URL generator?\r\n if (typeof options.chunk?.id === 'string' && options.chunk.id.match(asyncGeneratorTest)) {\r\n const chunkIdsWithStrings: Set<number | string> = new Set<number | string>();\r\n const chunkIdsWithoutStrings: Set<number | string> = new Set<number | string>();\r\n\r\n if (!chunkWithAsyncURLGenerator) {\r\n compilation.errors.push(\r\n new WebpackError(`No active chunk while constructing async chunk URL generator!`)\r\n );\r\n return assetPath;\r\n }\r\n\r\n const asyncChunks: Set<Chunk> = chunkWithAsyncURLGenerator!.getAllAsyncChunks();\r\n for (const asyncChunk of asyncChunks) {\r\n const chunkId: number | string | null = asyncChunk.id;\r\n\r\n if (chunkId === null || chunkId === undefined) {\r\n throw new Error(`Chunk \"${asyncChunk.name}\"'s ID is null or undefined.`);\r\n }\r\n\r\n if (_chunkHasLocalizedModules(chunkGraph, asyncChunk, runtimeLocaleExpression)) {\r\n chunkIdsWithStrings.add(chunkId);\r\n } else {\r\n chunkIdsWithoutStrings.add(chunkId);\r\n }\r\n }\r\n\r\n return assetPath.replace(Constants.LOCALE_FILENAME_TOKEN_REGEX, () => {\r\n // Use a replacer function so that we don't need to escape anything in the return value\r\n\r\n // If the runtime chunk is itself localized, forcibly match the locale of the runtime chunk\r\n // Otherwise prefer the runtime expression if specified\r\n const localeExpression: string =\r\n (!_chunkHasLocalizedModules(\r\n chunkGraph,\r\n chunkWithAsyncURLGenerator!,\r\n runtimeLocaleExpression\r\n ) &&\r\n runtimeLocaleExpression) ||\r\n Constants.JSONP_PLACEHOLDER;\r\n\r\n if (chunkIdsWithStrings.size === 0) {\r\n return this._noStringsLocaleName;\r\n } else if (chunkIdsWithoutStrings.size === 0) {\r\n return `\" + ${localeExpression} + \"`;\r\n } else {\r\n // Generate an object that is used to select between <locale> and <nostrings locale> for each chunk ID\r\n // Method: pick the smaller set of (localized, non-localized) and map that to 1 (a truthy value)\r\n // All other IDs map to `undefined` (a falsy value), so we then use the ternary operator to select\r\n // the appropriate token\r\n //\r\n // This can be improved in the future. We can maybe sort the chunks such that the chunks below a certain ID\r\n // number are localized and the those above are not.\r\n const chunkMapping: { [chunkId: string]: 1 } = {};\r\n // Use the map with the fewest values to shorten the expression\r\n const isLocalizedSmaller: boolean = chunkIdsWithStrings.size <= chunkIdsWithoutStrings.size;\r\n // These are the ids for which the expression should evaluate to a truthy value\r\n const smallerSet: Set<number | string> = isLocalizedSmaller\r\n ? chunkIdsWithStrings\r\n : chunkIdsWithoutStrings;\r\n for (const id of smallerSet) {\r\n chunkMapping[id] = 1;\r\n }\r\n\r\n const noLocaleExpression: string = JSON.stringify(this._noStringsLocaleName);\r\n\r\n return `\" + (${JSON.stringify(chunkMapping)}[chunkId]?${\r\n isLocalizedSmaller ? localeExpression : noLocaleExpression\r\n }:${isLocalizedSmaller ? noLocaleExpression : localeExpression}) + \"`;\r\n }\r\n });\r\n } else {\r\n let locale: string | undefined = options.locale;\r\n if (!locale) {\r\n const isLocalized: boolean = _chunkHasLocalizedModules(\r\n chunkGraph,\r\n options.chunk as Chunk,\r\n runtimeLocaleExpression\r\n );\r\n // Ensure that the initial name maps to a file that should exist in the final output\r\n locale = isLocalized ? this._defaultLocale : this._noStringsLocaleName;\r\n }\r\n return assetPath.replace(Constants.LOCALE_FILENAME_TOKEN_REGEX, locale);\r\n }\r\n } else {\r\n return assetPath;\r\n }\r\n }\r\n );\r\n\r\n const { outputOptions } = compilation;\r\n\r\n // For compatibility with minifiers, need to generate the additional assets after the optimize process runs\r\n compilation.hooks.processAssets.tapPromise(\r\n {\r\n name: PLUGIN_NAME,\r\n // Generating derived assets, but explicitly want to create them *after* asset optimization\r\n stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE - 1\r\n },\r\n async (): Promise<void> => {\r\n const locales: Set<string> = new Set(this._resolvedLocalizedStrings.keys());\r\n\r\n const { chunkGraph, chunks } = compilation;\r\n\r\n const filesByChunkName: Map<string, Record<string, string>> = new Map();\r\n const localizedEntryPointNames: string[] = [];\r\n const localizedChunkNames: string[] = [];\r\n\r\n const { localizationStats: statsOptions } = this._options;\r\n\r\n for (const chunk of chunks) {\r\n const isLocalized: boolean = _chunkHasLocalizedModules(\r\n chunkGraph,\r\n chunk,\r\n runtimeLocaleExpression\r\n );\r\n\r\n const template: Parameters<typeof Compilation.prototype.getAssetPath>[0] =\r\n chunk.filenameTemplate ||\r\n (chunk.hasRuntime() ? outputOptions.filename : outputOptions.chunkFilename)!;\r\n\r\n const defaultAssetName: string = compilation.getPath(template, {\r\n chunk,\r\n contentHashType: 'javascript'\r\n // Without locale this should return the name of the default asset\r\n });\r\n\r\n const asset: Asset | undefined = compilation.getAsset(defaultAssetName);\r\n if (!asset) {\r\n compilation.errors.push(new WebpackError(`Missing expected chunk asset ${defaultAssetName}`));\r\n continue;\r\n }\r\n\r\n if (isLocalized) {\r\n const localizedAssets: Record<string, string> = processLocalizedAsset({\r\n // Global values\r\n plugin: this,\r\n compilation,\r\n locales,\r\n defaultLocale: this._defaultLocale,\r\n fillMissingTranslationStrings: this._fillMissingTranslationStrings,\r\n // Chunk-specific values\r\n chunk,\r\n asset,\r\n filenameTemplate: template\r\n });\r\n\r\n if (statsOptions) {\r\n if (chunk.name) {\r\n filesByChunkName.set(chunk.name, localizedAssets);\r\n (chunk.hasRuntime() ? localizedEntryPointNames : localizedChunkNames).push(chunk.name);\r\n }\r\n }\r\n } else {\r\n processNonLocalizedAsset({\r\n // Global values\r\n plugin: this,\r\n compilation,\r\n noStringsLocaleName: this._noStringsLocaleName,\r\n // Chunk-specific values\r\n chunk,\r\n asset,\r\n fileName: defaultAssetName\r\n });\r\n }\r\n }\r\n\r\n // Since the stats generation doesn't depend on content, do it immediately\r\n if (statsOptions) {\r\n const localizationStats: ILocalizationStats = {\r\n entrypoints: {},\r\n namedChunkGroups: {}\r\n };\r\n\r\n // Sort in lexicographic order to ensure stable output\r\n localizedChunkNames.sort();\r\n for (const chunkName of localizedChunkNames) {\r\n localizationStats.namedChunkGroups[chunkName] = {\r\n localizedAssets: filesByChunkName.get(chunkName)!\r\n };\r\n }\r\n\r\n // Sort in lexicographic order to ensure stable output\r\n localizedEntryPointNames.sort();\r\n for (const chunkName of localizedEntryPointNames) {\r\n localizationStats.entrypoints[chunkName] = {\r\n localizedAssets: filesByChunkName.get(chunkName)!\r\n };\r\n }\r\n\r\n const { dropPath, callback } = statsOptions;\r\n\r\n if (dropPath) {\r\n compilation.emitAsset(\r\n dropPath,\r\n new compiler.webpack.sources.RawSource(JSON.stringify(localizationStats))\r\n );\r\n }\r\n\r\n if (callback) {\r\n try {\r\n callback(localizationStats);\r\n } catch (e) {\r\n /* swallow errors from the callback */\r\n }\r\n }\r\n }\r\n }\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * @public\r\n *\r\n * @returns An object mapping the string keys to placeholders\r\n */\r\n public async addDefaultLocFileAsync(\r\n context: LoaderContext<{}>,\r\n localizedFileKey: string,\r\n localizedResourceData: ILocalizationFile\r\n ): Promise<Record<string, string>> {\r\n const locFileData: ReadonlyMap<string, string> = convertLocalizationFileToLocData(localizedResourceData);\r\n const resultObject: Record<string, string> = this._addLocFileAndGetPlaceholders(\r\n this._defaultLocale,\r\n localizedFileKey,\r\n locFileData\r\n );\r\n\r\n const missingLocales: string[] = [];\r\n for (const [translatedLocaleName, translatedStrings] of this._resolvedTranslatedStringsFromOptions) {\r\n const translatedLocFileFromOptions: ILocaleFileData | undefined =\r\n translatedStrings.get(localizedFileKey);\r\n\r\n if (!translatedLocFileFromOptions) {\r\n missingLocales.push(translatedLocaleName);\r\n } else {\r\n const translatedLocFileData: ReadonlyMap<string, string> = await normalizeLocalizedData(\r\n context,\r\n translatedLocFileFromOptions\r\n );\r\n this._addTranslations(translatedLocaleName, localizedFileKey, translatedLocFileData);\r\n }\r\n }\r\n\r\n const { resolveMissingTranslatedStrings } = this._options.localizedData;\r\n\r\n if (missingLocales.length > 0 && resolveMissingTranslatedStrings) {\r\n let resolvedTranslatedData: IResolvedMissingTranslations | undefined = undefined;\r\n try {\r\n resolvedTranslatedData = await resolveMissingTranslatedStrings(\r\n missingLocales,\r\n localizedFileKey,\r\n context\r\n );\r\n } catch (e) {\r\n context.emitError(e);\r\n }\r\n\r\n if (resolvedTranslatedData) {\r\n const iterable: Iterable<[string, ILocaleFileData]> =\r\n resolvedTranslatedData instanceof Map\r\n ? resolvedTranslatedData.entries()\r\n : Object.entries(resolvedTranslatedData);\r\n for (const [resolvedLocaleName, resolvedLocaleData] of iterable) {\r\n if (resolvedLocaleData) {\r\n const translatedLocFileData: ReadonlyMap<string, string> = await normalizeLocalizedData(\r\n context,\r\n resolvedLocaleData\r\n );\r\n this._addTranslations(resolvedLocaleName, localizedFileKey, translatedLocFileData);\r\n }\r\n }\r\n }\r\n }\r\n\r\n for (const [pseudolocaleName, pseudolocalizer] of this._pseudolocalizers) {\r\n const pseudolocFileData: Map<string, string> = new Map();\r\n\r\n for (const [stringName, stringValue] of locFileData) {\r\n pseudolocFileData.set(stringName, pseudolocalizer(stringValue));\r\n }\r\n\r\n this._addTranslations(pseudolocaleName, localizedFileKey, pseudolocFileData);\r\n }\r\n\r\n markEntity(context._module!, true);\r\n\r\n return resultObject;\r\n }\r\n\r\n /**\r\n * @public\r\n */\r\n public getPlaceholder(localizedFileKey: string, stringName: string): IStringPlaceholder | undefined {\r\n const stringKey: string = `${localizedFileKey}?${stringName}`;\r\n return this.stringKeys.get(stringKey);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public getDataForSerialNumber(serialNumber: string): IStringPlaceholder | undefined {\r\n return this._stringPlaceholderMap.get(serialNumber);\r\n }\r\n\r\n private _addLocFileAndGetPlaceholders(\r\n localeName: string,\r\n localizedFileKey: string,\r\n localizedFileData: ReadonlyMap<string, string>\r\n ): Record<string, string> {\r\n const filesMap: Map<string, ReadonlyMap<string, string>> = this._resolvedLocalizedStrings.get(\r\n localeName\r\n )!;\r\n\r\n filesMap.set(localizedFileKey, localizedFileData);\r\n\r\n const resultObject: Record<string, string> = {};\r\n for (const [stringName, stringValue] of localizedFileData) {\r\n const stringKey: string = `${localizedFileKey}?${stringName}`;\r\n let placeholder: IStringPlaceholder | undefined = this.stringKeys.get(stringKey);\r\n if (!placeholder) {\r\n // TODO: This may need to be a deterministic identifier to support watch / incremental compilation\r\n const suffix: string = `${this._stringPlaceholderCounter++}`;\r\n\r\n const values: Map<string, string> = new Map();\r\n values.set(this._passthroughLocaleName, stringName);\r\n\r\n placeholder = {\r\n value: `${Constants.STRING_PLACEHOLDER_PREFIX}_\\\\_${Constants.STRING_PLACEHOLDER_LABEL}_${suffix}`,\r\n suffix,\r\n valuesByLocale: values,\r\n locFilePath: localizedFileKey,\r\n stringName\r\n };\r\n\r\n this.stringKeys.set(stringKey, placeholder);\r\n this._stringPlaceholderMap.set(suffix, placeholder);\r\n }\r\n\r\n resultObject[stringName] = placeholder.value;\r\n\r\n placeholder.valuesByLocale.set(localeName, stringValue);\r\n }\r\n\r\n return resultObject;\r\n }\r\n\r\n private _addTranslations(\r\n localeName: string,\r\n localizedFileKey: string,\r\n localizedFileData: ReadonlyMap<string, string>\r\n ): void {\r\n for (const [stringName, stringValue] of localizedFileData) {\r\n const stringKey: string = `${localizedFileKey}?${stringName}`;\r\n const placeholder: IStringPlaceholder | undefined = this.stringKeys.get(stringKey);\r\n if (placeholder) {\r\n placeholder.valuesByLocale.set(localeName, stringValue);\r\n }\r\n }\r\n }\r\n\r\n private _initializeAndValidateOptions(\r\n compiler: Compiler,\r\n isWebpackDevServer: boolean\r\n ): { errors: WebpackError[]; warnings: WebpackError[] } {\r\n const errors: WebpackError[] = [];\r\n const warnings: WebpackError[] = [];\r\n\r\n const { WebpackError } = compiler.webpack;\r\n const { options: configuration } = compiler;\r\n\r\n const LOCALE_NAME_REGEX: RegExp = /[a-z-]/i;\r\n function ensureValidLocaleName(localeName: string): boolean {\r\n if (!localeName.match(LOCALE_NAME_REGEX)) {\r\n errors.push(\r\n new WebpackError(\r\n `Invalid locale name: ${localeName}. Locale names may only contain letters and hyphens.`\r\n )\r\n );\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n }\r\n\r\n // START configuration\r\n if (\r\n !configuration.output ||\r\n !configuration.output.filename ||\r\n typeof configuration.output.filename !== 'string' ||\r\n configuration.output.filename.indexOf(Constants.LOCALE_FILENAME_TOKEN) === -1\r\n ) {\r\n errors.push(\r\n new WebpackError(\r\n 'The configuration.output.filename property must be provided, must be a string, and must include ' +\r\n `the ${Constants.LOCALE_FILENAME_TOKEN} placeholder`\r\n )\r\n );\r\n }\r\n // END configuration\r\n\r\n // START misc options\r\n // START options.localizedData\r\n const { localizedData } = this._options;\r\n if (localizedData) {\r\n // START options.localizedData.passthroughLocale\r\n const { passthroughLocale } = localizedData;\r\n if (passthroughLocale) {\r\n const { usePassthroughLocale, passthroughLocaleName = 'passthrough' } = passthroughLocale;\r\n if (usePassthroughLocale) {\r\n this._passthroughLocaleName = passthroughLocaleName;\r\n this._resolvedLocalizedStrings.set(passthroughLocaleName, new Map());\r\n }\r\n }\r\n // END options.localizedData.passthroughLocale\r\n\r\n // START options.localizedData.translatedStrings\r\n const resolveRelativeToContext: (relative: string) => string = (\r\n configuration.context?.startsWith('/') ? path.posix.resolve : path.resolve\r\n ).bind(0, configuration.context!);\r\n const { translatedStrings } = localizedData;\r\n this._resolvedTranslatedStringsFromOptions.clear();\r\n if (translatedStrings) {\r\n for (const [localeName, locale] of Object.entries(translatedStrings)) {\r\n if (this._resolvedLocalizedStrings.has(localeName)) {\r\n errors.push(\r\n new WebpackError(\r\n `The locale \"${localeName}\" appears multiple times. ` +\r\n 'There may be multiple instances with different casing.'\r\n )\r\n );\r\n return { errors, warnings };\r\n }\r\n\r\n if (!ensureValidLocaleName(localeName)) {\r\n return { errors, warnings };\r\n }\r\n\r\n this._resolvedLocalizedStrings.set(localeName, new Map());\r\n const resolvedFromOptionsForLocale: Map<string, ILocaleFileData> = new Map();\r\n this._resolvedTranslatedStringsFromOptions.set(localeName, resolvedFromOptionsForLocale);\r\n\r\n for (const [locFilePath, locFileDataFromOptions] of Object.entries(locale)) {\r\n const normalizedLocFilePath: string = resolveRelativeToContext(locFilePath);\r\n\r\n if (resolvedFromOptionsForLocale.has(normalizedLocFilePath)) {\r\n errors.push(\r\n new WebpackError(\r\n `The localization file path \"${locFilePath}\" appears multiple times in locale ${localeName}. ` +\r\n 'There may be multiple instances with different casing.'\r\n )\r\n );\r\n return { errors, warnings };\r\n }\r\n\r\n const normalizedLocFileDataFromOptions: ILocaleFileData =\r\n typeof locFileDataFromOptions === 'string'\r\n ? resolveRelativeToContext(locFileDataFromOptions)\r\n : locFileDataFromOptions;\r\n\r\n resolvedFromOptionsForLocale.set(normalizedLocFilePath, normalizedLocFileDataFromOptions);\r\n }\r\n }\r\n }\r\n // END options.localizedData.translatedStrings\r\n\r\n // START options.localizedData.defaultLocale\r\n const { defaultLocale } = localizedData;\r\n if (defaultLocale) {\r\n const { localeName, fillMissingTranslationStrings } = defaultLocale;\r\n if (localeName) {\r\n if (this._resolvedLocalizedStrings.has(localeName)) {\r\n errors.push(new WebpackError('The default locale is also specified in the translated strings.'));\r\n return { errors, warnings };\r\n } else if (!ensureValidLocaleName(localeName)) {\r\n return { errors, warnings };\r\n }\r\n\r\n this._resolvedLocalizedStrings.set(localeName, new Map());\r\n this._defaultLocale = localeName;\r\n this._fillMissingTranslationStrings = !!fillMissingTranslationStrings;\r\n } else {\r\n errors.push(new WebpackError('Missing default locale name'));\r\n return { errors, warnings };\r\n }\r\n } else {\r\n errors.push(new WebpackError('Missing default locale options.'));\r\n return { errors, warnings };\r\n }\r\n // END options.localizedData.defaultLocale\r\n\r\n // START options.localizedData.pseudoLocales\r\n const { pseudolocales } = localizedData;\r\n if (pseudolocales) {\r\n for (const [pseudolocaleName, pseudoLocaleOpts] of Object.entries(pseudolocales)) {\r\n if (this._defaultLocale === pseudolocaleName) {\r\n errors.push(\r\n new WebpackError(`A pseudolocale (${pseudolocaleName}) name is also the default locale name.`)\r\n );\r\n return { errors, warnings };\r\n }\r\n\r\n if (this._resolvedLocalizedStrings.has(pseudolocaleName)) {\r\n errors.push(\r\n new WebpackError(\r\n `A pseudolocale (${pseudolocaleName}) name is also specified in the translated strings.`\r\n )\r\n );\r\n return { errors, warnings };\r\n }\r\n\r\n this._pseudolocalizers.set(pseudolocaleName, getPseudolocalizer(pseudoLocaleOpts));\r\n this._resolvedLocalizedStrings.set(pseudolocaleName, new Map<string, Map<string, string>>());\r\n }\r\n }\r\n // END options.localizedData.pseudoLocales\r\n } else if (!isWebpackDevServer) {\r\n throw new Error('Localized data must be provided unless webpack dev server is running.');\r\n }\r\n // END options.localizedData\r\n\r\n // START options.noStringsLocaleName\r\n const { noStringsLocaleName } = this._options;\r\n if (\r\n noStringsLocaleName === undefined ||\r\n noStringsLocaleName === null ||\r\n !ensureValidLocaleName(noStringsLocaleName)\r\n ) {\r\n this._noStringsLocaleName = 'none';\r\n } else {\r\n this._noStringsLocaleName = noStringsLocaleName;\r\n }\r\n // END options.noStringsLocaleName\r\n\r\n return { errors, warnings };\r\n }\r\n}\r\n\r\nfunction _chunkHasLocalizedModules(\r\n chunkGraph: ChunkGraph,\r\n chunk: Chunk,\r\n runtimeLocaleExpression: string | undefined\r\n): boolean {\r\n let chunkHasAnyLocModules: boolean | undefined = getMark(chunk);\r\n if (chunkHasAnyLocModules === undefined) {\r\n chunkHasAnyLocModules = false;\r\n const candidateModules: Iterable<Module> | undefined = chunkGraph.getChunkModulesIterableBySourceType(\r\n chunk,\r\n 'javascript'\r\n );\r\n if (candidateModules) {\r\n outer: for (const module of candidateModules) {\r\n const moduleMark: boolean | undefined = getMark(module);\r\n if (moduleMark) {\r\n chunkHasAnyLocModules = true;\r\n break;\r\n } else if (moduleMark === false) {\r\n continue;\r\n }\r\n\r\n // Is this a concatenated module?\r\n const { _modules: modules } = module as { _modules?: Iterable<Module> };\r\n if (modules) {\r\n for (const nestedModule of modules) {\r\n if (getMark(nestedModule)) {\r\n markEntity(module, true);\r\n chunkHasAnyLocModules = true;\r\n break outer;\r\n }\r\n }\r\n markEntity(module, false);\r\n }\r\n }\r\n }\r\n\r\n // If this chunk doesn't directly contain any localized resources, it still\r\n // needs to be localized if it's an entrypoint chunk (i.e. - it has a runtime)\r\n // and it loads localized async chunks.\r\n // In that case, the generated chunk URL generation code needs to contain\r\n // the locale name.\r\n if (!chunkHasAnyLocModules && !runtimeLocaleExpression && chunk.hasRuntime()) {\r\n for (const asyncChunk of chunk.getAllAsyncChunks()) {\r\n if (_chunkHasLocalizedModules(chunkGraph, asyncChunk, runtimeLocaleExpression)) {\r\n chunkHasAnyLocModules = true;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n markEntity(chunk, chunkHasAnyLocModules);\r\n }\r\n\r\n return chunkHasAnyLocModules;\r\n}\r\n\r\nfunction convertLocalizationFileToLocData(locFile: ILocalizationFile): ReadonlyMap<string, string> {\r\n const locFileData: Map<string, string> = new Map();\r\n for (const [stringName, locFileEntry] of Object.entries(locFile)) {\r\n locFileData.set(stringName, locFileEntry.value);\r\n }\r\n\r\n return locFileData;\r\n}\r\n\r\nasync function normalizeLocalizedData(\r\n context: LoaderContext<{}>,\r\n localizedData: ILocaleFileData\r\n): Promise<ReadonlyMap<string, string>> {\r\n if (typeof localizedData === 'string') {\r\n // The value is the path to a file. Add it as a file dependency\r\n context.addDependency(localizedData);\r\n const content: string = await new Promise((resolve, reject) => {\r\n // Use context.fs so that the plugin is compatible with overriding compiler.inputFileSystem\r\n context.fs.readFile(localizedData, (err, data) => {\r\n if (err) {\r\n return reject(err);\r\n } else if (!data) {\r\n return reject(new Error(`No data in ${localizedData}`));\r\n }\r\n resolve(data.toString());\r\n });\r\n });\r\n\r\n const localizationFile: ILocalizationFile = parseResJson({\r\n filePath: localizedData,\r\n content\r\n });\r\n\r\n return convertLocalizationFileToLocData(localizationFile);\r\n } else {\r\n return localizedData instanceof Map ? localizedData : new Map(Object.entries(localizedData));\r\n }\r\n}\r\n"]}
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,2DAAqG;AAA5F,wHAAA,kBAAkB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport { LocalizationPlugin, IStringPlaceholder as _IStringPlaceholder } from './LocalizationPlugin';\n\nexport {\n IDefaultLocaleOptions,\n ILocaleData,\n ILocaleElementMap,\n ILocaleFileData,\n ILocaleFileObject,\n ILocalizationPluginOptions,\n ILocalizationStats,\n ILocalizationStatsChunkGroup,\n ILocalizationStatsEntrypoint,\n ILocalizationStatsOptions,\n ILocalizedData,\n ILocalizedStrings,\n IPassthroughLocaleOptions,\n IPseudolocalesOptions,\n IResolvedMissingTranslations\n} from './interfaces';\n\nexport { ILocalizedWebpackChunk } from './webpackInterfaces';\n"]}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,2DAAqG;AAA5F,wHAAA,kBAAkB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nexport { LocalizationPlugin, IStringPlaceholder as _IStringPlaceholder } from './LocalizationPlugin';\r\n\r\nexport {\r\n IDefaultLocaleOptions,\r\n ILocaleData,\r\n ILocaleElementMap,\r\n ILocaleFileData,\r\n ILocaleFileObject,\r\n ILocalizationPluginOptions,\r\n ILocalizationStats,\r\n ILocalizationStatsChunkGroup,\r\n ILocalizationStatsEntrypoint,\r\n ILocalizationStatsOptions,\r\n ILocalizedData,\r\n ILocalizedStrings,\r\n IPassthroughLocaleOptions,\r\n IPseudolocalesOptions,\r\n IResolvedMissingTranslations\r\n} from './interfaces';\r\n\r\nexport { ILocalizedWebpackChunk } from './webpackInterfaces';\r\n"]}
|
package/lib/interfaces.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { LoaderContext } from 'webpack';\nimport type { IPseudolocaleOptions } from '@rushstack/localization-utilities';\n\n/**\n * Options for the passthrough locale.\n *\n * @public\n */\nexport interface IPassthroughLocaleOptions {\n /**\n * If this is set to `true`, a passthrough locale will be included in the output\n */\n usePassthroughLocale?: boolean;\n\n /**\n * If {@link IPassthroughLocaleOptions.usePassthroughLocale} is set, use this name for the passthrough locale.\n * Defaults to \"passthrough\"\n */\n passthroughLocaleName?: string;\n}\n\n/**\n * @public\n */\nexport interface IDefaultLocaleOptions {\n /**\n * This required property specifies the name of the locale used in the\n * `.resx`, `.loc.json`, and `.resjson` files in the source\n */\n localeName: string;\n\n /**\n * If this option is set to `true`, strings that are missing from\n * `localizedData.translatedStrings` will be provided by the default locale\n */\n fillMissingTranslationStrings?: boolean;\n}\n\n/**\n * Options for generated pseudolocales.\n *\n * @public\n */\nexport interface IPseudolocalesOptions {\n [pseudoLocaleName: string]: IPseudolocaleOptions;\n}\n\n/**\n * @public\n */\nexport interface ILocalizedData {\n /**\n * Options for the locale used in the source localized data files.\n */\n defaultLocale: IDefaultLocaleOptions;\n\n /**\n * Use this parameter to specify the translated data.\n */\n translatedStrings: ILocalizedStrings;\n\n /**\n * Use this parameter to specify a function used to load translations missing from\n * the {@link ILocalizedData.translatedStrings} parameter.\n */\n resolveMissingTranslatedStrings?: (\n locales: string[],\n localizedFileKey: string,\n loaderContext: LoaderContext<{}>\n ) => Promise<IResolvedMissingTranslations> | IResolvedMissingTranslations;\n\n /**\n * Options around including a passthrough locale.\n */\n passthroughLocale?: IPassthroughLocaleOptions;\n\n /**\n * Options for pseudo-localization.\n */\n pseudolocales?: IPseudolocalesOptions;\n}\n\n/**\n * Options for how localization stats data should be produced.\n *\n * @public\n */\nexport interface ILocalizationStatsOptions {\n /**\n * This option is used to designate a path at which a JSON file describing the localized\n * assets produced should be written.\n */\n dropPath?: string;\n\n /**\n * This option is used to specify a callback to be called with the stats data that would be\n * dropped at `localizationStats.dropPath` after compilation completes.\n */\n callback?: (stats: ILocalizationStats) => void;\n}\n\n/**\n * The options for localization.\n *\n * @public\n */\nexport interface ILocalizationPluginOptions {\n /**\n * Localization data.\n */\n localizedData: ILocalizedData;\n\n /**\n * This option is used to specify `.resx`, `.resx.json`, and `.loc.json` files that should not be processed by\n * this plugin.\n */\n globsToIgnore?: string[];\n\n /**\n * The value to replace the [locale] token with for chunks without localized strings. Defaults to \"none\"\n */\n noStringsLocaleName?: string;\n\n /**\n * A chunk of javascript to use to get the current locale at runtime. If specified, allows the runtime chunk\n * to be non-localized even if it has async localized chunks, as long as it does not directly contain strings.\n */\n runtimeLocaleExpression?: string;\n\n /**\n * Options for how localization stats data should be produced.\n */\n localizationStats?: ILocalizationStatsOptions;\n}\n\n/**\n * @public\n */\nexport interface ILocaleFileObject {\n [stringName: string]: string;\n}\n\n/**\n * @public\n * Accepted formats:\n * - A string containing the path to the translations in .resjson format (keys mapped directly to values)\n * - An object mapping keys directly to values\n * - A map mapping keys directly to values\n */\nexport type ILocaleFileData = string | ILocaleFileObject | ReadonlyMap<string, string>;\n\n/**\n * @public\n */\nexport type IResolvedMissingTranslations = ReadonlyMap<string, ILocaleFileData>;\n\n/**\n * @public\n */\nexport interface ILocaleData {\n [locFilePath: string]: ILocaleFileData;\n}\n\n/**\n * @public\n */\nexport interface ILocalizedStrings {\n [locale: string]: ILocaleData;\n}\n\n/**\n * @public\n */\nexport interface ILocaleElementMap {\n [locale: string]: string;\n}\n\n/**\n * @public\n */\nexport interface ILocalizationStatsEntrypoint {\n localizedAssets: ILocaleElementMap;\n}\n\n/**\n * @public\n */\nexport interface ILocalizationStatsChunkGroup {\n localizedAssets: ILocaleElementMap;\n}\n\n/**\n * @public\n */\nexport interface ILocalizationStats {\n entrypoints: { [name: string]: ILocalizationStatsEntrypoint };\n namedChunkGroups: { [name: string]: ILocalizationStatsChunkGroup };\n}\n"]}
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { LoaderContext } from 'webpack';\r\nimport type { IPseudolocaleOptions } from '@rushstack/localization-utilities';\r\n\r\n/**\r\n * Options for the passthrough locale.\r\n *\r\n * @public\r\n */\r\nexport interface IPassthroughLocaleOptions {\r\n /**\r\n * If this is set to `true`, a passthrough locale will be included in the output\r\n */\r\n usePassthroughLocale?: boolean;\r\n\r\n /**\r\n * If {@link IPassthroughLocaleOptions.usePassthroughLocale} is set, use this name for the passthrough locale.\r\n * Defaults to \"passthrough\"\r\n */\r\n passthroughLocaleName?: string;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface IDefaultLocaleOptions {\r\n /**\r\n * This required property specifies the name of the locale used in the\r\n * `.resx`, `.loc.json`, and `.resjson` files in the source\r\n */\r\n localeName: string;\r\n\r\n /**\r\n * If this option is set to `true`, strings that are missing from\r\n * `localizedData.translatedStrings` will be provided by the default locale\r\n */\r\n fillMissingTranslationStrings?: boolean;\r\n}\r\n\r\n/**\r\n * Options for generated pseudolocales.\r\n *\r\n * @public\r\n */\r\nexport interface IPseudolocalesOptions {\r\n [pseudoLocaleName: string]: IPseudolocaleOptions;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ILocalizedData {\r\n /**\r\n * Options for the locale used in the source localized data files.\r\n */\r\n defaultLocale: IDefaultLocaleOptions;\r\n\r\n /**\r\n * Use this parameter to specify the translated data.\r\n */\r\n translatedStrings: ILocalizedStrings;\r\n\r\n /**\r\n * Use this parameter to specify a function used to load translations missing from\r\n * the {@link ILocalizedData.translatedStrings} parameter.\r\n */\r\n resolveMissingTranslatedStrings?: (\r\n locales: string[],\r\n localizedFileKey: string,\r\n loaderContext: LoaderContext<{}>\r\n ) => Promise<IResolvedMissingTranslations> | IResolvedMissingTranslations;\r\n\r\n /**\r\n * Options around including a passthrough locale.\r\n */\r\n passthroughLocale?: IPassthroughLocaleOptions;\r\n\r\n /**\r\n * Options for pseudo-localization.\r\n */\r\n pseudolocales?: IPseudolocalesOptions;\r\n}\r\n\r\n/**\r\n * Options for how localization stats data should be produced.\r\n *\r\n * @public\r\n */\r\nexport interface ILocalizationStatsOptions {\r\n /**\r\n * This option is used to designate a path at which a JSON file describing the localized\r\n * assets produced should be written.\r\n */\r\n dropPath?: string;\r\n\r\n /**\r\n * This option is used to specify a callback to be called with the stats data that would be\r\n * dropped at `localizationStats.dropPath` after compilation completes.\r\n */\r\n callback?: (stats: ILocalizationStats) => void;\r\n}\r\n\r\n/**\r\n * The options for localization.\r\n *\r\n * @public\r\n */\r\nexport interface ILocalizationPluginOptions {\r\n /**\r\n * Localization data.\r\n */\r\n localizedData: ILocalizedData;\r\n\r\n /**\r\n * This option is used to specify `.resx`, `.resx.json`, and `.loc.json` files that should not be processed by\r\n * this plugin.\r\n */\r\n globsToIgnore?: string[];\r\n\r\n /**\r\n * The value to replace the [locale] token with for chunks without localized strings. Defaults to \"none\"\r\n */\r\n noStringsLocaleName?: string;\r\n\r\n /**\r\n * A chunk of javascript to use to get the current locale at runtime. If specified, allows the runtime chunk\r\n * to be non-localized even if it has async localized chunks, as long as it does not directly contain strings.\r\n */\r\n runtimeLocaleExpression?: string;\r\n\r\n /**\r\n * Options for how localization stats data should be produced.\r\n */\r\n localizationStats?: ILocalizationStatsOptions;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ILocaleFileObject {\r\n [stringName: string]: string;\r\n}\r\n\r\n/**\r\n * @public\r\n * Accepted formats:\r\n * - A string containing the path to the translations in .resjson format (keys mapped directly to values)\r\n * - An object mapping keys directly to values\r\n * - A map mapping keys directly to values\r\n */\r\nexport type ILocaleFileData = string | ILocaleFileObject | ReadonlyMap<string, string>;\r\n\r\n/**\r\n * @public\r\n */\r\nexport type IResolvedMissingTranslations = ReadonlyMap<string, ILocaleFileData>;\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ILocaleData {\r\n [locFilePath: string]: ILocaleFileData;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ILocalizedStrings {\r\n [locale: string]: ILocaleData;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ILocaleElementMap {\r\n [locale: string]: string;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ILocalizationStatsEntrypoint {\r\n localizedAssets: ILocaleElementMap;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ILocalizationStatsChunkGroup {\r\n localizedAssets: ILocaleElementMap;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ILocalizationStats {\r\n entrypoints: { [name: string]: ILocalizationStatsEntrypoint };\r\n namedChunkGroups: { [name: string]: ILocalizationStatsChunkGroup };\r\n}\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"IResxLoaderOptions.js","sourceRoot":"","sources":["../../src/loaders/IResxLoaderOptions.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { IParseResxOptionsBase } from '@rushstack/localization-utilities';\nimport type { IBaseLocLoaderOptions } from './LoaderFactory';\n\n/**\n * @public\n */\nexport type IResxLoaderOptions = Omit<IParseResxOptionsBase, 'terminal'>;\n\n/**\n * @public\n */\nexport interface IResxLocLoaderOptions extends IResxLoaderOptions, IBaseLocLoaderOptions {}\n"]}
|
1
|
+
{"version":3,"file":"IResxLoaderOptions.js","sourceRoot":"","sources":["../../src/loaders/IResxLoaderOptions.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { IParseResxOptionsBase } from '@rushstack/localization-utilities';\r\nimport type { IBaseLocLoaderOptions } from './LoaderFactory';\r\n\r\n/**\r\n * @public\r\n */\r\nexport type IResxLoaderOptions = Omit<IParseResxOptionsBase, 'terminal'>;\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface IResxLocLoaderOptions extends IResxLoaderOptions, IBaseLocLoaderOptions {}\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LoaderFactory.js","sourceRoot":"","sources":["../../src/loaders/LoaderFactory.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAM3D,8DAAmF;AAMnF,SAAgB,YAAY,CAC1B,SAA8F;IAE9F,sCAAsC;IACtC,MAAM,MAAM,GAAgC,KAAK,WAE/C,OAAe;QAEf,MAAM,WAAW,GAAW,IAAI,CAAC,YAAY,CAAC;QAE9C,MAAM,cAAc,GAAuB,IAAA,sCAAiB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE7E,MAAM,WAAW,GAAsB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QAE7E,MAAM,OAAO,GAA2B,MAAM,cAAc,CAAC,sBAAsB,CACjF,IAAI,EACJ,WAAW,EACX,WAAW,CACZ,CAAC;QAEF,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAQ,CAAC;QAE/B,QAAQ,IAAI,EAAE;YACZ,KAAK,MAAM;gBACT,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACjC,KAAK,iBAAiB,CAAC;YACvB,KAAK,gBAAgB;gBACnB,OAAO,mBAAmB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,4BAA4B,CAAC;YAChF;gBACE,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,oCAAoC,IAAI,eAAe,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;gBACtG,OAAO,EAAE,CAAC;SACb;IACH,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAnCD,oCAmCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\n\nimport type { ILocalizationFile } from '@rushstack/localization-utilities';\n\nimport { getPluginInstance, type LocalizationPlugin } from '../LocalizationPlugin';\n\nexport interface IBaseLocLoaderOptions {\n // Nothing\n}\n\nexport function createLoader<T extends IBaseLocLoaderOptions>(\n parseFile: (content: string, filePath: string, context: LoaderContext<T>) => ILocalizationFile\n): LoaderDefinitionFunction<T> {\n // eslint-disable-next-line func-style\n const loader: LoaderDefinitionFunction<T> = async function (\n this: LoaderContext<T>,\n content: string\n ): Promise<string> {\n const locFilePath: string = this.resourcePath;\n\n const pluginInstance: LocalizationPlugin = getPluginInstance(this._compiler);\n\n const locFileData: ILocalizationFile = parseFile(content, locFilePath, this);\n\n const strings: Record<string, string> = await pluginInstance.addDefaultLocFileAsync(\n this,\n locFilePath,\n locFileData\n );\n\n const { type } = this._module!;\n\n switch (type) {\n case 'json':\n return JSON.stringify(strings);\n case 'javascript/auto':\n case 'javascript/esm':\n return `const strings = ${JSON.stringify(strings)};\\nexport default strings;`;\n default:\n this.emitError(new Error(`Unexpected localized module type ${type} for module ${this.resourcePath}`));\n return '';\n }\n };\n\n return loader;\n}\n"]}
|
1
|
+
{"version":3,"file":"LoaderFactory.js","sourceRoot":"","sources":["../../src/loaders/LoaderFactory.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAM3D,8DAAmF;AAMnF,SAAgB,YAAY,CAC1B,SAA8F;IAE9F,sCAAsC;IACtC,MAAM,MAAM,GAAgC,KAAK,WAE/C,OAAe;QAEf,MAAM,WAAW,GAAW,IAAI,CAAC,YAAY,CAAC;QAE9C,MAAM,cAAc,GAAuB,IAAA,sCAAiB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE7E,MAAM,WAAW,GAAsB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QAE7E,MAAM,OAAO,GAA2B,MAAM,cAAc,CAAC,sBAAsB,CACjF,IAAI,EACJ,WAAW,EACX,WAAW,CACZ,CAAC;QAEF,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAQ,CAAC;QAE/B,QAAQ,IAAI,EAAE;YACZ,KAAK,MAAM;gBACT,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACjC,KAAK,iBAAiB,CAAC;YACvB,KAAK,gBAAgB;gBACnB,OAAO,mBAAmB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,4BAA4B,CAAC;YAChF;gBACE,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,oCAAoC,IAAI,eAAe,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;gBACtG,OAAO,EAAE,CAAC;SACb;IACH,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAnCD,oCAmCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\r\n\r\nimport type { ILocalizationFile } from '@rushstack/localization-utilities';\r\n\r\nimport { getPluginInstance, type LocalizationPlugin } from '../LocalizationPlugin';\r\n\r\nexport interface IBaseLocLoaderOptions {\r\n // Nothing\r\n}\r\n\r\nexport function createLoader<T extends IBaseLocLoaderOptions>(\r\n parseFile: (content: string, filePath: string, context: LoaderContext<T>) => ILocalizationFile\r\n): LoaderDefinitionFunction<T> {\r\n // eslint-disable-next-line func-style\r\n const loader: LoaderDefinitionFunction<T> = async function (\r\n this: LoaderContext<T>,\r\n content: string\r\n ): Promise<string> {\r\n const locFilePath: string = this.resourcePath;\r\n\r\n const pluginInstance: LocalizationPlugin = getPluginInstance(this._compiler);\r\n\r\n const locFileData: ILocalizationFile = parseFile(content, locFilePath, this);\r\n\r\n const strings: Record<string, string> = await pluginInstance.addDefaultLocFileAsync(\r\n this,\r\n locFilePath,\r\n locFileData\r\n );\r\n\r\n const { type } = this._module!;\r\n\r\n switch (type) {\r\n case 'json':\r\n return JSON.stringify(strings);\r\n case 'javascript/auto':\r\n case 'javascript/esm':\r\n return `const strings = ${JSON.stringify(strings)};\\nexport default strings;`;\r\n default:\r\n this.emitError(new Error(`Unexpected localized module type ${type} for module ${this.resourcePath}`));\r\n return '';\r\n }\r\n };\r\n\r\n return loader;\r\n}\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"default-locale-loader.js","sourceRoot":"","sources":["../../src/loaders/default-locale-loader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,oEAAwD;AACxD,8EAAyF;AAGzF,gFAA6E;AAE7E;;GAEG;AACH,sCAAsC;AACtC,MAAM,MAAM,GAAiD,UAE3D,OAAe;IAEf,MAAM,OAAO,GAAuB,IAAI,CAAC,UAAU,EAAE,CAAC;IAEtD,MAAM,WAAW,GAAsB,IAAA,qCAAY,EAAC;QAClD,GAAG,OAAO;QACV,OAAO;QACP,QAAQ,EAAE,IAAI,CAAC,YAAY;QAC3B,QAAQ,EAAE,IAAI,4BAAQ,CAAC,+CAAsB,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC;KAClF,CAAC,CAAC;IAEH,MAAM,YAAY,GAAqC,EAAE,CAAC;IAC1D,KAAK,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QACnE,YAAY,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC;KAC9C;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\nimport { Terminal } from '@rushstack/node-core-library';\nimport { type ILocalizationFile, parseLocFile } from '@rushstack/localization-utilities';\n\nimport type { IResxLoaderOptions } from './IResxLoaderOptions';\nimport { LoaderTerminalProvider } from '../utilities/LoaderTerminalProvider';\n\n/**\n * This loader passes through the raw untranslated strings and may be used without a LocalizationPlugin instance.\n */\n// eslint-disable-next-line func-style\nconst loader: LoaderDefinitionFunction<IResxLoaderOptions> = function (\n this: LoaderContext<IResxLoaderOptions>,\n content: string\n): string {\n const options: IResxLoaderOptions = this.getOptions();\n\n const locFileData: ILocalizationFile = parseLocFile({\n ...options,\n content,\n filePath: this.resourcePath,\n terminal: new Terminal(LoaderTerminalProvider.getTerminalProviderForLoader(this))\n });\n\n const resultObject: { [stringName: string]: string } = {};\n for (const [stringName, stringValue] of Object.entries(locFileData)) {\n resultObject[stringName] = stringValue.value;\n }\n\n return JSON.stringify(resultObject);\n};\n\nexport default loader;\n"]}
|
1
|
+
{"version":3,"file":"default-locale-loader.js","sourceRoot":"","sources":["../../src/loaders/default-locale-loader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,oEAAwD;AACxD,8EAAyF;AAGzF,gFAA6E;AAE7E;;GAEG;AACH,sCAAsC;AACtC,MAAM,MAAM,GAAiD,UAE3D,OAAe;IAEf,MAAM,OAAO,GAAuB,IAAI,CAAC,UAAU,EAAE,CAAC;IAEtD,MAAM,WAAW,GAAsB,IAAA,qCAAY,EAAC;QAClD,GAAG,OAAO;QACV,OAAO;QACP,QAAQ,EAAE,IAAI,CAAC,YAAY;QAC3B,QAAQ,EAAE,IAAI,4BAAQ,CAAC,+CAAsB,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC;KAClF,CAAC,CAAC;IAEH,MAAM,YAAY,GAAqC,EAAE,CAAC;IAC1D,KAAK,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QACnE,YAAY,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC;KAC9C;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\r\nimport { Terminal } from '@rushstack/node-core-library';\r\nimport { type ILocalizationFile, parseLocFile } from '@rushstack/localization-utilities';\r\n\r\nimport type { IResxLoaderOptions } from './IResxLoaderOptions';\r\nimport { LoaderTerminalProvider } from '../utilities/LoaderTerminalProvider';\r\n\r\n/**\r\n * This loader passes through the raw untranslated strings and may be used without a LocalizationPlugin instance.\r\n */\r\n// eslint-disable-next-line func-style\r\nconst loader: LoaderDefinitionFunction<IResxLoaderOptions> = function (\r\n this: LoaderContext<IResxLoaderOptions>,\r\n content: string\r\n): string {\r\n const options: IResxLoaderOptions = this.getOptions();\r\n\r\n const locFileData: ILocalizationFile = parseLocFile({\r\n ...options,\r\n content,\r\n filePath: this.resourcePath,\r\n terminal: new Terminal(LoaderTerminalProvider.getTerminalProviderForLoader(this))\r\n });\r\n\r\n const resultObject: { [stringName: string]: string } = {};\r\n for (const [stringName, stringValue] of Object.entries(locFileData)) {\r\n resultObject[stringName] = stringValue.value;\r\n }\r\n\r\n return JSON.stringify(resultObject);\r\n};\r\n\r\nexport default loader;\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"loc-loader.js","sourceRoot":"","sources":["../../src/loaders/loc-loader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAI3D,oEAA0E;AAC1E,8EAAiE;AAGjE,mDAA2E;AAC3E,gFAA6E;AAQ7E;;GAEG;AACH,MAAM,MAAM,GAAgD,IAAA,4BAAY,EACtE,CAAC,OAAe,EAAE,QAAgB,EAAE,OAAyC,EAAE,EAAE;IAC/E,MAAM,OAAO,GAAsB,OAAO,CAAC,UAAU,EAAE,CAAC;IACxD,MAAM,QAAQ,GAAa,IAAI,4BAAQ,CAAC,+CAAsB,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC,CAAC;IAEtG,OAAO,IAAA,qCAAY,EAAC;QAClB,GAAG,OAAO;QACV,QAAQ;QACR,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\n\nimport { Terminal, type NewlineKind } from '@rushstack/node-core-library';\nimport { parseLocFile } from '@rushstack/localization-utilities';\n\nimport type { LocalizationPlugin } from '../LocalizationPlugin';\nimport { createLoader, type IBaseLocLoaderOptions } from './LoaderFactory';\nimport { LoaderTerminalProvider } from '../utilities/LoaderTerminalProvider';\n\nexport interface ILocLoaderOptions extends IBaseLocLoaderOptions {\n pluginInstance: LocalizationPlugin;\n resxNewlineNormalization: NewlineKind | undefined;\n ignoreMissingResxComments: boolean | undefined;\n}\n\n/**\n * General purpose loader that dispatches based on file extension.\n */\nconst loader: LoaderDefinitionFunction<ILocLoaderOptions> = createLoader(\n (content: string, filePath: string, context: LoaderContext<ILocLoaderOptions>) => {\n const options: ILocLoaderOptions = context.getOptions();\n const terminal: Terminal = new Terminal(LoaderTerminalProvider.getTerminalProviderForLoader(context));\n\n return parseLocFile({\n ...options,\n terminal,\n content,\n filePath\n });\n }\n);\n\nexport default loader;\n"]}
|
1
|
+
{"version":3,"file":"loc-loader.js","sourceRoot":"","sources":["../../src/loaders/loc-loader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAI3D,oEAA0E;AAC1E,8EAAiE;AAGjE,mDAA2E;AAC3E,gFAA6E;AAQ7E;;GAEG;AACH,MAAM,MAAM,GAAgD,IAAA,4BAAY,EACtE,CAAC,OAAe,EAAE,QAAgB,EAAE,OAAyC,EAAE,EAAE;IAC/E,MAAM,OAAO,GAAsB,OAAO,CAAC,UAAU,EAAE,CAAC;IACxD,MAAM,QAAQ,GAAa,IAAI,4BAAQ,CAAC,+CAAsB,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC,CAAC;IAEtG,OAAO,IAAA,qCAAY,EAAC;QAClB,GAAG,OAAO;QACV,QAAQ;QACR,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\r\n\r\nimport { Terminal, type NewlineKind } from '@rushstack/node-core-library';\r\nimport { parseLocFile } from '@rushstack/localization-utilities';\r\n\r\nimport type { LocalizationPlugin } from '../LocalizationPlugin';\r\nimport { createLoader, type IBaseLocLoaderOptions } from './LoaderFactory';\r\nimport { LoaderTerminalProvider } from '../utilities/LoaderTerminalProvider';\r\n\r\nexport interface ILocLoaderOptions extends IBaseLocLoaderOptions {\r\n pluginInstance: LocalizationPlugin;\r\n resxNewlineNormalization: NewlineKind | undefined;\r\n ignoreMissingResxComments: boolean | undefined;\r\n}\r\n\r\n/**\r\n * General purpose loader that dispatches based on file extension.\r\n */\r\nconst loader: LoaderDefinitionFunction<ILocLoaderOptions> = createLoader(\r\n (content: string, filePath: string, context: LoaderContext<ILocLoaderOptions>) => {\r\n const options: ILocLoaderOptions = context.getOptions();\r\n const terminal: Terminal = new Terminal(LoaderTerminalProvider.getTerminalProviderForLoader(context));\r\n\r\n return parseLocFile({\r\n ...options,\r\n terminal,\r\n content,\r\n filePath\r\n });\r\n }\r\n);\r\n\r\nexport default loader;\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"locjson-loader.js","sourceRoot":"","sources":["../../src/loaders/locjson-loader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,8EAAiE;AAEjE,mDAA2E;AAE3E,MAAM,MAAM,GAAoD,IAAA,4BAAY,EAC1E,CAAC,OAAe,EAAE,QAAgB,EAAE,OAA6C,EAAE,EAAE;IACnF,OAAO,IAAA,qCAAY,EAAC;QAClB,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\nimport { parseLocJson } from '@rushstack/localization-utilities';\n\nimport { createLoader, type IBaseLocLoaderOptions } from './LoaderFactory';\n\nconst loader: LoaderDefinitionFunction<IBaseLocLoaderOptions> = createLoader(\n (content: string, filePath: string, context: LoaderContext<IBaseLocLoaderOptions>) => {\n return parseLocJson({\n content,\n filePath\n });\n }\n);\n\nexport default loader;\n"]}
|
1
|
+
{"version":3,"file":"locjson-loader.js","sourceRoot":"","sources":["../../src/loaders/locjson-loader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,8EAAiE;AAEjE,mDAA2E;AAE3E,MAAM,MAAM,GAAoD,IAAA,4BAAY,EAC1E,CAAC,OAAe,EAAE,QAAgB,EAAE,OAA6C,EAAE,EAAE;IACnF,OAAO,IAAA,qCAAY,EAAC;QAClB,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\r\nimport { parseLocJson } from '@rushstack/localization-utilities';\r\n\r\nimport { createLoader, type IBaseLocLoaderOptions } from './LoaderFactory';\r\n\r\nconst loader: LoaderDefinitionFunction<IBaseLocLoaderOptions> = createLoader(\r\n (content: string, filePath: string, context: LoaderContext<IBaseLocLoaderOptions>) => {\r\n return parseLocJson({\r\n content,\r\n filePath\r\n });\r\n }\r\n);\r\n\r\nexport default loader;\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"resjson-loader.js","sourceRoot":"","sources":["../../src/loaders/resjson-loader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,8EAAiE;AAEjE,mDAA2E;AAE3E,MAAM,MAAM,GAAoD,IAAA,4BAAY,EAC1E,CAAC,OAAe,EAAE,QAAgB,EAAE,OAA6C,EAAE,EAAE;IACnF,OAAO,IAAA,qCAAY,EAAC;QAClB,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\nimport { parseResJson } from '@rushstack/localization-utilities';\n\nimport { createLoader, type IBaseLocLoaderOptions } from './LoaderFactory';\n\nconst loader: LoaderDefinitionFunction<IBaseLocLoaderOptions> = createLoader(\n (content: string, filePath: string, context: LoaderContext<IBaseLocLoaderOptions>) => {\n return parseResJson({\n content,\n filePath\n });\n }\n);\n\nexport default loader;\n"]}
|
1
|
+
{"version":3,"file":"resjson-loader.js","sourceRoot":"","sources":["../../src/loaders/resjson-loader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,8EAAiE;AAEjE,mDAA2E;AAE3E,MAAM,MAAM,GAAoD,IAAA,4BAAY,EAC1E,CAAC,OAAe,EAAE,QAAgB,EAAE,OAA6C,EAAE,EAAE;IACnF,OAAO,IAAA,qCAAY,EAAC;QAClB,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\r\nimport { parseResJson } from '@rushstack/localization-utilities';\r\n\r\nimport { createLoader, type IBaseLocLoaderOptions } from './LoaderFactory';\r\n\r\nconst loader: LoaderDefinitionFunction<IBaseLocLoaderOptions> = createLoader(\r\n (content: string, filePath: string, context: LoaderContext<IBaseLocLoaderOptions>) => {\r\n return parseResJson({\r\n content,\r\n filePath\r\n });\r\n }\r\n);\r\n\r\nexport default loader;\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"resx-loader.js","sourceRoot":"","sources":["../../src/loaders/resx-loader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,oEAAwD;AACxD,8EAA8D;AAG9D,mDAA+C;AAC/C,gFAA6E;AAE7E,MAAM,MAAM,GAAoD,IAAA,4BAAY,EAC1E,CAAC,OAAe,EAAE,QAAgB,EAAE,OAA6C,EAAE,EAAE;IACnF,MAAM,OAAO,GAA0B,OAAO,CAAC,UAAU,EAAE,CAAC;IAC5D,MAAM,QAAQ,GAAa,IAAI,4BAAQ,CAAC,+CAAsB,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC,CAAC;IAEtG,OAAO,IAAA,kCAAS,EAAC;QACf,OAAO;QACP,QAAQ;QACR,QAAQ;QACR,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;QAC1D,yBAAyB,EAAE,CAAC,OAAO,CAAC,yBAAyB;KAC9D,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\nimport { Terminal } from '@rushstack/node-core-library';\nimport { parseResx } from '@rushstack/localization-utilities';\nimport type { IResxLocLoaderOptions } from './IResxLoaderOptions';\n\nimport { createLoader } from './LoaderFactory';\nimport { LoaderTerminalProvider } from '../utilities/LoaderTerminalProvider';\n\nconst loader: LoaderDefinitionFunction<IResxLocLoaderOptions> = createLoader(\n (content: string, filePath: string, context: LoaderContext<IResxLocLoaderOptions>) => {\n const options: IResxLocLoaderOptions = context.getOptions();\n const terminal: Terminal = new Terminal(LoaderTerminalProvider.getTerminalProviderForLoader(context));\n\n return parseResx({\n content,\n filePath,\n terminal,\n resxNewlineNormalization: options.resxNewlineNormalization,\n ignoreMissingResxComments: !options.ignoreMissingResxComments\n });\n }\n);\n\nexport default loader;\n"]}
|
1
|
+
{"version":3,"file":"resx-loader.js","sourceRoot":"","sources":["../../src/loaders/resx-loader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,oEAAwD;AACxD,8EAA8D;AAG9D,mDAA+C;AAC/C,gFAA6E;AAE7E,MAAM,MAAM,GAAoD,IAAA,4BAAY,EAC1E,CAAC,OAAe,EAAE,QAAgB,EAAE,OAA6C,EAAE,EAAE;IACnF,MAAM,OAAO,GAA0B,OAAO,CAAC,UAAU,EAAE,CAAC;IAC5D,MAAM,QAAQ,GAAa,IAAI,4BAAQ,CAAC,+CAAsB,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC,CAAC;IAEtG,OAAO,IAAA,kCAAS,EAAC;QACf,OAAO;QACP,QAAQ;QACR,QAAQ;QACR,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;QAC1D,yBAAyB,EAAE,CAAC,OAAO,CAAC,yBAAyB;KAC9D,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\r\nimport { Terminal } from '@rushstack/node-core-library';\r\nimport { parseResx } from '@rushstack/localization-utilities';\r\nimport type { IResxLocLoaderOptions } from './IResxLoaderOptions';\r\n\r\nimport { createLoader } from './LoaderFactory';\r\nimport { LoaderTerminalProvider } from '../utilities/LoaderTerminalProvider';\r\n\r\nconst loader: LoaderDefinitionFunction<IResxLocLoaderOptions> = createLoader(\r\n (content: string, filePath: string, context: LoaderContext<IResxLocLoaderOptions>) => {\r\n const options: IResxLocLoaderOptions = context.getOptions();\r\n const terminal: Terminal = new Terminal(LoaderTerminalProvider.getTerminalProviderForLoader(context));\r\n\r\n return parseResx({\r\n content,\r\n filePath,\r\n terminal,\r\n resxNewlineNormalization: options.resxNewlineNormalization,\r\n ignoreMissingResxComments: !options.ignoreMissingResxComments\r\n });\r\n }\r\n);\r\n\r\nexport default loader;\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/utilities/Constants.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE9C,QAAA,qBAAqB,GAAe,UAAU,CAAC;AAC/C,QAAA,2BAA2B,GAAW,cAAc,CAAC;AACrD,QAAA,mCAAmC,GAAuB,kBAAkB,CAAC;AAC7E,QAAA,yCAAyC,GAAW,sBAAsB,CAAC;AAC3E,QAAA,yBAAyB,GACpC,wDAAwD,CAAC;AAE9C,QAAA,yBAAyB,GAAW,yCAAyC,CAAC;AAE9E,QAAA,wBAAwB,GAAQ,GAAG,CAAC;AACpC,QAAA,6BAA6B,GAAQ,GAAG,CAAC;AACzC,QAAA,uBAAuB,GAAQ,GAAG,CAAC;AAEnC,QAAA,uBAAuB,GAAqF,GAAG,iCAAyB,KAAK,qCAA6B,IAAI,CAAC;AAC/K,QAAA,iBAAiB,GAA+E,GAAG,iCAAyB,KAAK,+BAAuB,IAAI,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport const LOCALE_FILENAME_TOKEN: '[locale]' = '[locale]';\nexport const LOCALE_FILENAME_TOKEN_REGEX: RegExp = /\\[locale\\]/gi;\nexport const NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN: '[no-locale-file]' = '[no-locale-file]';\nexport const NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX: RegExp = /\\[no-locale-file\\]/gi;\nexport const STRING_PLACEHOLDER_PREFIX: '_LOCALIZED_STRING_f12dy0i7_n4bo_dqwj_39gf_sasqehjmihz9' =\n '_LOCALIZED_STRING_f12dy0i7_n4bo_dqwj_39gf_sasqehjmihz9';\n\nexport const RESOURCE_FILE_NAME_REGEXP: RegExp = /\\.(resx|resx\\.json|loc\\.json|resjson)$/i;\n\nexport const STRING_PLACEHOLDER_LABEL: 'A' = 'A';\nexport const LOCALE_NAME_PLACEHOLDER_LABEL: 'B' = 'B';\nexport const JSONP_PLACEHOLDER_LABEL: 'C' = 'C';\n\nexport const LOCALE_NAME_PLACEHOLDER: `${typeof STRING_PLACEHOLDER_PREFIX}__${typeof LOCALE_NAME_PLACEHOLDER_LABEL}_0` = `${STRING_PLACEHOLDER_PREFIX}__${LOCALE_NAME_PLACEHOLDER_LABEL}_0`;\nexport const JSONP_PLACEHOLDER: `${typeof STRING_PLACEHOLDER_PREFIX}__${typeof JSONP_PLACEHOLDER_LABEL}_0` = `${STRING_PLACEHOLDER_PREFIX}__${JSONP_PLACEHOLDER_LABEL}_0`;\n"]}
|
1
|
+
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/utilities/Constants.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE9C,QAAA,qBAAqB,GAAe,UAAU,CAAC;AAC/C,QAAA,2BAA2B,GAAW,cAAc,CAAC;AACrD,QAAA,mCAAmC,GAAuB,kBAAkB,CAAC;AAC7E,QAAA,yCAAyC,GAAW,sBAAsB,CAAC;AAC3E,QAAA,yBAAyB,GACpC,wDAAwD,CAAC;AAE9C,QAAA,yBAAyB,GAAW,yCAAyC,CAAC;AAE9E,QAAA,wBAAwB,GAAQ,GAAG,CAAC;AACpC,QAAA,6BAA6B,GAAQ,GAAG,CAAC;AACzC,QAAA,uBAAuB,GAAQ,GAAG,CAAC;AAEnC,QAAA,uBAAuB,GAAqF,GAAG,iCAAyB,KAAK,qCAA6B,IAAI,CAAC;AAC/K,QAAA,iBAAiB,GAA+E,GAAG,iCAAyB,KAAK,+BAAuB,IAAI,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nexport const LOCALE_FILENAME_TOKEN: '[locale]' = '[locale]';\r\nexport const LOCALE_FILENAME_TOKEN_REGEX: RegExp = /\\[locale\\]/gi;\r\nexport const NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN: '[no-locale-file]' = '[no-locale-file]';\r\nexport const NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX: RegExp = /\\[no-locale-file\\]/gi;\r\nexport const STRING_PLACEHOLDER_PREFIX: '_LOCALIZED_STRING_f12dy0i7_n4bo_dqwj_39gf_sasqehjmihz9' =\r\n '_LOCALIZED_STRING_f12dy0i7_n4bo_dqwj_39gf_sasqehjmihz9';\r\n\r\nexport const RESOURCE_FILE_NAME_REGEXP: RegExp = /\\.(resx|resx\\.json|loc\\.json|resjson)$/i;\r\n\r\nexport const STRING_PLACEHOLDER_LABEL: 'A' = 'A';\r\nexport const LOCALE_NAME_PLACEHOLDER_LABEL: 'B' = 'B';\r\nexport const JSONP_PLACEHOLDER_LABEL: 'C' = 'C';\r\n\r\nexport const LOCALE_NAME_PLACEHOLDER: `${typeof STRING_PLACEHOLDER_PREFIX}__${typeof LOCALE_NAME_PLACEHOLDER_LABEL}_0` = `${STRING_PLACEHOLDER_PREFIX}__${LOCALE_NAME_PLACEHOLDER_LABEL}_0`;\r\nexport const JSONP_PLACEHOLDER: `${typeof STRING_PLACEHOLDER_PREFIX}__${typeof JSONP_PLACEHOLDER_LABEL}_0` = `${STRING_PLACEHOLDER_PREFIX}__${JSONP_PLACEHOLDER_LABEL}_0`;\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EntityMarker.js","sourceRoot":"","sources":["../../src/utilities/EntityMarker.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,MAAM,KAAK,GAA6B,IAAI,OAAO,EAAE,CAAC;AAEtD;;GAEG;AACH,SAAgB,UAAU,CAAC,MAAc,EAAE,KAAc;IACvD,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC3B,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,OAAO,CAAC,MAAc;IACpC,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAFD,0BAEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nconst MARKS: WeakMap<object, boolean> = new WeakMap();\n\n/**\n * Marks a webpack entity as containing or not containing localized resources.\n */\nexport function markEntity(entity: object, value: boolean): void {\n MARKS.set(entity, value);\n}\n\n/**\n * Read the cache marker for whether or not the entity contains localized resources.\n */\nexport function getMark(entity: object): boolean | undefined {\n return MARKS.get(entity);\n}\n"]}
|
1
|
+
{"version":3,"file":"EntityMarker.js","sourceRoot":"","sources":["../../src/utilities/EntityMarker.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,MAAM,KAAK,GAA6B,IAAI,OAAO,EAAE,CAAC;AAEtD;;GAEG;AACH,SAAgB,UAAU,CAAC,MAAc,EAAE,KAAc;IACvD,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC3B,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,OAAO,CAAC,MAAc;IACpC,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAFD,0BAEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nconst MARKS: WeakMap<object, boolean> = new WeakMap();\r\n\r\n/**\r\n * Marks a webpack entity as containing or not containing localized resources.\r\n */\r\nexport function markEntity(entity: object, value: boolean): void {\r\n MARKS.set(entity, value);\r\n}\r\n\r\n/**\r\n * Read the cache marker for whether or not the entity contains localized resources.\r\n */\r\nexport function getMark(entity: object): boolean | undefined {\r\n return MARKS.get(entity);\r\n}\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LoaderTerminalProvider.js","sourceRoot":"","sources":["../../src/utilities/LoaderTerminalProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,oEAAgG;AAEhG,MAAa,sBAAsB;IAC1B,MAAM,CAAC,4BAA4B,CAAC,aAAgC;QACzE,OAAO;YACL,aAAa,EAAE,KAAK;YACpB,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,CAAC,IAAY,EAAE,QAAkC,EAAE,EAAE;gBAC1D,QAAQ,QAAQ,EAAE;oBAChB,KAAK,4CAAwB,CAAC,KAAK,CAAC,CAAC;wBACnC,aAAa,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;wBACzC,MAAM;qBACP;oBAED,KAAK,4CAAwB,CAAC,OAAO,CAAC,CAAC;wBACrC,aAAa,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;wBAC3C,MAAM;qBACP;iBACF;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AApBD,wDAoBC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { LoaderContext } from 'webpack';\nimport { type ITerminalProvider, TerminalProviderSeverity } from '@rushstack/node-core-library';\n\nexport class LoaderTerminalProvider {\n public static getTerminalProviderForLoader(loaderContext: LoaderContext<{}>): ITerminalProvider {\n return {\n supportsColor: false,\n eolCharacter: '\\n',\n write: (data: string, severity: TerminalProviderSeverity) => {\n switch (severity) {\n case TerminalProviderSeverity.error: {\n loaderContext.emitError(new Error(data));\n break;\n }\n\n case TerminalProviderSeverity.warning: {\n loaderContext.emitWarning(new Error(data));\n break;\n }\n }\n }\n };\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"LoaderTerminalProvider.js","sourceRoot":"","sources":["../../src/utilities/LoaderTerminalProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,oEAAgG;AAEhG,MAAa,sBAAsB;IAC1B,MAAM,CAAC,4BAA4B,CAAC,aAAgC;QACzE,OAAO;YACL,aAAa,EAAE,KAAK;YACpB,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,CAAC,IAAY,EAAE,QAAkC,EAAE,EAAE;gBAC1D,QAAQ,QAAQ,EAAE;oBAChB,KAAK,4CAAwB,CAAC,KAAK,CAAC,CAAC;wBACnC,aAAa,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;wBACzC,MAAM;qBACP;oBAED,KAAK,4CAAwB,CAAC,OAAO,CAAC,CAAC;wBACrC,aAAa,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;wBAC3C,MAAM;qBACP;iBACF;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AApBD,wDAoBC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { LoaderContext } from 'webpack';\r\nimport { type ITerminalProvider, TerminalProviderSeverity } from '@rushstack/node-core-library';\r\n\r\nexport class LoaderTerminalProvider {\r\n public static getTerminalProviderForLoader(loaderContext: LoaderContext<{}>): ITerminalProvider {\r\n return {\r\n supportsColor: false,\r\n eolCharacter: '\\n',\r\n write: (data: string, severity: TerminalProviderSeverity) => {\r\n switch (severity) {\r\n case TerminalProviderSeverity.error: {\r\n loaderContext.emitError(new Error(data));\r\n break;\r\n }\r\n\r\n case TerminalProviderSeverity.warning: {\r\n loaderContext.emitWarning(new Error(data));\r\n break;\r\n }\r\n }\r\n }\r\n };\r\n }\r\n}\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"webpackInterfaces.js","sourceRoot":"","sources":["../src/webpackInterfaces.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { Chunk, Compilation } from 'webpack';\n\n/**\n * @public\n */\nexport interface ILocalizedWebpackChunk extends Chunk {\n localizedFiles?: { [locale: string]: string };\n}\n\nexport type IAssetPathOptions = Parameters<typeof Compilation.prototype.getPath>[1] & {\n locale?: string;\n};\n"]}
|
1
|
+
{"version":3,"file":"webpackInterfaces.js","sourceRoot":"","sources":["../src/webpackInterfaces.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { Chunk, Compilation } from 'webpack';\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ILocalizedWebpackChunk extends Chunk {\r\n localizedFiles?: { [locale: string]: string };\r\n}\r\n\r\nexport type IAssetPathOptions = Parameters<typeof Compilation.prototype.getPath>[1] & {\r\n locale?: string;\r\n};\r\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rushstack/webpack5-localization-plugin",
|
3
|
-
"version": "0.5.
|
3
|
+
"version": "0.5.10",
|
4
4
|
"description": "This plugin facilitates localization with Webpack.",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"typings": "dist/webpack5-localization-plugin.d.ts",
|
@@ -15,13 +15,13 @@
|
|
15
15
|
"@types/node": "*"
|
16
16
|
},
|
17
17
|
"dependencies": {
|
18
|
-
"@rushstack/localization-utilities": "0.9.
|
18
|
+
"@rushstack/localization-utilities": "0.9.10",
|
19
19
|
"@rushstack/node-core-library": "3.61.0"
|
20
20
|
},
|
21
21
|
"devDependencies": {
|
22
22
|
"memfs": "3.4.3",
|
23
23
|
"webpack": "~5.82.1",
|
24
|
-
"@rushstack/heft": "0.
|
24
|
+
"@rushstack/heft": "0.63.0",
|
25
25
|
"local-node-rig": "1.0.0"
|
26
26
|
},
|
27
27
|
"peerDependenciesMeta": {
|