@discord/metro-intl-transformer 0.21.1 → 0.22.0-rc.0

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
@@ -138,7 +138,7 @@ async function transformAsset(assetData) {
138
138
  debug('Initializing database with all messages files within watch folders: %O', watchFolders);
139
139
  const result = processAllMessagesFiles(findAllMessagesFiles(watchFolders));
140
140
  debug('Finished processing all discovered messages files: %O', result);
141
- hasInitializedAllDefinitions = true;
141
+ hasInitializedAllDefinitions = result.flatMap((result) => result.errors).length === 0;
142
142
  }
143
143
 
144
144
  const filename = assetData.files[0] ?? '';
@@ -171,6 +171,10 @@ async function transformAsset(assetData) {
171
171
  debug(`[${filename}] ${metroConfig.transformer?.publicPath}`);
172
172
 
173
173
  const result = processTranslationsFile(filename);
174
+ if (!result.succeeded) {
175
+ throw new Error('Intl processing error:' + result.errors[0]);
176
+ }
177
+
174
178
  debug(`[${filename}] precompiling file`);
175
179
  precompileFileForLocale(filename, result.locale, outputFile, {
176
180
  format,
package/index.js CHANGED
@@ -37,6 +37,9 @@ function transformToString({
37
37
  if (isMessageDefinitionsFile(filename)) {
38
38
  debug(`[${filename}] Processing as a definitions file`);
39
39
  const result = processDefinitionsFile(filename, src, { locale: sourceLocale });
40
+ if (!result.succeeded) {
41
+ throw new Error('Intl processing error in ' + filename + ': ' + result.errors[0].message);
42
+ }
40
43
  const compiledSourcePath = filename.replace(
41
44
  /\.messages\.js$/,
42
45
  `.compiled.messages.${getTranslationAssetExtension()}`,
@@ -60,6 +63,9 @@ function transformToString({
60
63
  } else if (isMessageTranslationsFile(filename)) {
61
64
  debug(`[${filename}] Processing as a translations file`);
62
65
  const result = processTranslationsFile(filename, src);
66
+ if (!result.succeeded) {
67
+ throw new Error('Intl processing error in ' + filename + ': ' + result.errors[0]);
68
+ }
63
69
  // @ts-expect-error Without the `outputFile` option, this always returns a Buffer, but the
64
70
  // option allows the function to return void instead.
65
71
  return precompileFileForLocale(filename, result.locale, undefined, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discord/metro-intl-transformer",
3
- "version": "0.21.1",
3
+ "version": "0.22.0-rc.0",
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": {
@@ -14,8 +14,8 @@
14
14
  "dependencies": {
15
15
  "debug": "^4.3.6",
16
16
  "metro-config": "^0.81.0",
17
- "@discord/babel-plugin-transform-discord-intl": "0.21.1",
18
- "@discord/intl-loader-core": "0.21.1"
17
+ "@discord/babel-plugin-transform-discord-intl": "0.22.0-rc.0",
18
+ "@discord/intl-loader-core": "0.22.0-rc.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/debug": "^4.1.12"