@discord/jest-processor-discord-intl 0.8.0 → 0.9.0-rc.1

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.
Files changed (2) hide show
  1. package/index.js +25 -23
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -18,14 +18,18 @@ module.exports = {
18
18
  * @returns {string}
19
19
  */
20
20
  process(source, filePath, _config) {
21
+ const precompileOptions = {
22
+ format: IntlCompiledMessageFormat.KeylessJson,
23
+ // Always bundle secrets when running tests
24
+ bundleSecrets: true,
25
+ };
26
+
21
27
  const forceTranslation = filePath === '?forceTranslation';
22
28
  if (isMessageDefinitionsFile(filePath) && !forceTranslation) {
23
29
  const result = processDefinitionsFile(filePath, source, { processTranslations: false });
24
30
 
25
31
  const sourceMessages = /** @type {Buffer} */ (
26
- precompileFileForLocale(filePath, result.locale, {
27
- format: IntlCompiledMessageFormat.KeylessJson,
28
- })
32
+ precompileFileForLocale(filePath, result.locale, undefined, precompileOptions)
29
33
  ).toString();
30
34
 
31
35
  result.translationsLocaleMap[result.locale] = 'intl$sentinel-use-local';
@@ -48,29 +52,27 @@ module.exports = {
48
52
  // compatible values as a safe default.
49
53
  exportMode: 'transpiledEsModule',
50
54
  }).getOutput();
51
- }
55
+ } else {
56
+ const locale = getLocaleFromTranslationsFileName(filePath);
57
+ if (isMessageTranslationsFile(filePath)) {
58
+ processTranslationsFile(filePath, source, { locale });
59
+ } else if (!forceTranslation) {
60
+ throw new Error(
61
+ 'Expected a translation file or the `forceTranslation` query parameter on this import, but none was found',
62
+ );
63
+ }
52
64
 
53
- const locale = getLocaleFromTranslationsFileName(filePath);
54
- if (isMessageTranslationsFile(filePath)) {
55
- processTranslationsFile(filePath, source, { locale });
56
- } else if (!forceTranslation) {
57
- throw new Error(
58
- 'Expected a translation file or the `forceTranslation` query parameter on this import, but none was found',
65
+ const compiledResult = /** @type {Buffer} */ (
66
+ precompileFileForLocale(filePath, locale, undefined, precompileOptions)
59
67
  );
60
- }
61
68
 
62
- const compiledResult = /** @type {Buffer} */ (
63
- precompileFileForLocale(filePath, locale, {
64
- format: IntlCompiledMessageFormat.KeylessJson,
65
- })
66
- );
67
-
68
- if (forceTranslation) {
69
- return (
70
- 'module.exports.default = JSON.parse(' + JSON.stringify(compiledResult?.toString()) + ')'
71
- );
72
- } else {
73
- return compiledResult.toString();
69
+ if (forceTranslation) {
70
+ return (
71
+ 'module.exports.default = JSON.parse(' + JSON.stringify(compiledResult?.toString()) + ')'
72
+ );
73
+ } else {
74
+ return compiledResult.toString();
75
+ }
74
76
  }
75
77
  },
76
78
  };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@discord/jest-processor-discord-intl",
3
- "version": "0.8.0",
3
+ "version": "0.9.0-rc.1",
4
4
  "license": "MIT",
5
5
  "description": "Processor plugin for Jest to handle intl message definitions and translations from @discord/intl",
6
6
  "exports": {
7
7
  ".": "./index.js"
8
8
  },
9
9
  "dependencies": {
10
- "@discord/intl-loader-core": "0.8.0"
10
+ "@discord/intl-loader-core": "0.9.0-rc.1"
11
11
  }
12
12
  }