@rushstack/webpack5-localization-plugin 0.1.19 → 0.1.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.29.4"
8
+ "packageVersion": "7.29.5"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/webpack5-localization-plugin",
3
- "version": "0.1.19",
3
+ "version": "0.1.22",
4
4
  "description": "This plugin facilitates localization with Webpack.",
5
5
  "main": "lib/index.js",
6
6
  "typings": "dist/webpack5-localization-plugin.d.ts",
@@ -14,14 +14,14 @@
14
14
  "webpack": "^5.68.0"
15
15
  },
16
16
  "dependencies": {
17
- "@rushstack/localization-utilities": "0.8.17",
17
+ "@rushstack/localization-utilities": "0.8.20",
18
18
  "@rushstack/node-core-library": "3.51.1",
19
19
  "@types/node": "12.20.24"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@rushstack/eslint-config": "3.0.0",
23
- "@rushstack/heft": "0.47.5",
24
- "@rushstack/heft-node-rig": "1.10.5",
23
+ "@rushstack/heft": "0.47.6",
24
+ "@rushstack/heft-node-rig": "1.10.8",
25
25
  "@types/heft-jest": "1.0.1",
26
26
  "memfs": "3.4.3",
27
27
  "webpack": "~5.68.0"
@@ -30,6 +30,5 @@
30
30
  "build": "heft build --clean",
31
31
  "_phase:build": "heft build --clean",
32
32
  "_phase:test": "heft test --no-build"
33
- },
34
- "readme": "# @rushstack/webpack5-localization-plugin\n\n## Installation\n\n`npm install @rushstack/webpack5-localization-plugin --save-dev`\n\n## Overview\n\nThis Webpack plugin produces bundles that have multiple locales' variants of strings embedded. It also\nhas out-of-box support for RESX files in addition to JSON strings files (with the extensions `.loc.json` or `.resjson`).\n\nThe loaders can also be chained with other loaders that convert the content to one of the known formats.\n\n# Plugin\n\nTo use the plugin, add it to the `plugins` array of your Webpack config, and specify one or more loaders. For example:\n\n```JavaScript\nimport { LocalizationPlugin } from '@rushstack/webpack5-localization-plugin';\n\n{\n plugins: [\n new LocalizationPlugin( /* options */ )\n ],\n module: {\n rules: [{\n test: /\\.resjson$/,\n use: {\n // All loaders are available in `@rushstack/webpack5-localization-plugin/lib/loaders/`\n // Loaders for specific formats: `resjson-loader`, `locjson-loader`, `resx-loader`\n // Loader that switches on file extension: `loc-loader`\n // Loader that switches on file extension and skips localization: `default-locale-loader`\n loader: require.resolve('@rushstack/webpack5-localization-plugin/lib/loaders/resjson-loader')\n },\n // Can be one of `javascript/esm`, `javascript/dynamic`, or `json`\n // `javascript/esm` will produce the smallest bundle sizes, while `json` will produce faster code for large string tables\n type: 'javascript/esm',\n sideEffects: false\n }]\n }\n}\n```\n\n***A note about the dev server:*** When Webpack is being run by the Webpack dev server, this plugin pipes\nthe strings in the loc files in the source (the `.loc.json` and the `.resx` files) to the output without\nany translations.\n\n## Options\n\n### `localizedData = { }`\n\n#### `localizedData.defaultLocale = { }`\n\nThis option has a required property (`localeName`), to specify the name of the locale used in the\n`.resx` and `.loc.json` files in the source.\n\n##### `localizedData.defaultLocale.fillMissingTranslationStrings = true | false`\n\nIf this option is set to `true`, strings that are missing from `localizedData.translatedStrings` will be\nprovided by the default locale (the strings in the `.resx` and `.loc.json` files in the source). If\nthis option is unset or set to `false`, an error will be emitted if a string is missing from\n`localizedData.translatedStrings`.\n\n#### `localizedData.translatedStrings = { }`\n\nThis option is used to specify the localization data to be used in the build. This object has the following\nstructure:\n\n- Locale name\n - Compilation context-relative or absolute localization file path\n - Translated strings\n\nFor example:\n\n```JavaScript\ntranslatedStrings: {\n \"en-us\": {\n \"./src/strings1.loc.json\": {\n \"string1\": \"the first string\"\n }\n },\n \"es-es\": {\n \"./src/strings1.loc.json\": {\n \"string1\": \"la primera cadena\"\n }\n }\n}\n```\n\nAlternatively, instead of directly specifying the translations, a path to a translated resource file can be\nspecified. For example:\n\n```JavaScript\ntranslatedStrings: {\n \"en-us\": {\n \"./src/strings1.loc.json\": \"./localization/en-us/strings1.loc.json\"\n },\n \"es-es\": {\n \"./src/strings1.loc.json\": \"./localization/es-es/strings1.loc.json\"\n }\n}\n```\n\n#### `localizedData.resolveMissingTranslatedStrings = (locales: string[], filePath: string, context: LoaderContext<{}>) => { ... }`\n\nThis optional option can be used to resolve translated data that is missing from data that is provided\nin the `localizedData.translatedStrings` option. Set this option with a function expecting two parameters:\nthe first, an array of locale names, and second, a fully-qualified path to the localized file in source. The\nfunction should synchronously or asynchronously (as a promise) return an object (or map) with locale names as keys and localized\ndata as values. The localized data value should be one of:\n\n- a string: The absolute path to the translated data in `.resx`, `.loc.json`, or `.resjson` format\n- an object: An object containing the translated data\n- a map: A map containing the translated data\n\nNote that these values are the same as the values that can be specified for translations for a localized\nresource in `localizedData.translatedStrings`.\n\nIf the function returns data that is missing locales or individual strings, the plugin will fall back to the\ndefault locale if `localizedData.defaultLocale.fillMissingTranslationStrings` is set to `true`. If\n`localizedData.defaultLocale.fillMissingTranslationStrings` is set to `false`, an error will result.\n\n#### `localizedData.passthroughLocale = { }`\n\nThis option is used to specify how and if a passthrough locale should be generated. A passthrough locale\nis a generated locale in which each string's value is its name. This is useful for debugging and for identifying\ncases where a locale is missing.\n\nThis option takes two optional properties:\n\n##### `localizedData.passthroughLocale.usePassthroughLocale = true | false`\n\nIf `passthroughLocale.usePassthroughLocale` is set to `true`, a passthrough locale will be included in the output.\nBy default, the passthrough locale's name is \"passthrough.\"\n\n##### `localizedData.passthroughLocale.passthroughLocaleName = '...'`\n\nIf `passthroughLocale.usePassthroughLocale` is set to `true`, the \"passthrough\" locale name can be overridden\nby setting a value on `passthroughLocale.passthroughLocaleName`.\n\n#### `localizedData.pseudolocales = { }`\n\nThis option allows pseudolocales to be generated from the strings in the default locale. This option takes\nan option with pseudolocales as keys and options for the\n[pseudolocale package](https://www.npmjs.com/package/pseudolocale) as values.\n\n### `noStringsLocaleName = '...'`\n\nThe value to replace the `[locale]` token with for chunks without localized strings. Defaults to \"none\"\n\n### `runtimeLocaleExpression = '...'`\n\nA chunk of raw ECMAScript to inject into the webpack runtime to resolve the current locale at execution time. Allows\nmultiple locales to share the same runtime chunk if it does not directly contain localized strings.\n\n### `localizationStats = { }`\n\n#### `localizationStats.dropPath = '...'`\n\nThis option is used to designate a path at which a JSON file describing the localized assets produced should be\nwritten. If this property is omitted, the stats file won't be written.\n\nThe file has the following format:\n\n```JSON\n{\n \"entrypoints\": {\n \"<BUNDLE NAME>\": {\n \"localizedAssets\": {\n \"<LOCALE NAME>\": \"<ASSET NAME>\",\n \"<LOCALE NAME>\": \"<ASSET NAME>\"\n }\n },\n \"<BUNDLE NAME>\": {\n \"localizedAssets\": {\n \"<LOCALE NAME>\": \"<ASSET NAME>\",\n \"<LOCALE NAME>\": \"<ASSET NAME>\"\n }\n }\n },\n \"namedChunkGroups\": {\n \"<CHUNK NAME>\": {\n \"localizedAssets\": {\n \"<LOCALE NAME>\": \"<ASSET NAME>\",\n \"<LOCALE NAME>\": \"<ASSET NAME>\"\n }\n },\n \"<CHUNK NAME>\": {\n \"localizedAssets\": {\n \"<LOCALE NAME>\": \"<ASSET NAME>\",\n \"<LOCALE NAME>\": \"<ASSET NAME>\"\n }\n }\n }\n}\n\n```\n\n#### `localizationStats.callback = (stats) => { ... }`\n\nThis option is used to specify a callback to be called with the stats data that would be dropped at\n[`localizationStats.dropPath`](#localizationStats.DropPath--) after compilation completes.\n\n## Links\n\n- [CHANGELOG.md](https://github.com/microsoft/rushstack/blob/main/webpack/localization-plugin/CHANGELOG.md) - Find\n out what's new in the latest version\n\n`@rushstack/webpack5-localization-plugin` is part of the [Rush Stack](https://rushstack.io/) family of projects.\n"
33
+ }
35
34
  }