@discord/metro-intl-transformer 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.
package/asset-plugin.js CHANGED
@@ -20,6 +20,15 @@ const {
20
20
  * The final extension to use when searching for and creating assets. Defaults to `json`. Note that
21
21
  * all compiled assets will include the initial extension `.compiled.messages.`, followed by this
22
22
  * configuration.
23
+ *
24
+ * @property {boolean=} bundleSecrets
25
+ * Whether messages marked as `secret` will be preserved in the bundled message assets. When false,
26
+ * secret messages have their values replaced with obfuscated text to prevent leaking information.
27
+ *
28
+ * @property {IntlCompiledMessageFormat=} format
29
+ * The format to which messages shouuld be compiled during bundling. `Json` will cause the messages
30
+ * to be compiled to a FormatJS-like compatible format, while `KeylessJson` will use a much more
31
+ * compressed, `@discord/intl`-specific format. `KeylessJson` is the default.
23
32
  */
24
33
 
25
34
  /**
@@ -30,6 +39,7 @@ const {
30
39
  const defaultConfig = {
31
40
  cacheDir: path.join('.cache', 'intl'),
32
41
  assetExtension: 'json',
42
+ bundleSecrets: false,
33
43
  };
34
44
 
35
45
  /**
@@ -76,7 +86,12 @@ const pluginConfig = fetchConfig();
76
86
  * @param {any} assetData
77
87
  */
78
88
  async function transformAsset(assetData) {
79
- const { cacheDir, assetExtension } = await pluginConfig;
89
+ const {
90
+ cacheDir,
91
+ assetExtension,
92
+ format = IntlCompiledMessageFormat.KeylessJson,
93
+ bundleSecrets = false,
94
+ } = await pluginConfig;
80
95
 
81
96
  const filename = assetData.files[0] ?? '';
82
97
  // If this isn't a translations file or if it's already a compiled artifact, then we don't want
@@ -102,9 +117,9 @@ async function transformAsset(assetData) {
102
117
  }
103
118
 
104
119
  const result = processTranslationsFile(filename);
105
- precompileFileForLocale(filename, result.locale, {
106
- format: IntlCompiledMessageFormat.KeylessJson,
107
- outputFile,
120
+ precompileFileForLocale(filename, result.locale, outputFile, {
121
+ format,
122
+ bundleSecrets,
108
123
  });
109
124
 
110
125
  return {
package/index.js CHANGED
@@ -16,6 +16,7 @@ const debug = require('debug')('intl:metro-intl-transformer');
16
16
  * getPrelude: () => string
17
17
  * getTranslationAssetExtension: () => string,
18
18
  * getTranslationImport: (importPath: string) => string,
19
+ * bundleSecrets?: boolean,
19
20
  * }} options
20
21
  * @returns {string | Buffer}
21
22
  */
@@ -25,6 +26,7 @@ function transformToString({
25
26
  getPrelude,
26
27
  getTranslationAssetExtension,
27
28
  getTranslationImport,
29
+ bundleSecrets = false,
28
30
  }) {
29
31
  if (isMessageDefinitionsFile(filename)) {
30
32
  debug(`[${filename}] Processing as a definitions file`);
@@ -58,6 +60,7 @@ function transformToString({
58
60
  // option allows the function to return void instead.
59
61
  return precompileFileForLocale(filename, result.locale, {
60
62
  format: IntlCompiledMessageFormat.KeylessJson,
63
+ bundleSecrets,
61
64
  });
62
65
  }
63
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discord/metro-intl-transformer",
3
- "version": "0.8.0",
3
+ "version": "0.9.0-rc.1",
4
4
  "license": "MIT",
5
5
  "description": "Metro/Babel transformer plugin for compiling, bundling, and minifying intl message definitions and usages using intl-message-database.",
6
6
  "exports": {
@@ -9,8 +9,8 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "debug": "^4.3.6",
12
- "@discord/babel-plugin-transform-discord-intl": "0.8.0",
13
- "@discord/intl-loader-core": "0.8.0"
12
+ "@discord/intl-loader-core": "0.9.0-rc.1",
13
+ "@discord/babel-plugin-transform-discord-intl": "0.9.0-rc.1"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/debug": "^4.1.12"