@rushstack/webpack4-localization-plugin 0.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -0
- package/README.md +292 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/webpack4-localization-plugin.d.ts +324 -0
- package/lib/AssetProcessor.d.ts +36 -0
- package/lib/AssetProcessor.d.ts.map +1 -0
- package/lib/AssetProcessor.js +306 -0
- package/lib/AssetProcessor.js.map +1 -0
- package/lib/LocalizationPlugin.d.ts +77 -0
- package/lib/LocalizationPlugin.d.ts.map +1 -0
- package/lib/LocalizationPlugin.js +597 -0
- package/lib/LocalizationPlugin.js.map +1 -0
- package/lib/WebpackConfigurationUpdater.d.ts +22 -0
- package/lib/WebpackConfigurationUpdater.d.ts.map +1 -0
- package/lib/WebpackConfigurationUpdater.js +136 -0
- package/lib/WebpackConfigurationUpdater.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces.d.ts +219 -0
- package/lib/interfaces.d.ts.map +1 -0
- package/lib/interfaces.js +5 -0
- package/lib/interfaces.js.map +1 -0
- package/lib/loaders/InPlaceLocFileLoader.d.ts +4 -0
- package/lib/loaders/InPlaceLocFileLoader.d.ts.map +1 -0
- package/lib/loaders/InPlaceLocFileLoader.js +17 -0
- package/lib/loaders/InPlaceLocFileLoader.js.map +1 -0
- package/lib/loaders/LoaderFactory.d.ts +13 -0
- package/lib/loaders/LoaderFactory.d.ts.map +1 -0
- package/lib/loaders/LoaderFactory.js +41 -0
- package/lib/loaders/LoaderFactory.js.map +1 -0
- package/lib/loaders/LocLoader.d.ts +9 -0
- package/lib/loaders/LocLoader.d.ts.map +1 -0
- package/lib/loaders/LocLoader.js +36 -0
- package/lib/loaders/LocLoader.js.map +1 -0
- package/lib/utilities/Constants.d.ts +14 -0
- package/lib/utilities/Constants.d.ts.map +1 -0
- package/lib/utilities/Constants.js +44 -0
- package/lib/utilities/Constants.js.map +1 -0
- package/lib/utilities/EntityMarker.d.ts +13 -0
- package/lib/utilities/EntityMarker.d.ts.map +1 -0
- package/lib/utilities/EntityMarker.js +19 -0
- package/lib/utilities/EntityMarker.js.map +1 -0
- package/lib/utilities/LoaderTerminalProvider.d.ts +6 -0
- package/lib/utilities/LoaderTerminalProvider.d.ts.map +1 -0
- package/lib/utilities/LoaderTerminalProvider.js +28 -0
- package/lib/utilities/LoaderTerminalProvider.js.map +1 -0
- package/lib/webpackInterfaces.d.ts +10 -0
- package/lib/webpackInterfaces.d.ts.map +1 -0
- package/lib/webpackInterfaces.js +5 -0
- package/lib/webpackInterfaces.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationPlugin.js","sourceRoot":"","sources":["../src/LocalizationPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,oEAA4F;AAC5F,iDAAmC;AACnC,2CAA6B;AAE7B,8EAK2C;AAE3C,qDAAkD;AAClD,+EAGuC;AAUvC,2DAAwD;AACxD,qDAAkG;AAuDlG,MAAM,WAAW,GAAW,cAAc,CAAC;AAE3C;;;;GAIG;AACH,MAAa,kBAAkB;IAoC7B,YAAmB,OAAmC;;QAnCtD;;WAEG;QACI,eAAU,GAAoC,IAAI,GAAG,EAA8B,CAAC;QAKnF,8BAAyB,GAAW,CAAC,CAAC;QACtC,0BAAqB,GAAyC,IAAI,GAAG,EAG1E,CAAC;QACI,aAAQ,GAAgB,IAAI,GAAG,EAAU,CAAC;QAK1C,sBAAiB,GAAyC,IAAI,GAAG,EAGtE,CAAC;QAIJ;;;;WAIG;QACK,8BAAyB,GAAkD,IAAI,GAAG,EAGvF,CAAC;QAGF,IAAI,OAAO,CAAC,aAAa,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC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AAC,qBAAqB,IAAI,KAAK,CAAC,UAAU,EAAE,EAAE;gBAChD,KAAK,MAAM,UAAU,IAAI,KAAK,CAAC,iBAAiB,EAAE,EAAE;oBAClD,IAAI,IAAI,CAAC,yBAAyB,CAAC,UAAU,CAAC,EAAE;wBAC9C,qBAAqB,GAAG,IAAI,CAAC;wBAC7B,MAAM;qBACP;iBACF;aACF;YAED,2BAAY,CAAC,UAAU,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;SACvD;QAED,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAEO,iCAAiC,CAAC,OAA0B;QAClE,MAAM,WAAW,GAAoB,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAChE,WAAW,CAAC,UAAU,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC;SAC9C;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AA5vBD,gDA4vBC","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 { JsonFile, FileSystem, ITerminal, NewlineKind } from '@rushstack/node-core-library';\nimport * as Webpack from 'webpack';\nimport * as path from 'path';\nimport * as Tapable from 'tapable';\nimport {\n getPseudolocalizer,\n ILocalizationFile,\n parseLocFile,\n TypingsGenerator\n} from '@rushstack/localization-utilities';\n\nimport { Constants } from './utilities/Constants';\nimport {\n IWebpackConfigurationUpdaterOptions,\n WebpackConfigurationUpdater\n} from './WebpackConfigurationUpdater';\nimport {\n ILocalizationPluginOptions,\n ILocalizationStats,\n ILocaleFileData,\n ILocaleElementMap,\n ILocalizedStrings,\n IResolvedMissingTranslations\n} from './interfaces';\nimport { ILocalizedWebpackChunk } from './webpackInterfaces';\nimport { EntityMarker } from './utilities/EntityMarker';\nimport { IAsset, IProcessAssetResult, AssetProcessor, PLACEHOLDER_REGEX } from './AssetProcessor';\n\n/**\n * @internal\n */\nexport interface IStringPlaceholder {\n value: string;\n suffix: string;\n}\n\n/**\n * @internal\n */\nexport interface IAddDefaultLocFileResult {\n /**\n * A list of paths to translation files that were loaded\n */\n additionalLoadedFilePaths: string[];\n\n errors: Error[];\n}\n\ninterface IExtendedMainTemplate {\n hooks: {\n assetPath: Tapable.SyncHook<string, IAssetPathOptions>;\n };\n}\n\ninterface IExtendedConfiguration extends Webpack.compilation.Compilation {\n options: Webpack.Configuration;\n}\n\ninterface IExtendedChunkGroup extends Webpack.compilation.ChunkGroup {\n getChildren(): Webpack.compilation.Chunk[];\n}\n\ninterface IExtendedChunk extends Webpack.compilation.Chunk {\n filenameTemplate: string;\n}\n\ninterface IAssetPathOptions {\n chunk: Webpack.compilation.Chunk;\n contentHashType: string;\n filename: string;\n}\n\n/**\n * @internal\n */\nexport interface IStringSerialNumberData {\n values: ILocaleElementMap;\n locFilePath: string;\n stringName: string;\n}\n\nconst PLUGIN_NAME: string = 'localization';\n\n/**\n * This plugin facilitates localization in webpack.\n *\n * @public\n */\nexport class LocalizationPlugin implements Webpack.Plugin {\n /**\n * @internal\n */\n public stringKeys: Map<string, IStringPlaceholder> = new Map<string, IStringPlaceholder>();\n\n private _options: ILocalizationPluginOptions;\n private _resolvedTranslatedStringsFromOptions!: ILocalizedStrings;\n private _globsToIgnore: string[] | undefined;\n private _stringPlaceholderCounter: number = 0;\n private _stringPlaceholderMap: Map<string, IStringSerialNumberData> = new Map<\n string,\n IStringSerialNumberData\n >();\n private _locales: Set<string> = new Set<string>();\n private _passthroughLocaleName!: string;\n private _defaultLocale!: string;\n private _noStringsLocaleName!: string;\n private _fillMissingTranslationStrings!: boolean;\n private _pseudolocalizers: Map<string, (str: string) => string> = new Map<\n string,\n (str: string) => string\n >();\n private _resxNewlineNormalization: NewlineKind | undefined;\n private _ignoreMissingResxComments: boolean | undefined;\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 string,\n Map<string, Map<string, string>>\n >();\n\n public constructor(options: ILocalizationPluginOptions) {\n if (options.filesToIgnore) {\n throw new Error('The filesToIgnore option is no longer supported. Please use globsToIgnore instead.');\n }\n\n if (options.typingsOptions?.ignoreString) {\n throw new Error(\n 'The typingsOptions.ignoreString option is no longer supported. Please use the ignoreString ' +\n 'option directly on the constructor options object instead.'\n );\n }\n\n this._options = options;\n }\n\n public apply(compiler: Webpack.Compiler): void {\n const isWebpack4: boolean = !!compiler.hooks;\n\n if (!isWebpack4) {\n throw new Error(`The ${LocalizationPlugin.name} plugin requires Webpack 4`);\n }\n\n if (this._options.typingsOptions && compiler.context) {\n if (\n this._options.typingsOptions.generatedTsFolder &&\n !path.isAbsolute(this._options.typingsOptions.generatedTsFolder)\n ) {\n this._options.typingsOptions.generatedTsFolder = path.resolve(\n compiler.context,\n this._options.typingsOptions.generatedTsFolder\n );\n }\n\n if (\n this._options.typingsOptions.sourceRoot &&\n !path.isAbsolute(this._options.typingsOptions.sourceRoot)\n ) {\n this._options.typingsOptions.sourceRoot = path.resolve(\n compiler.context,\n this._options.typingsOptions.sourceRoot\n );\n }\n }\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.options, isWebpackDevServer);\n\n let typingsPreprocessor: TypingsGenerator | undefined;\n if (this._options.typingsOptions) {\n typingsPreprocessor = new TypingsGenerator({\n srcFolder: this._options.typingsOptions.sourceRoot || compiler.context,\n generatedTsFolder: this._options.typingsOptions.generatedTsFolder,\n exportAsDefault: this._options.typingsOptions.exportAsDefault,\n globsToIgnore: this._options.globsToIgnore,\n ignoreString: this._options.ignoreString,\n processComment: this._options.typingsOptions.processComment\n });\n } else {\n typingsPreprocessor = undefined;\n }\n\n const webpackConfigurationUpdaterOptions: IWebpackConfigurationUpdaterOptions = {\n pluginInstance: this,\n configuration: compiler.options,\n globsToIgnore: this._globsToIgnore,\n localeNameOrPlaceholder: Constants.LOCALE_NAME_PLACEHOLDER,\n resxNewlineNormalization: this._resxNewlineNormalization,\n ignoreMissingResxComments: this._ignoreMissingResxComments,\n ignoreString: this._options.ignoreString\n };\n\n if (errors.length > 0 || warnings.length > 0) {\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation: Webpack.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 WebpackConfigurationUpdater.amendWebpackConfigurationForInPlaceLocFiles(\n webpackConfigurationUpdaterOptions\n );\n return;\n }\n }\n\n if (isWebpackDevServer) {\n if (typingsPreprocessor) {\n compiler.hooks.afterEnvironment.tap(PLUGIN_NAME, () => typingsPreprocessor!.runWatcherAsync());\n\n if (!compiler.options.plugins) {\n compiler.options.plugins = [];\n }\n\n compiler.options.plugins.push(\n new Webpack.WatchIgnorePlugin([this._options.typingsOptions!.generatedTsFolder])\n );\n }\n\n WebpackConfigurationUpdater.amendWebpackConfigurationForInPlaceLocFiles(\n webpackConfigurationUpdaterOptions\n );\n } else {\n if (typingsPreprocessor) {\n compiler.hooks.beforeRun.tapPromise(\n PLUGIN_NAME,\n async () => await typingsPreprocessor!.generateTypingsAsync()\n );\n }\n\n WebpackConfigurationUpdater.amendWebpackConfigurationForMultiLocale(webpackConfigurationUpdaterOptions);\n\n if (errors.length === 0) {\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (untypedCompilation: Webpack.compilation.Compilation) => {\n const compilation: IExtendedConfiguration = untypedCompilation as IExtendedConfiguration;\n (compilation.mainTemplate as unknown as IExtendedMainTemplate).hooks.assetPath.tap(\n PLUGIN_NAME,\n (assetPath: string, options: IAssetPathOptions) => {\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 as string).match(/^\\\" \\+/)) {\n return assetPath.replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n `\" + ${Constants.JSONP_PLACEHOLDER} + \"`\n );\n } else {\n return assetPath.replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n Constants.LOCALE_NAME_PLACEHOLDER\n );\n }\n } else if (assetPath.match(Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX)) {\n // Replace the placeholder with the [locale] token for sourcemaps\n const deLocalizedFilename: string = options.filename.replace(\n PLACEHOLDER_REGEX,\n Constants.LOCALE_FILENAME_TOKEN\n );\n return assetPath.replace(\n Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX,\n deLocalizedFilename\n );\n } else {\n return assetPath;\n }\n }\n );\n\n compilation.hooks.optimizeChunks.tap(\n PLUGIN_NAME,\n (\n untypedChunks: Webpack.compilation.Chunk[],\n untypedChunkGroups: Webpack.compilation.ChunkGroup[]\n ) => {\n const chunks: IExtendedChunk[] = untypedChunks as IExtendedChunk[];\n const chunkGroups: IExtendedChunkGroup[] = untypedChunkGroups as IExtendedChunkGroup[];\n\n let chunksHaveAnyChildren: boolean = false;\n for (const chunkGroup of chunkGroups) {\n const children: Webpack.compilation.Chunk[] = chunkGroup.getChildren();\n if (children.length > 0) {\n chunksHaveAnyChildren = true;\n break;\n }\n }\n\n if (\n chunksHaveAnyChildren &&\n (!compilation.options.output ||\n !compilation.options.output.chunkFilename ||\n compilation.options.output.chunkFilename.indexOf(Constants.LOCALE_FILENAME_TOKEN) === -1)\n ) {\n compilation.errors.push(\n new Error(\n 'The configuration.output.chunkFilename property must be provided and must include ' +\n `the ${Constants.LOCALE_FILENAME_TOKEN} placeholder`\n )\n );\n\n return;\n }\n\n for (const chunk of chunks) {\n // See if the chunk contains any localized modules or loads any localized chunks\n const localizedChunk: boolean = this._chunkHasLocalizedModules(chunk);\n\n // Change the chunk's name to include either the locale name or the locale name for chunks without strings\n const replacementValue: string = localizedChunk\n ? Constants.LOCALE_NAME_PLACEHOLDER\n : this._noStringsLocaleName;\n if (chunk.hasRuntime()) {\n chunk.filenameTemplate = (compilation.options.output!.filename as string).replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n replacementValue\n );\n } else {\n chunk.filenameTemplate = compilation.options.output!.chunkFilename!.replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n replacementValue\n );\n }\n }\n }\n );\n }\n );\n\n compiler.hooks.emit.tap(PLUGIN_NAME, (compilation: Webpack.compilation.Compilation) => {\n const localizationStats: ILocalizationStats = {\n entrypoints: {},\n namedChunkGroups: {}\n };\n\n const alreadyProcessedAssets: Set<string> = new Set<string>();\n const hotUpdateRegex: RegExp = /\\.hot-update\\.js$/;\n\n for (const untypedChunk of compilation.chunks) {\n const chunk: ILocalizedWebpackChunk = untypedChunk;\n const chunkFilesSet: Set<string> = new Set(chunk.files);\n function processChunkJsFile(callback: (chunkFilename: string) => void): void {\n let alreadyProcessedAFileInThisChunk: boolean = false;\n for (const chunkFilename of chunk.files) {\n if (\n chunkFilename.endsWith('.js') && // Ensure this is a JS file\n !hotUpdateRegex.test(chunkFilename) && // Ensure this is not a webpack hot update\n !alreadyProcessedAssets.has(chunkFilename) // Ensure this isn't a vendor chunk we've already processed\n ) {\n if (alreadyProcessedAFileInThisChunk) {\n throw new Error(\n `Found more than one JS file in chunk \"${chunk.name}\". This is not expected.`\n );\n }\n\n alreadyProcessedAFileInThisChunk = true;\n alreadyProcessedAssets.add(chunkFilename);\n callback(chunkFilename);\n }\n }\n }\n\n if (this._chunkHasLocalizedModules(chunk)) {\n processChunkJsFile((chunkFilename) => {\n if (chunkFilename.indexOf(Constants.LOCALE_NAME_PLACEHOLDER) === -1) {\n throw new Error(\n `Asset ${chunkFilename} is expected to be localized, but is missing a locale placeholder`\n );\n }\n\n const asset: IAsset = compilation.assets[chunkFilename];\n\n const resultingAssets: Map<string, IProcessAssetResult> =\n AssetProcessor.processLocalizedAsset({\n plugin: this,\n compilation,\n assetName: chunkFilename,\n asset,\n chunk,\n chunkHasLocalizedModules: this._chunkHasLocalizedModules.bind(this),\n locales: this._locales,\n noStringsLocaleName: this._noStringsLocaleName,\n fillMissingTranslationStrings: this._fillMissingTranslationStrings,\n defaultLocale: this._defaultLocale\n });\n\n // Delete the existing asset because it's been renamed\n delete compilation.assets[chunkFilename];\n chunkFilesSet.delete(chunkFilename);\n\n const localizedChunkAssets: ILocaleElementMap = {};\n for (const [locale, newAsset] of resultingAssets) {\n compilation.assets[newAsset.filename] = newAsset.asset;\n localizedChunkAssets[locale] = newAsset.filename;\n chunkFilesSet.add(newAsset.filename);\n }\n\n if (chunk.hasRuntime()) {\n // This is an entrypoint\n localizationStats.entrypoints[chunk.name] = {\n localizedAssets: localizedChunkAssets\n };\n } else {\n // This is a secondary chunk\n if (chunk.name) {\n localizationStats.namedChunkGroups[chunk.name] = {\n localizedAssets: localizedChunkAssets\n };\n }\n }\n\n chunk.localizedFiles = localizedChunkAssets;\n });\n } else {\n processChunkJsFile((chunkFilename) => {\n const asset: IAsset = compilation.assets[chunkFilename];\n\n const resultingAsset: IProcessAssetResult = AssetProcessor.processNonLocalizedAsset({\n plugin: this,\n compilation,\n assetName: chunkFilename,\n asset,\n chunk,\n noStringsLocaleName: this._noStringsLocaleName,\n chunkHasLocalizedModules: this._chunkHasLocalizedModules.bind(this)\n });\n\n // Delete the existing asset because it's been renamed\n delete compilation.assets[chunkFilename];\n chunkFilesSet.delete(chunkFilename);\n\n compilation.assets[resultingAsset.filename] = resultingAsset.asset;\n chunkFilesSet.add(resultingAsset.filename);\n });\n }\n\n chunk.files = Array.from(chunkFilesSet);\n }\n\n if (this._options.localizationStats) {\n if (this._options.localizationStats.dropPath) {\n const resolvedLocalizationStatsDropPath: string = path.resolve(\n compiler.outputPath,\n this._options.localizationStats.dropPath\n );\n JsonFile.save(localizationStats, resolvedLocalizationStatsDropPath, {\n ensureFolderExists: true\n });\n }\n\n if (this._options.localizationStats.callback) {\n try {\n this._options.localizationStats.callback(localizationStats);\n } catch (e) {\n /* swallow errors from the callback */\n }\n }\n }\n });\n }\n }\n }\n\n /**\n * @internal\n *\n * @returns\n */\n public addDefaultLocFile(\n terminal: ITerminal,\n localizedResourcePath: string,\n localizedResourceData: ILocalizationFile\n ): IAddDefaultLocFileResult {\n const additionalLoadedFilePaths: string[] = [];\n const errors: Error[] = [];\n\n const locFileData: ILocaleFileData = this._convertLocalizationFileToLocData(localizedResourceData);\n this._addLocFile(this._defaultLocale, localizedResourcePath, locFileData);\n\n const normalizeLocalizedData: (localizedData: ILocaleFileData | string) => ILocaleFileData = (\n localizedData\n ) => {\n if (typeof localizedData === 'string') {\n additionalLoadedFilePaths.push(localizedData);\n const localizationFile: ILocalizationFile = parseLocFile({\n filePath: localizedData,\n content: FileSystem.readFile(localizedData),\n terminal: terminal,\n resxNewlineNormalization: this._resxNewlineNormalization,\n ignoreMissingResxComments: this._ignoreMissingResxComments\n });\n\n return this._convertLocalizationFileToLocData(localizationFile);\n } else {\n return localizedData;\n }\n };\n\n const missingLocales: string[] = [];\n for (const [translatedLocaleName, translatedStrings] of Object.entries(\n this._resolvedTranslatedStringsFromOptions\n )) {\n const translatedLocFileFromOptions: ILocaleFileData | string | undefined =\n translatedStrings[localizedResourcePath];\n if (!translatedLocFileFromOptions) {\n missingLocales.push(translatedLocaleName);\n } else {\n const translatedLocFileData: ILocaleFileData = normalizeLocalizedData(translatedLocFileFromOptions);\n this._addLocFile(translatedLocaleName, localizedResourcePath, translatedLocFileData);\n }\n }\n\n if (missingLocales.length > 0 && this._options.localizedData.resolveMissingTranslatedStrings) {\n let resolvedTranslatedData: IResolvedMissingTranslations | undefined = undefined;\n try {\n resolvedTranslatedData = this._options.localizedData.resolveMissingTranslatedStrings(\n missingLocales,\n localizedResourcePath\n );\n } catch (e) {\n errors.push(e as Error);\n }\n\n if (resolvedTranslatedData) {\n for (const [resolvedLocaleName, resolvedLocaleData] of Object.entries(resolvedTranslatedData)) {\n if (resolvedLocaleData) {\n const translatedLocFileData: ILocaleFileData = normalizeLocalizedData(resolvedLocaleData);\n this._addLocFile(resolvedLocaleName, localizedResourcePath, translatedLocFileData);\n }\n }\n }\n }\n\n this._pseudolocalizers.forEach((pseudolocalizer: (str: string) => string, pseudolocaleName: string) => {\n const pseudolocFileData: ILocaleFileData = {};\n\n for (const [stringName, stringValue] of Object.entries(locFileData)) {\n pseudolocFileData[stringName] = pseudolocalizer(stringValue);\n }\n\n this._addLocFile(pseudolocaleName, localizedResourcePath, pseudolocFileData);\n });\n\n return { additionalLoadedFilePaths, errors };\n }\n\n /**\n * @internal\n */\n public getDataForSerialNumber(serialNumber: string): IStringSerialNumberData | undefined {\n return this._stringPlaceholderMap.get(serialNumber);\n }\n\n private _addLocFile(\n localeName: string,\n localizedFilePath: string,\n localizedFileData: ILocaleFileData\n ): void {\n const filesMap: Map<string, Map<string, string>> = this._resolvedLocalizedStrings.get(localeName)!;\n\n const stringsMap: Map<string, string> = new Map<string, string>();\n filesMap.set(localizedFilePath, stringsMap);\n\n for (const [stringName, stringValue] of Object.entries(localizedFileData)) {\n const stringKey: string = `${localizedFilePath}?${stringName}`;\n if (!this.stringKeys.has(stringKey)) {\n const placeholder: IStringPlaceholder = this._getPlaceholderString();\n this.stringKeys.set(stringKey, placeholder);\n }\n\n const placeholder: IStringPlaceholder = this.stringKeys.get(stringKey)!;\n if (!this._stringPlaceholderMap.has(placeholder.suffix)) {\n this._stringPlaceholderMap.set(placeholder.suffix, {\n values: {\n [this._passthroughLocaleName]: stringName\n },\n locFilePath: localizedFilePath,\n stringName: stringName\n });\n }\n\n this._stringPlaceholderMap.get(placeholder.suffix)!.values[localeName] = stringValue;\n\n stringsMap.set(stringName, stringValue);\n }\n }\n\n private _initializeAndValidateOptions(\n configuration: Webpack.Configuration,\n isWebpackDevServer: boolean\n ): { errors: Error[]; warnings: Error[] } {\n const errors: Error[] = [];\n const warnings: Error[] = [];\n\n function ensureValidLocaleName(localeName: string): boolean {\n const LOCALE_NAME_REGEX: RegExp = /[a-z-]/i;\n if (!localeName.match(LOCALE_NAME_REGEX)) {\n errors.push(\n new Error(`Invalid locale name: ${localeName}. Locale names may only contain letters and hyphens.`)\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 Error(\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 // eslint-disable-next-line no-lone-blocks\n {\n this._globsToIgnore = this._options.globsToIgnore;\n }\n // END misc options\n\n // START options.localizedData\n if (this._options.localizedData) {\n this._ignoreMissingResxComments = this._options.localizedData.ignoreMissingResxComments;\n\n // START options.localizedData.passthroughLocale\n if (this._options.localizedData.passthroughLocale) {\n const { usePassthroughLocale, passthroughLocaleName = 'passthrough' } =\n this._options.localizedData.passthroughLocale;\n if (usePassthroughLocale) {\n this._passthroughLocaleName = passthroughLocaleName;\n this._locales.add(passthroughLocaleName);\n }\n }\n // END options.localizedData.passthroughLocale\n\n // START options.localizedData.translatedStrings\n const { translatedStrings } = this._options.localizedData;\n this._resolvedTranslatedStringsFromOptions = {};\n if (translatedStrings) {\n for (const [localeName, locale] of Object.entries(translatedStrings)) {\n if (this._locales.has(localeName)) {\n errors.push(\n Error(\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._locales.add(localeName);\n this._resolvedLocalizedStrings.set(localeName, new Map<string, Map<string, string>>());\n this._resolvedTranslatedStringsFromOptions[localeName] = {};\n\n const locFilePathsInLocale: Set<string> = new Set<string>();\n\n for (const [locFilePath, locFileDataFromOptions] of Object.entries(locale)) {\n if (locale.hasOwnProperty(locFilePath)) {\n const normalizedLocFilePath: string = path.resolve(configuration.context!, locFilePath);\n\n if (locFilePathsInLocale.has(normalizedLocFilePath)) {\n errors.push(\n new Error(\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 locFilePathsInLocale.add(normalizedLocFilePath);\n\n const normalizedLocFileDataFromOptions: string | ILocaleFileData =\n typeof locFileDataFromOptions === 'string'\n ? path.resolve(configuration.context!, locFileDataFromOptions)\n : locFileDataFromOptions;\n\n this._resolvedTranslatedStringsFromOptions[localeName][normalizedLocFilePath] =\n normalizedLocFileDataFromOptions;\n }\n }\n }\n }\n // END options.localizedData.translatedStrings\n\n // START options.localizedData.defaultLocale\n if (this._options.localizedData.defaultLocale) {\n const { localeName, fillMissingTranslationStrings } = this._options.localizedData.defaultLocale;\n if (this._options.localizedData.defaultLocale.localeName) {\n if (this._locales.has(localeName)) {\n errors.push(new Error('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._locales.add(localeName);\n this._resolvedLocalizedStrings.set(localeName, new Map<string, Map<string, string>>());\n this._defaultLocale = localeName;\n this._fillMissingTranslationStrings = !!fillMissingTranslationStrings;\n } else {\n errors.push(new Error('Missing default locale name'));\n return { errors, warnings };\n }\n } else {\n errors.push(new Error('Missing default locale options.'));\n return { errors, warnings };\n }\n // END options.localizedData.defaultLocale\n\n // START options.localizedData.pseudoLocales\n if (this._options.localizedData.pseudolocales) {\n for (const [pseudolocaleName, pseudoLocaleOpts] of Object.entries(\n this._options.localizedData.pseudolocales\n )) {\n if (this._defaultLocale === pseudolocaleName) {\n errors.push(\n new Error(`A pseudolocale (${pseudolocaleName}) name is also the default locale name.`)\n );\n return { errors, warnings };\n }\n\n if (this._locales.has(pseudolocaleName)) {\n errors.push(\n new Error(\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._locales.add(pseudolocaleName);\n this._resolvedLocalizedStrings.set(pseudolocaleName, new Map<string, Map<string, string>>());\n }\n }\n // END options.localizedData.pseudoLocales\n\n // START options.localizedData.normalizeResxNewlines\n if (this._options.localizedData.normalizeResxNewlines) {\n switch (this._options.localizedData.normalizeResxNewlines) {\n case 'crlf': {\n this._resxNewlineNormalization = NewlineKind.CrLf;\n break;\n }\n\n case 'lf': {\n this._resxNewlineNormalization = NewlineKind.Lf;\n break;\n }\n\n default: {\n errors.push(\n new Error(\n `Unexpected value \"${this._options.localizedData.normalizeResxNewlines}\" for option ` +\n '\"localizedData.normalizeResxNewlines\"'\n )\n );\n break;\n }\n }\n }\n // END options.localizedData.normalizeResxNewlines\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 if (\n this._options.noStringsLocaleName === undefined ||\n this._options.noStringsLocaleName === null ||\n !ensureValidLocaleName(this._options.noStringsLocaleName)\n ) {\n this._noStringsLocaleName = 'none';\n } else {\n this._noStringsLocaleName = this._options.noStringsLocaleName;\n }\n // END options.noStringsLocaleName\n\n return { errors, warnings };\n }\n\n private _getPlaceholderString(): IStringPlaceholder {\n const suffix: string = (this._stringPlaceholderCounter++).toString();\n return {\n value: `${Constants.STRING_PLACEHOLDER_PREFIX}_\\\\_${Constants.STRING_PLACEHOLDER_LABEL}_${suffix}`,\n suffix: suffix\n };\n }\n\n private _chunkHasLocalizedModules(chunk: Webpack.compilation.Chunk): boolean {\n let chunkHasAnyLocModules: boolean | undefined = EntityMarker.getMark(chunk);\n if (chunkHasAnyLocModules === undefined) {\n chunkHasAnyLocModules = false;\n for (const module of chunk.getModules()) {\n if (EntityMarker.getMark(module)) {\n chunkHasAnyLocModules = true;\n break;\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 && chunk.hasRuntime()) {\n for (const asyncChunk of chunk.getAllAsyncChunks()) {\n if (this._chunkHasLocalizedModules(asyncChunk)) {\n chunkHasAnyLocModules = true;\n break;\n }\n }\n }\n\n EntityMarker.markEntity(chunk, chunkHasAnyLocModules);\n }\n\n return chunkHasAnyLocModules;\n }\n\n private _convertLocalizationFileToLocData(locFile: ILocalizationFile): ILocaleFileData {\n const locFileData: ILocaleFileData = {};\n for (const [stringName, locFileEntry] of Object.entries(locFile)) {\n locFileData[stringName] = locFileEntry.value;\n }\n\n return locFileData;\n }\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as Webpack from 'webpack';
|
|
2
|
+
import { NewlineKind } from '@rushstack/node-core-library';
|
|
3
|
+
import { IgnoreStringFunction } from '@rushstack/localization-utilities';
|
|
4
|
+
import { LocalizationPlugin } from './LocalizationPlugin';
|
|
5
|
+
export interface IWebpackConfigurationUpdaterOptions {
|
|
6
|
+
pluginInstance: LocalizationPlugin;
|
|
7
|
+
configuration: Webpack.Configuration;
|
|
8
|
+
globsToIgnore: string[] | undefined;
|
|
9
|
+
localeNameOrPlaceholder: string;
|
|
10
|
+
resxNewlineNormalization: NewlineKind | undefined;
|
|
11
|
+
ignoreMissingResxComments: boolean | undefined;
|
|
12
|
+
ignoreString: IgnoreStringFunction | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare class WebpackConfigurationUpdater {
|
|
15
|
+
static amendWebpackConfigurationForMultiLocale(options: IWebpackConfigurationUpdaterOptions): void;
|
|
16
|
+
static amendWebpackConfigurationForInPlaceLocFiles(options: IWebpackConfigurationUpdaterOptions): void;
|
|
17
|
+
private static _tryUpdateLocaleTokenInPublicPathPlugin;
|
|
18
|
+
private static _addLoadersForLocFiles;
|
|
19
|
+
private static _addRulesToConfiguration;
|
|
20
|
+
private static _tryUpdateSourceMapFilename;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=WebpackConfigurationUpdater.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebpackConfigurationUpdater.d.ts","sourceRoot":"","sources":["../src/WebpackConfigurationUpdater.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAGzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI1D,MAAM,WAAW,mCAAmC;IAClD,cAAc,EAAE,kBAAkB,CAAC;IACnC,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;IACrC,aAAa,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACpC,uBAAuB,EAAE,MAAM,CAAC;IAChC,wBAAwB,EAAE,WAAW,GAAG,SAAS,CAAC;IAClD,yBAAyB,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/C,YAAY,EAAE,oBAAoB,GAAG,SAAS,CAAC;CAChD;AAID,qBAAa,2BAA2B;WACxB,uCAAuC,CAAC,OAAO,EAAE,mCAAmC,GAAG,IAAI;WAgB3F,2CAA2C,CACvD,OAAO,EAAE,mCAAmC,GAC3C,IAAI;IAuBP,OAAO,CAAC,MAAM,CAAC,uCAAuC;IA4BtD,OAAO,CAAC,MAAM,CAAC,sBAAsB;IA6BrC,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAiBvC,OAAO,CAAC,MAAM,CAAC,2BAA2B;CAY3C"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.WebpackConfigurationUpdater = void 0;
|
|
32
|
+
const minimatch_1 = __importDefault(require("minimatch"));
|
|
33
|
+
const path = __importStar(require("path"));
|
|
34
|
+
const lodash = __importStar(require("lodash"));
|
|
35
|
+
const Constants_1 = require("./utilities/Constants");
|
|
36
|
+
const FILE_TOKEN_REGEX = new RegExp(lodash.escapeRegExp('[file]'));
|
|
37
|
+
class WebpackConfigurationUpdater {
|
|
38
|
+
static amendWebpackConfigurationForMultiLocale(options) {
|
|
39
|
+
const loader = path.resolve(__dirname, 'loaders', 'LocLoader.js');
|
|
40
|
+
const loaderOptions = {
|
|
41
|
+
pluginInstance: options.pluginInstance,
|
|
42
|
+
resxNewlineNormalization: options.resxNewlineNormalization,
|
|
43
|
+
ignoreMissingResxComments: options.ignoreMissingResxComments,
|
|
44
|
+
ignoreString: options.ignoreString
|
|
45
|
+
};
|
|
46
|
+
WebpackConfigurationUpdater._addLoadersForLocFiles(options, loader, loaderOptions);
|
|
47
|
+
WebpackConfigurationUpdater._tryUpdateLocaleTokenInPublicPathPlugin(options);
|
|
48
|
+
WebpackConfigurationUpdater._tryUpdateSourceMapFilename(options.configuration);
|
|
49
|
+
}
|
|
50
|
+
static amendWebpackConfigurationForInPlaceLocFiles(options) {
|
|
51
|
+
const loader = path.resolve(__dirname, 'loaders', 'InPlaceLocFileLoader.js');
|
|
52
|
+
const loaderOptions = {
|
|
53
|
+
resxNewlineNormalization: options.resxNewlineNormalization,
|
|
54
|
+
ignoreMissingResxComments: options.ignoreMissingResxComments,
|
|
55
|
+
ignoreString: options.ignoreString
|
|
56
|
+
};
|
|
57
|
+
WebpackConfigurationUpdater._addRulesToConfiguration(options.configuration, [
|
|
58
|
+
{
|
|
59
|
+
test: Constants_1.Constants.RESOURCE_FILE_NAME_REGEXP,
|
|
60
|
+
use: [
|
|
61
|
+
{
|
|
62
|
+
loader: loader,
|
|
63
|
+
options: loaderOptions
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
type: 'json',
|
|
67
|
+
sideEffects: false
|
|
68
|
+
}
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
static _tryUpdateLocaleTokenInPublicPathPlugin(options) {
|
|
72
|
+
let setPublicPathPlugin;
|
|
73
|
+
try {
|
|
74
|
+
const pluginPackage = require('@rushstack/set-webpack-public-path-plugin');
|
|
75
|
+
setPublicPathPlugin = pluginPackage.SetPublicPathPlugin;
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
// public path plugin isn't present - ignore
|
|
79
|
+
}
|
|
80
|
+
if (setPublicPathPlugin && options.configuration.plugins) {
|
|
81
|
+
for (const plugin of options.configuration.plugins) {
|
|
82
|
+
if (plugin instanceof setPublicPathPlugin) {
|
|
83
|
+
if (plugin.options &&
|
|
84
|
+
plugin.options.scriptName &&
|
|
85
|
+
plugin.options.scriptName.isTokenized &&
|
|
86
|
+
plugin.options.scriptName.name) {
|
|
87
|
+
plugin.options.scriptName.name = plugin.options.scriptName.name.replace(/\[locale\]/g, options.localeNameOrPlaceholder);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
static _addLoadersForLocFiles(options, loader, loaderOptions) {
|
|
94
|
+
const { globsToIgnore, configuration } = options;
|
|
95
|
+
const rules = globsToIgnore && globsToIgnore.length > 0
|
|
96
|
+
? {
|
|
97
|
+
include: Constants_1.Constants.RESOURCE_FILE_NAME_REGEXP,
|
|
98
|
+
exclude: (filePath) => globsToIgnore.some((glob) => (0, minimatch_1.default)(filePath, glob))
|
|
99
|
+
}
|
|
100
|
+
: Constants_1.Constants.RESOURCE_FILE_NAME_REGEXP;
|
|
101
|
+
WebpackConfigurationUpdater._addRulesToConfiguration(configuration, [
|
|
102
|
+
{
|
|
103
|
+
test: rules,
|
|
104
|
+
use: [
|
|
105
|
+
{
|
|
106
|
+
loader: loader,
|
|
107
|
+
options: loaderOptions
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
type: 'json',
|
|
111
|
+
sideEffects: false
|
|
112
|
+
}
|
|
113
|
+
]);
|
|
114
|
+
}
|
|
115
|
+
static _addRulesToConfiguration(configuration, rules) {
|
|
116
|
+
if (!configuration.module) {
|
|
117
|
+
configuration.module = {
|
|
118
|
+
rules: []
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (!configuration.module.rules) {
|
|
122
|
+
configuration.module.rules = [];
|
|
123
|
+
}
|
|
124
|
+
configuration.module.rules.push(...rules);
|
|
125
|
+
}
|
|
126
|
+
static _tryUpdateSourceMapFilename(configuration) {
|
|
127
|
+
if (!configuration.output) {
|
|
128
|
+
configuration.output = {}; // This should never happen
|
|
129
|
+
}
|
|
130
|
+
if (configuration.output.sourceMapFilename !== undefined) {
|
|
131
|
+
configuration.output.sourceMapFilename = configuration.output.sourceMapFilename.replace(FILE_TOKEN_REGEX, Constants_1.Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.WebpackConfigurationUpdater = WebpackConfigurationUpdater;
|
|
136
|
+
//# sourceMappingURL=WebpackConfigurationUpdater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebpackConfigurationUpdater.js","sourceRoot":"","sources":["../src/WebpackConfigurationUpdater.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,0DAAkC;AAClC,2CAA6B;AAI7B,+CAAiC;AAGjC,qDAAkD;AAelD,MAAM,gBAAgB,GAAW,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;AAE3E,MAAa,2BAA2B;IAC/B,MAAM,CAAC,uCAAuC,CAAC,OAA4C;QAChG,MAAM,MAAM,GAAW,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;QAC1E,MAAM,aAAa,GAAsB;YACvC,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;YAC1D,yBAAyB,EAAE,OAAO,CAAC,yBAAyB;YAC5D,YAAY,EAAE,OAAO,CAAC,YAAY;SACnC,CAAC;QAEF,2BAA2B,CAAC,sBAAsB,CAAC,OA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AAG,EAAE,CAAC;SACjC;QAED,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IAC5C,CAAC;IAEO,MAAM,CAAC,2BAA2B,CAAC,aAAoC;QAC7E,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YACzB,aAAa,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,2BAA2B;SACvD;QAED,IAAI,aAAa,CAAC,MAAM,CAAC,iBAAiB,KAAK,SAAS,EAAE;YACxD,aAAa,CAAC,MAAM,CAAC,iBAAiB,GAAG,aAAa,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,CACrF,gBAAgB,EAChB,qBAAS,CAAC,mCAAmC,CAC9C,CAAC;SACH;IACH,CAAC;CACF;AAhID,kEAgIC","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 minimatch from 'minimatch';\nimport * as path from 'path';\nimport * as Webpack from 'webpack';\nimport * as SetPublicPathPluginPackageType from '@rushstack/set-webpack-public-path-plugin';\nimport { NewlineKind } from '@rushstack/node-core-library';\nimport * as lodash from 'lodash';\nimport { IgnoreStringFunction } from '@rushstack/localization-utilities';\n\nimport { Constants } from './utilities/Constants';\nimport { LocalizationPlugin } from './LocalizationPlugin';\nimport { ILocLoaderOptions } from './loaders/LocLoader';\nimport { IBaseLoaderOptions } from './loaders/LoaderFactory';\n\nexport interface IWebpackConfigurationUpdaterOptions {\n pluginInstance: LocalizationPlugin;\n configuration: Webpack.Configuration;\n globsToIgnore: string[] | undefined;\n localeNameOrPlaceholder: string;\n resxNewlineNormalization: NewlineKind | undefined;\n ignoreMissingResxComments: boolean | undefined;\n ignoreString: IgnoreStringFunction | undefined;\n}\n\nconst FILE_TOKEN_REGEX: RegExp = new RegExp(lodash.escapeRegExp('[file]'));\n\nexport class WebpackConfigurationUpdater {\n public static amendWebpackConfigurationForMultiLocale(options: IWebpackConfigurationUpdaterOptions): void {\n const loader: string = path.resolve(__dirname, 'loaders', 'LocLoader.js');\n const loaderOptions: ILocLoaderOptions = {\n pluginInstance: options.pluginInstance,\n resxNewlineNormalization: options.resxNewlineNormalization,\n ignoreMissingResxComments: options.ignoreMissingResxComments,\n ignoreString: options.ignoreString\n };\n\n WebpackConfigurationUpdater._addLoadersForLocFiles(options, loader, loaderOptions);\n\n WebpackConfigurationUpdater._tryUpdateLocaleTokenInPublicPathPlugin(options);\n\n WebpackConfigurationUpdater._tryUpdateSourceMapFilename(options.configuration);\n }\n\n public static amendWebpackConfigurationForInPlaceLocFiles(\n options: IWebpackConfigurationUpdaterOptions\n ): void {\n const loader: string = path.resolve(__dirname, 'loaders', 'InPlaceLocFileLoader.js');\n const loaderOptions: IBaseLoaderOptions = {\n resxNewlineNormalization: options.resxNewlineNormalization,\n ignoreMissingResxComments: options.ignoreMissingResxComments,\n ignoreString: options.ignoreString\n };\n\n WebpackConfigurationUpdater._addRulesToConfiguration(options.configuration, [\n {\n test: Constants.RESOURCE_FILE_NAME_REGEXP,\n use: [\n {\n loader: loader,\n options: loaderOptions\n }\n ],\n type: 'json',\n sideEffects: false\n }\n ]);\n }\n\n private static _tryUpdateLocaleTokenInPublicPathPlugin(options: IWebpackConfigurationUpdaterOptions): void {\n let setPublicPathPlugin: typeof SetPublicPathPluginPackageType.SetPublicPathPlugin | undefined;\n try {\n const pluginPackage: typeof SetPublicPathPluginPackageType = require('@rushstack/set-webpack-public-path-plugin');\n setPublicPathPlugin = pluginPackage.SetPublicPathPlugin;\n } catch (e) {\n // public path plugin isn't present - ignore\n }\n\n if (setPublicPathPlugin && options.configuration.plugins) {\n for (const plugin of options.configuration.plugins) {\n if (plugin instanceof setPublicPathPlugin) {\n if (\n plugin.options &&\n plugin.options.scriptName &&\n plugin.options.scriptName.isTokenized &&\n plugin.options.scriptName.name\n ) {\n plugin.options.scriptName.name = plugin.options.scriptName.name.replace(\n /\\[locale\\]/g,\n options.localeNameOrPlaceholder\n );\n }\n }\n }\n }\n }\n\n private static _addLoadersForLocFiles(\n options: IWebpackConfigurationUpdaterOptions,\n loader: string,\n loaderOptions: IBaseLoaderOptions\n ): void {\n const { globsToIgnore, configuration } = options;\n const rules: Webpack.RuleSetCondition =\n globsToIgnore && globsToIgnore.length > 0\n ? {\n include: Constants.RESOURCE_FILE_NAME_REGEXP,\n exclude: (filePath: string): boolean =>\n globsToIgnore.some((glob: string): boolean => minimatch(filePath, glob))\n }\n : Constants.RESOURCE_FILE_NAME_REGEXP;\n WebpackConfigurationUpdater._addRulesToConfiguration(configuration, [\n {\n test: rules,\n use: [\n {\n loader: loader,\n options: loaderOptions\n }\n ],\n type: 'json',\n sideEffects: false\n }\n ]);\n }\n\n private static _addRulesToConfiguration(\n configuration: Webpack.Configuration,\n rules: Webpack.RuleSetRule[]\n ): void {\n if (!configuration.module) {\n configuration.module = {\n rules: []\n };\n }\n\n if (!configuration.module.rules) {\n configuration.module.rules = [];\n }\n\n configuration.module.rules.push(...rules);\n }\n\n private static _tryUpdateSourceMapFilename(configuration: Webpack.Configuration): void {\n if (!configuration.output) {\n configuration.output = {}; // This should never happen\n }\n\n if (configuration.output.sourceMapFilename !== undefined) {\n configuration.output.sourceMapFilename = configuration.output.sourceMapFilename.replace(\n FILE_TOKEN_REGEX,\n Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN\n );\n }\n }\n}\n"]}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { LocalizationPlugin, IStringPlaceholder as _IStringPlaceholder } from './LocalizationPlugin';
|
|
2
|
+
export { IDefaultLocaleOptions, ILocaleData, ILocaleElementMap, ILocaleFileData, ILocalizationPluginOptions, ILocalizationStats, ILocalizationStatsChunkGroup, ILocalizationStatsEntrypoint, ILocalizationStatsOptions, ILocalizedData, ILocalizedStrings, IPassthroughLocaleOptions, IPseudolocalesOptions, IResolvedMissingTranslations, ITypingsGenerationOptions } from './interfaces';
|
|
3
|
+
export { ILocalizedWebpackChunk } from './webpackInterfaces';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAErG,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,0BAA0B,EAC1B,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,yBAAyB,EACzB,cAAc,EACd,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,EAC5B,yBAAyB,EAC1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.LocalizationPlugin = void 0;
|
|
6
|
+
var LocalizationPlugin_1 = require("./LocalizationPlugin");
|
|
7
|
+
Object.defineProperty(exports, "LocalizationPlugin", { enumerable: true, get: function () { return LocalizationPlugin_1.LocalizationPlugin; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +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 ILocalizationPluginOptions,\n ILocalizationStats,\n ILocalizationStatsChunkGroup,\n ILocalizationStatsEntrypoint,\n ILocalizationStatsOptions,\n ILocalizedData,\n ILocalizedStrings,\n IPassthroughLocaleOptions,\n IPseudolocalesOptions,\n IResolvedMissingTranslations,\n ITypingsGenerationOptions\n} from './interfaces';\n\nexport { ILocalizedWebpackChunk } from './webpackInterfaces';\n"]}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { IgnoreStringFunction, IPseudolocaleOptions } from '@rushstack/localization-utilities';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the passthrough locale.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface IPassthroughLocaleOptions {
|
|
8
|
+
/**
|
|
9
|
+
* If this is set to `true`, a passthrough locale will be included in the output
|
|
10
|
+
*/
|
|
11
|
+
usePassthroughLocale?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* If {@link IPassthroughLocaleOptions.usePassthroughLocale} is set, use this name for the passthrough locale.
|
|
14
|
+
* Defaults to "passthrough"
|
|
15
|
+
*/
|
|
16
|
+
passthroughLocaleName?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Options for typing generation.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export interface ITypingsGenerationOptions {
|
|
24
|
+
/**
|
|
25
|
+
* This property specifies the folder in which `.d.ts` files for loc files should be dropped.
|
|
26
|
+
*/
|
|
27
|
+
generatedTsFolder: string;
|
|
28
|
+
/**
|
|
29
|
+
* This optional property overrides the compiler context for discovery of localization files
|
|
30
|
+
* for which typings should be generated.
|
|
31
|
+
*/
|
|
32
|
+
sourceRoot?: string;
|
|
33
|
+
/**
|
|
34
|
+
* If this option is set to `true`, loc modules typings will be exported wrapped in a `default` property.
|
|
35
|
+
*/
|
|
36
|
+
exportAsDefault?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated
|
|
39
|
+
* Use {@link ILocalizationPluginOptions.ignoreString} instead.
|
|
40
|
+
*
|
|
41
|
+
* @internalRemarks
|
|
42
|
+
* TODO: Remove when version 1.0.0 is released.
|
|
43
|
+
*/
|
|
44
|
+
ignoreString?: (resxFilePath: string, stringName: string) => boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Optionally, provide a function that will process string comments. The returned value will become the
|
|
47
|
+
* TSDoc comment for the string in the typings.
|
|
48
|
+
*/
|
|
49
|
+
processComment?: (comment: string | undefined, resxFilePath: string, stringName: string) => string | undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export interface IDefaultLocaleOptions {
|
|
55
|
+
/**
|
|
56
|
+
* This required property specifies the name of the locale used in the
|
|
57
|
+
* `.resx`, `.loc.json`, and `.resjson` files in the source
|
|
58
|
+
*/
|
|
59
|
+
localeName: string;
|
|
60
|
+
/**
|
|
61
|
+
* If this option is set to `true`, strings that are missing from
|
|
62
|
+
* `localizedData.translatedStrings` will be provided by the default locale
|
|
63
|
+
*/
|
|
64
|
+
fillMissingTranslationStrings?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Options for generated pseudolocales.
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export interface IPseudolocalesOptions {
|
|
72
|
+
[pseudoLocaleName: string]: IPseudolocaleOptions;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
export interface ILocalizedData {
|
|
78
|
+
/**
|
|
79
|
+
* Options for the locale used in the source localized data files.
|
|
80
|
+
*/
|
|
81
|
+
defaultLocale: IDefaultLocaleOptions;
|
|
82
|
+
/**
|
|
83
|
+
* Use this parameter to specify the translated data.
|
|
84
|
+
*/
|
|
85
|
+
translatedStrings: ILocalizedStrings;
|
|
86
|
+
/**
|
|
87
|
+
* Use this parameter to specify a function used to load translations missing from
|
|
88
|
+
* the {@link ILocalizedData.translatedStrings} parameter.
|
|
89
|
+
*/
|
|
90
|
+
resolveMissingTranslatedStrings?: (locales: string[], filePath: string) => IResolvedMissingTranslations;
|
|
91
|
+
/**
|
|
92
|
+
* Options around including a passthrough locale.
|
|
93
|
+
*/
|
|
94
|
+
passthroughLocale?: IPassthroughLocaleOptions;
|
|
95
|
+
/**
|
|
96
|
+
* Options for pseudo-localization.
|
|
97
|
+
*/
|
|
98
|
+
pseudolocales?: IPseudolocalesOptions;
|
|
99
|
+
/**
|
|
100
|
+
* Normalize newlines in RESX files to either CRLF (Windows-style) or LF ('nix style)
|
|
101
|
+
*/
|
|
102
|
+
normalizeResxNewlines?: 'lf' | 'crlf';
|
|
103
|
+
/**
|
|
104
|
+
* If set to true, do not warn on missing RESX `<data>` element comments.
|
|
105
|
+
*/
|
|
106
|
+
ignoreMissingResxComments?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Options for how localization stats data should be produced.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
export interface ILocalizationStatsOptions {
|
|
114
|
+
/**
|
|
115
|
+
* This option is used to designate a path at which a JSON file describing the localized
|
|
116
|
+
* assets produced should be written.
|
|
117
|
+
*/
|
|
118
|
+
dropPath?: string;
|
|
119
|
+
/**
|
|
120
|
+
* This option is used to specify a callback to be called with the stats data that would be
|
|
121
|
+
* dropped at `localizationStats.dropPath` after compilation completes.
|
|
122
|
+
*/
|
|
123
|
+
callback?: (stats: ILocalizationStats) => void;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The options for localization.
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
export interface ILocalizationPluginOptions {
|
|
131
|
+
/**
|
|
132
|
+
* Localization data.
|
|
133
|
+
*/
|
|
134
|
+
localizedData: ILocalizedData;
|
|
135
|
+
/**
|
|
136
|
+
* This option is used to specify `.resx`, `.resx.json`, and `.loc.json` files that should not be processed by
|
|
137
|
+
* this plugin.
|
|
138
|
+
*/
|
|
139
|
+
globsToIgnore?: string[];
|
|
140
|
+
/**
|
|
141
|
+
* The value to replace the [locale] token with for chunks without localized strings. Defaults to "none"
|
|
142
|
+
*/
|
|
143
|
+
noStringsLocaleName?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Options for how localization stats data should be produced.
|
|
146
|
+
*/
|
|
147
|
+
localizationStats?: ILocalizationStatsOptions;
|
|
148
|
+
/**
|
|
149
|
+
* This option is used to specify how and if TypeScript typings should be generated for loc files.
|
|
150
|
+
*/
|
|
151
|
+
typingsOptions?: ITypingsGenerationOptions;
|
|
152
|
+
/**
|
|
153
|
+
* Optionally, provide a function that will be called for each string. If the function returns `true`
|
|
154
|
+
* the string will not be included.
|
|
155
|
+
*/
|
|
156
|
+
ignoreString?: IgnoreStringFunction;
|
|
157
|
+
/**
|
|
158
|
+
* @deprecated
|
|
159
|
+
* Use {@link ILocalizationPluginOptions.globsToIgnore} instead.
|
|
160
|
+
*
|
|
161
|
+
* @internalRemarks
|
|
162
|
+
* TODO: Remove when version 1.0.0 is released.
|
|
163
|
+
*/
|
|
164
|
+
filesToIgnore?: string[];
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
export interface ILocaleFileData {
|
|
170
|
+
[stringName: string]: string;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* @public
|
|
174
|
+
*/
|
|
175
|
+
export interface IResolvedMissingTranslations {
|
|
176
|
+
[localeName: string]: string | ILocaleFileData;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
181
|
+
export interface ILocaleData {
|
|
182
|
+
[locFilePath: string]: string | ILocaleFileData;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* @public
|
|
186
|
+
*/
|
|
187
|
+
export interface ILocalizedStrings {
|
|
188
|
+
[locale: string]: ILocaleData;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* @public
|
|
192
|
+
*/
|
|
193
|
+
export interface ILocaleElementMap {
|
|
194
|
+
[locale: string]: string;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* @public
|
|
198
|
+
*/
|
|
199
|
+
export interface ILocalizationStatsEntrypoint {
|
|
200
|
+
localizedAssets: ILocaleElementMap;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* @public
|
|
204
|
+
*/
|
|
205
|
+
export interface ILocalizationStatsChunkGroup {
|
|
206
|
+
localizedAssets: ILocaleElementMap;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
export interface ILocalizationStats {
|
|
212
|
+
entrypoints: {
|
|
213
|
+
[name: string]: ILocalizationStatsEntrypoint;
|
|
214
|
+
};
|
|
215
|
+
namedChunkGroups: {
|
|
216
|
+
[name: string]: ILocalizationStatsChunkGroup;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAE/F;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;I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|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
//# sourceMappingURL=interfaces.js.map
|
|
@@ -0,0 +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 { IgnoreStringFunction, 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 * Options for typing generation.\n *\n * @public\n */\nexport interface ITypingsGenerationOptions {\n /**\n * This property specifies the folder in which `.d.ts` files for loc files should be dropped.\n */\n generatedTsFolder: string;\n\n /**\n * This optional property overrides the compiler context for discovery of localization files\n * for which typings should be generated.\n */\n sourceRoot?: string;\n\n /**\n * If this option is set to `true`, loc modules typings will be exported wrapped in a `default` property.\n */\n exportAsDefault?: boolean;\n\n /**\n * @deprecated\n * Use {@link ILocalizationPluginOptions.ignoreString} instead.\n *\n * @internalRemarks\n * TODO: Remove when version 1.0.0 is released.\n */\n ignoreString?: (resxFilePath: string, stringName: string) => boolean;\n\n /**\n * Optionally, provide a function that will process string comments. The returned value will become the\n * TSDoc comment for the string in the typings.\n */\n processComment?: (\n comment: string | undefined,\n resxFilePath: string,\n stringName: string\n ) => string | undefined;\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?: (locales: string[], filePath: string) => 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 * Normalize newlines in RESX files to either CRLF (Windows-style) or LF ('nix style)\n */\n normalizeResxNewlines?: 'lf' | 'crlf';\n\n /**\n * If set to true, do not warn on missing RESX `<data>` element comments.\n */\n ignoreMissingResxComments?: boolean;\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 * Options for how localization stats data should be produced.\n */\n localizationStats?: ILocalizationStatsOptions;\n\n /**\n * This option is used to specify how and if TypeScript typings should be generated for loc files.\n */\n typingsOptions?: ITypingsGenerationOptions;\n\n /**\n * Optionally, provide a function that will be called for each string. If the function returns `true`\n * the string will not be included.\n */\n ignoreString?: IgnoreStringFunction;\n\n /**\n * @deprecated\n * Use {@link ILocalizationPluginOptions.globsToIgnore} instead.\n *\n * @internalRemarks\n * TODO: Remove when version 1.0.0 is released.\n */\n filesToIgnore?: string[];\n}\n\n/**\n * @public\n */\nexport interface ILocaleFileData {\n [stringName: string]: string;\n}\n\n/**\n * @public\n */\nexport interface IResolvedMissingTranslations {\n [localeName: string]: string | ILocaleFileData;\n}\n\n/**\n * @public\n */\nexport interface ILocaleData {\n [locFilePath: string]: 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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InPlaceLocFileLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/InPlaceLocFileLoader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;;AAOjC,wBAkBG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
6
|
+
const localization_utilities_1 = require("@rushstack/localization-utilities");
|
|
7
|
+
const LoaderFactory_1 = require("./LoaderFactory");
|
|
8
|
+
const LoaderTerminalProvider_1 = require("../utilities/LoaderTerminalProvider");
|
|
9
|
+
exports.default = (0, LoaderFactory_1.loaderFactory)(function (locFilePath, content, options) {
|
|
10
|
+
const locFileData = (0, localization_utilities_1.parseLocFile)(Object.assign(Object.assign({}, options), { content, filePath: locFilePath, terminal: new node_core_library_1.Terminal(LoaderTerminalProvider_1.LoaderTerminalProvider.getTerminalProviderForLoader(this)) }));
|
|
11
|
+
const resultObject = {};
|
|
12
|
+
for (const [stringName, stringValue] of Object.entries(locFileData)) {
|
|
13
|
+
resultObject[stringName] = stringValue.value;
|
|
14
|
+
}
|
|
15
|
+
return resultObject;
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=InPlaceLocFileLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InPlaceLocFileLoader.js","sourceRoot":"","sources":["../../src/loaders/InPlaceLocFileLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,oEAAwD;AACxD,8EAAoF;AAEpF,mDAAoE;AACpE,gFAA6E;AAE7E,kBAAe,IAAA,6BAAa,EAAC,UAE3B,WAAmB,EACnB,OAAe,EACf,OAA2B;IAE3B,MAAM,WAAW,GAAsB,IAAA,qCAAY,kCAC9C,OAAO,KACV,OAAO,EACP,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,IAAI,4BAAQ,CAAC,+CAAsB,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC,IACjF,CAAC;IACH,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,YAAY,CAAC;AACtB,CAAC,CAAC,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 { loader } from 'webpack';\nimport { Terminal } from '@rushstack/node-core-library';\nimport { ILocalizationFile, parseLocFile } from '@rushstack/localization-utilities';\n\nimport { loaderFactory, IBaseLoaderOptions } from './LoaderFactory';\nimport { LoaderTerminalProvider } from '../utilities/LoaderTerminalProvider';\n\nexport default loaderFactory(function (\n this: loader.LoaderContext,\n locFilePath: string,\n content: string,\n options: IBaseLoaderOptions\n) {\n const locFileData: ILocalizationFile = parseLocFile({\n ...options,\n content,\n filePath: locFilePath,\n terminal: new Terminal(LoaderTerminalProvider.getTerminalProviderForLoader(this))\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 resultObject;\n});\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { loader } from 'webpack';
|
|
2
|
+
import { NewlineKind } from '@rushstack/node-core-library';
|
|
3
|
+
import type { IgnoreStringFunction } from '@rushstack/localization-utilities';
|
|
4
|
+
export interface IBaseLoaderOptions {
|
|
5
|
+
resxNewlineNormalization: NewlineKind | undefined;
|
|
6
|
+
ignoreMissingResxComments: boolean | undefined;
|
|
7
|
+
ignoreString: IgnoreStringFunction | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface ILoaderResult {
|
|
10
|
+
[stringName: string]: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function loaderFactory<TOptions extends IBaseLoaderOptions>(innerLoader: (locFilePath: string, content: string, options: TOptions) => ILoaderResult): loader.Loader;
|
|
13
|
+
//# sourceMappingURL=LoaderFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoaderFactory.d.ts","sourceRoot":"","sources":["../../src/loaders/LoaderFactory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,WAAW,kBAAkB;IACjC,wBAAwB,EAAE,WAAW,GAAG,SAAS,CAAC;IAClD,yBAAyB,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/C,YAAY,EAAE,oBAAoB,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAED,wBAAgB,aAAa,CAAC,QAAQ,SAAS,kBAAkB,EAC/D,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,KAAK,aAAa,GACtF,MAAM,CAAC,MAAM,CAUf"}
|