@rushstack/webpack5-localization-plugin 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +24 -0
- package/README.md +209 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/webpack5-localization-plugin.d.ts +274 -0
- package/lib/AssetProcessor.d.ts +26 -0
- package/lib/AssetProcessor.d.ts.map +1 -0
- package/lib/AssetProcessor.js +243 -0
- package/lib/AssetProcessor.js.map +1 -0
- package/lib/LocalizationPlugin.d.ts +79 -0
- package/lib/LocalizationPlugin.d.ts.map +1 -0
- package/lib/LocalizationPlugin.js +586 -0
- package/lib/LocalizationPlugin.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 +173 -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/IResxLoaderOptions.d.ts +12 -0
- package/lib/loaders/IResxLoaderOptions.d.ts.map +1 -0
- package/lib/loaders/IResxLoaderOptions.js +5 -0
- package/lib/loaders/IResxLoaderOptions.js.map +1 -0
- package/lib/loaders/LoaderFactory.d.ts +6 -0
- package/lib/loaders/LoaderFactory.d.ts.map +1 -0
- package/lib/loaders/LoaderFactory.js +28 -0
- package/lib/loaders/LoaderFactory.js.map +1 -0
- package/lib/loaders/default-locale-loader.d.ts +8 -0
- package/lib/loaders/default-locale-loader.d.ts.map +1 -0
- package/lib/loaders/default-locale-loader.js +26 -0
- package/lib/loaders/default-locale-loader.js.map +1 -0
- package/lib/loaders/loc-loader.d.ts +15 -0
- package/lib/loaders/loc-loader.d.ts.map +1 -0
- package/lib/loaders/loc-loader.js +23 -0
- package/lib/loaders/loc-loader.js.map +1 -0
- package/lib/loaders/locjson-loader.d.ts +5 -0
- package/lib/loaders/locjson-loader.d.ts.map +1 -0
- package/lib/loaders/locjson-loader.js +14 -0
- package/lib/loaders/locjson-loader.js.map +1 -0
- package/lib/loaders/resjson-loader.d.ts +5 -0
- package/lib/loaders/resjson-loader.d.ts.map +1 -0
- package/lib/loaders/resjson-loader.js +14 -0
- package/lib/loaders/resjson-loader.js.map +1 -0
- package/lib/loaders/resx-loader.d.ts +5 -0
- package/lib/loaders/resx-loader.d.ts.map +1 -0
- package/lib/loaders/resx-loader.js +21 -0
- package/lib/loaders/resx-loader.js.map +1 -0
- package/lib/utilities/Constants.d.ts +12 -0
- package/lib/utilities/Constants.d.ts.map +1 -0
- package/lib/utilities/Constants.js +17 -0
- package/lib/utilities/Constants.js.map +1 -0
- package/lib/utilities/EntityMarker.d.ts +9 -0
- package/lib/utilities/EntityMarker.d.ts.map +1 -0
- package/lib/utilities/EntityMarker.js +21 -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 +13 -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 +35 -0
@@ -0,0 +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"]}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export declare const LOCALE_FILENAME_TOKEN: '[locale]';
|
2
|
+
export declare const LOCALE_FILENAME_TOKEN_REGEX: RegExp;
|
3
|
+
export declare const NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN: '[no-locale-file]';
|
4
|
+
export declare const NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX: RegExp;
|
5
|
+
export declare const STRING_PLACEHOLDER_PREFIX: '_LOCALIZED_STRING_f12dy0i7_n4bo_dqwj_39gf_sasqehjmihz9';
|
6
|
+
export declare const RESOURCE_FILE_NAME_REGEXP: RegExp;
|
7
|
+
export declare const STRING_PLACEHOLDER_LABEL: 'A';
|
8
|
+
export declare const LOCALE_NAME_PLACEHOLDER_LABEL: 'B';
|
9
|
+
export declare const JSONP_PLACEHOLDER_LABEL: 'C';
|
10
|
+
export declare const LOCALE_NAME_PLACEHOLDER: `${typeof STRING_PLACEHOLDER_PREFIX}__${typeof LOCALE_NAME_PLACEHOLDER_LABEL}_0`;
|
11
|
+
export declare const JSONP_PLACEHOLDER: `${typeof STRING_PLACEHOLDER_PREFIX}__${typeof JSONP_PLACEHOLDER_LABEL}_0`;
|
12
|
+
//# sourceMappingURL=Constants.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../../src/utilities/Constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,EAAE,UAAuB,CAAC;AAC5D,eAAO,MAAM,2BAA2B,EAAE,MAAuB,CAAC;AAClE,eAAO,MAAM,mCAAmC,EAAE,kBAAuC,CAAC;AAC1F,eAAO,MAAM,yCAAyC,EAAE,MAA+B,CAAC;AACxF,eAAO,MAAM,yBAAyB,EAAE,wDACkB,CAAC;AAE3D,eAAO,MAAM,yBAAyB,EAAE,MAAkD,CAAC;AAE3F,eAAO,MAAM,wBAAwB,EAAE,GAAS,CAAC;AACjD,eAAO,MAAM,6BAA6B,EAAE,GAAS,CAAC;AACtD,eAAO,MAAM,uBAAuB,EAAE,GAAS,CAAC;AAEhD,eAAO,MAAM,uBAAuB,EAAE,GAAG,OAAO,yBAAyB,KAAK,OAAO,6BAA6B,IAAyE,CAAC;AAC5L,eAAO,MAAM,iBAAiB,EAAE,GAAG,OAAO,yBAAyB,KAAK,OAAO,uBAAuB,IAAmE,CAAC"}
|
@@ -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
|
+
exports.JSONP_PLACEHOLDER = exports.LOCALE_NAME_PLACEHOLDER = exports.JSONP_PLACEHOLDER_LABEL = exports.LOCALE_NAME_PLACEHOLDER_LABEL = exports.STRING_PLACEHOLDER_LABEL = exports.RESOURCE_FILE_NAME_REGEXP = exports.STRING_PLACEHOLDER_PREFIX = exports.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX = exports.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN = exports.LOCALE_FILENAME_TOKEN_REGEX = exports.LOCALE_FILENAME_TOKEN = void 0;
|
6
|
+
exports.LOCALE_FILENAME_TOKEN = '[locale]';
|
7
|
+
exports.LOCALE_FILENAME_TOKEN_REGEX = /\[locale\]/gi;
|
8
|
+
exports.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN = '[no-locale-file]';
|
9
|
+
exports.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX = /\[no-locale-file\]/gi;
|
10
|
+
exports.STRING_PLACEHOLDER_PREFIX = '_LOCALIZED_STRING_f12dy0i7_n4bo_dqwj_39gf_sasqehjmihz9';
|
11
|
+
exports.RESOURCE_FILE_NAME_REGEXP = /\.(resx|resx\.json|loc\.json|resjson)$/i;
|
12
|
+
exports.STRING_PLACEHOLDER_LABEL = 'A';
|
13
|
+
exports.LOCALE_NAME_PLACEHOLDER_LABEL = 'B';
|
14
|
+
exports.JSONP_PLACEHOLDER_LABEL = 'C';
|
15
|
+
exports.LOCALE_NAME_PLACEHOLDER = `${exports.STRING_PLACEHOLDER_PREFIX}__${exports.LOCALE_NAME_PLACEHOLDER_LABEL}_0`;
|
16
|
+
exports.JSONP_PLACEHOLDER = `${exports.STRING_PLACEHOLDER_PREFIX}__${exports.JSONP_PLACEHOLDER_LABEL}_0`;
|
17
|
+
//# sourceMappingURL=Constants.js.map
|
@@ -0,0 +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"]}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Marks a webpack entity as containing or not containing localized resources.
|
3
|
+
*/
|
4
|
+
export declare function markEntity(entity: object, value: boolean): void;
|
5
|
+
/**
|
6
|
+
* Read the cache marker for whether or not the entity contains localized resources.
|
7
|
+
*/
|
8
|
+
export declare function getMark(entity: object): boolean | undefined;
|
9
|
+
//# sourceMappingURL=EntityMarker.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"EntityMarker.d.ts","sourceRoot":"","sources":["../../src/utilities/EntityMarker.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAE/D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAE3D"}
|
@@ -0,0 +1,21 @@
|
|
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.getMark = exports.markEntity = void 0;
|
6
|
+
const MARKS = new WeakMap();
|
7
|
+
/**
|
8
|
+
* Marks a webpack entity as containing or not containing localized resources.
|
9
|
+
*/
|
10
|
+
function markEntity(entity, value) {
|
11
|
+
MARKS.set(entity, value);
|
12
|
+
}
|
13
|
+
exports.markEntity = markEntity;
|
14
|
+
/**
|
15
|
+
* Read the cache marker for whether or not the entity contains localized resources.
|
16
|
+
*/
|
17
|
+
function getMark(entity) {
|
18
|
+
return MARKS.get(entity);
|
19
|
+
}
|
20
|
+
exports.getMark = getMark;
|
21
|
+
//# sourceMappingURL=EntityMarker.js.map
|
@@ -0,0 +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"]}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { LoaderContext } from 'webpack';
|
2
|
+
import { ITerminalProvider } from '@rushstack/node-core-library';
|
3
|
+
export declare class LoaderTerminalProvider {
|
4
|
+
static getTerminalProviderForLoader(loaderContext: LoaderContext<{}>): ITerminalProvider;
|
5
|
+
}
|
6
|
+
//# sourceMappingURL=LoaderTerminalProvider.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"LoaderTerminalProvider.d.ts","sourceRoot":"","sources":["../../src/utilities/LoaderTerminalProvider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAA4B,MAAM,8BAA8B,CAAC;AAE3F,qBAAa,sBAAsB;WACnB,4BAA4B,CAAC,aAAa,EAAE,aAAa,CAAC,EAAE,CAAC,GAAG,iBAAiB;CAmBhG"}
|
@@ -0,0 +1,28 @@
|
|
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.LoaderTerminalProvider = void 0;
|
6
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
7
|
+
class LoaderTerminalProvider {
|
8
|
+
static getTerminalProviderForLoader(loaderContext) {
|
9
|
+
return {
|
10
|
+
supportsColor: false,
|
11
|
+
eolCharacter: '\n',
|
12
|
+
write: (data, severity) => {
|
13
|
+
switch (severity) {
|
14
|
+
case node_core_library_1.TerminalProviderSeverity.error: {
|
15
|
+
loaderContext.emitError(new Error(data));
|
16
|
+
break;
|
17
|
+
}
|
18
|
+
case node_core_library_1.TerminalProviderSeverity.warning: {
|
19
|
+
loaderContext.emitWarning(new Error(data));
|
20
|
+
break;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
};
|
25
|
+
}
|
26
|
+
}
|
27
|
+
exports.LoaderTerminalProvider = LoaderTerminalProvider;
|
28
|
+
//# sourceMappingURL=LoaderTerminalProvider.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"LoaderTerminalProvider.js","sourceRoot":"","sources":["../../src/utilities/LoaderTerminalProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,oEAA2F;AAE3F,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 { 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"]}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import type { Chunk, Compilation } from 'webpack';
|
2
|
+
/**
|
3
|
+
* @public
|
4
|
+
*/
|
5
|
+
export interface ILocalizedWebpackChunk extends Chunk {
|
6
|
+
localizedFiles?: {
|
7
|
+
[locale: string]: string;
|
8
|
+
};
|
9
|
+
}
|
10
|
+
export declare type IAssetPathOptions = Parameters<typeof Compilation.prototype.getPath>[1] & {
|
11
|
+
locale?: string;
|
12
|
+
};
|
13
|
+
//# sourceMappingURL=webpackInterfaces.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"webpackInterfaces.d.ts","sourceRoot":"","sources":["../src/webpackInterfaces.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,KAAK;IACnD,cAAc,CAAC,EAAE;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CAC/C;AAED,oBAAY,iBAAiB,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
@@ -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=webpackInterfaces.js.map
|
@@ -0,0 +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"]}
|
package/package.json
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"name": "@rushstack/webpack5-localization-plugin",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"description": "This plugin facilitates localization with Webpack.",
|
5
|
+
"main": "lib/index.js",
|
6
|
+
"typings": "dist/webpack5-localization-plugin.d.ts",
|
7
|
+
"license": "MIT",
|
8
|
+
"repository": {
|
9
|
+
"type": "git",
|
10
|
+
"url": "https://github.com/microsoft/rushstack.git",
|
11
|
+
"directory": "webpack/localization-plugin-5"
|
12
|
+
},
|
13
|
+
"peerDependencies": {
|
14
|
+
"webpack": "^5.68.0"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"@rushstack/localization-utilities": "0.7.2",
|
18
|
+
"@rushstack/node-core-library": "3.45.7",
|
19
|
+
"@types/node": "12.20.24"
|
20
|
+
},
|
21
|
+
"devDependencies": {
|
22
|
+
"@rushstack/eslint-config": "2.6.1",
|
23
|
+
"@rushstack/heft": "0.45.9",
|
24
|
+
"@rushstack/heft-node-rig": "1.9.10",
|
25
|
+
"@types/heft-jest": "1.0.1",
|
26
|
+
"memfs": "3.4.3",
|
27
|
+
"webpack": "~5.68.0"
|
28
|
+
},
|
29
|
+
"scripts": {
|
30
|
+
"build": "heft build --clean",
|
31
|
+
"_phase:build": "heft build --clean",
|
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"
|
35
|
+
}
|