babel-plugin-formatjs 10.3.8 → 10.3.12

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/index.js CHANGED
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_ID_INTERPOLATION_PATTERN = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var helper_plugin_utils_1 = require("@babel/helper-plugin-utils");
6
- var plugin_syntax_jsx_1 = tslib_1.__importDefault(require("@babel/plugin-syntax-jsx"));
6
+ var plugin_syntax_jsx_1 = (0, tslib_1.__importDefault)(require("@babel/plugin-syntax-jsx"));
7
7
  var jsx_opening_element_1 = require("./visitors/jsx-opening-element");
8
8
  var call_expression_1 = require("./visitors/call-expression");
9
9
  exports.DEFAULT_ID_INTERPOLATION_PATTERN = '[sha512:contenthash:base64:6]';
10
10
  // @ts-expect-error PluginPass doesn't allow custom state but it actually does
11
- exports.default = helper_plugin_utils_1.declare(function (api, options) {
11
+ exports.default = (0, helper_plugin_utils_1.declare)(function (api, options) {
12
12
  api.assertVersion(7);
13
13
  if (!options.idInterpolationPattern) {
14
14
  options.idInterpolationPattern = exports.DEFAULT_ID_INTERPOLATION_PATTERN;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-formatjs",
3
- "version": "10.3.8",
3
+ "version": "10.3.12",
4
4
  "description": "Extracts string messages for translation from modules that use formatjs.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,8 +16,8 @@
16
16
  "@babel/plugin-syntax-jsx": "7",
17
17
  "@babel/traverse": "7",
18
18
  "@babel/types": "^7.12.11",
19
- "@formatjs/icu-messageformat-parser": "2.0.11",
20
- "@formatjs/ts-transformer": "3.4.10",
19
+ "@formatjs/icu-messageformat-parser": "2.0.15",
20
+ "@formatjs/ts-transformer": "3.7.0",
21
21
  "@types/babel__core": "^7.1.7",
22
22
  "@types/babel__helper-plugin-utils": "^7.10.0",
23
23
  "tslib": "^2.1.0"
package/utils.js CHANGED
@@ -64,9 +64,9 @@ function evaluateMessageDescriptor(descriptorPath, isJSXSource, filename, idInte
64
64
  id = overrideIdFn(id, defaultMessage, description, filename);
65
65
  }
66
66
  else if (!id && idInterpolationPattern && defaultMessage) {
67
- id = ts_transformer_1.interpolateName({ resourcePath: filename }, idInterpolationPattern, {
67
+ id = (0, ts_transformer_1.interpolateName)({ resourcePath: filename }, idInterpolationPattern, {
68
68
  content: description
69
- ? defaultMessage + "#" + description
69
+ ? "".concat(defaultMessage, "#").concat(description)
70
70
  : defaultMessage,
71
71
  });
72
72
  }
@@ -92,7 +92,7 @@ function getICUMessageValue(messagePath, _a, preserveWhitespace) {
92
92
  message = message.trim().replace(/\s+/gm, ' ');
93
93
  }
94
94
  try {
95
- icu_messageformat_parser_1.parse(message);
95
+ (0, icu_messageformat_parser_1.parse)(message);
96
96
  }
97
97
  catch (parseError) {
98
98
  if (isJSXSource &&
@@ -106,7 +106,7 @@ function getICUMessageValue(messagePath, _a, preserveWhitespace) {
106
106
  }
107
107
  throw messagePath.buildCodeFrameError('[React Intl] Message failed to parse. ' +
108
108
  'See: https://formatjs.io/docs/core-concepts/icu-syntax' +
109
- ("\n" + parseError));
109
+ "\n".concat(parseError));
110
110
  }
111
111
  return message;
112
112
  }
@@ -148,8 +148,8 @@ function storeMessage(_a, path, _b, filename, messages) {
148
148
  }
149
149
  var loc = {};
150
150
  if (extractSourceLocation) {
151
- loc = tslib_1.__assign({ file: filename }, path.node.loc);
151
+ loc = (0, tslib_1.__assign)({ file: filename }, path.node.loc);
152
152
  }
153
- messages.push(tslib_1.__assign({ id: id, description: description, defaultMessage: defaultMessage }, loc));
153
+ messages.push((0, tslib_1.__assign)({ id: id, description: description, defaultMessage: defaultMessage }, loc));
154
154
  }
155
155
  exports.storeMessage = storeMessage;
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.visitor = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var t = tslib_1.__importStar(require("@babel/types"));
5
+ var t = (0, tslib_1.__importStar)(require("@babel/types"));
6
6
  var utils_1 = require("../utils");
7
7
  var icu_messageformat_parser_1 = require("@formatjs/icu-messageformat-parser");
8
8
  function assertObjectExpression(path, callee) {
9
9
  if (!path || !path.isObjectExpression()) {
10
- throw path.buildCodeFrameError("[React Intl] `" + callee.get('property').node.name + "()` must be called with an object expression with values that are React Intl Message Descriptors, also defined as object expressions.");
10
+ throw path.buildCodeFrameError("[React Intl] `".concat(callee.get('property').node.name, "()` must be called with an object expression with values that are React Intl Message Descriptors, also defined as object expressions."));
11
11
  }
12
12
  }
13
13
  function isFormatMessageCall(callee, functionNames) {
@@ -32,7 +32,7 @@ function getMessagesObjectFromExpression(nodePath) {
32
32
  var visitor = function (path, _a) {
33
33
  var opts = _a.opts, filename = _a.file.opts.filename;
34
34
  var _b = opts, overrideIdFn = _b.overrideIdFn, idInterpolationPattern = _b.idInterpolationPattern, removeDefaultMessage = _b.removeDefaultMessage, ast = _b.ast, preserveWhitespace = _b.preserveWhitespace;
35
- if (utils_1.wasExtracted(path)) {
35
+ if ((0, utils_1.wasExtracted)(path)) {
36
36
  return;
37
37
  }
38
38
  var _c = this, messages = _c.messages, functionNames = _c.functionNames;
@@ -46,7 +46,7 @@ var visitor = function (path, _a) {
46
46
  var _a, _b;
47
47
  assertObjectExpression(messageDescriptor, callee);
48
48
  var properties = messageDescriptor.get('properties');
49
- var descriptorPath = utils_1.createMessageDescriptor(properties.map(function (prop) {
49
+ var descriptorPath = (0, utils_1.createMessageDescriptor)(properties.map(function (prop) {
50
50
  return [prop.get('key'), prop.get('value')];
51
51
  }));
52
52
  // If the message is already compiled, don't re-compile it
@@ -54,8 +54,8 @@ var visitor = function (path, _a) {
54
54
  return;
55
55
  }
56
56
  // Evaluate the Message Descriptor values, then store it.
57
- var descriptor = utils_1.evaluateMessageDescriptor(descriptorPath, false, filename || undefined, idInterpolationPattern, overrideIdFn, preserveWhitespace);
58
- utils_1.storeMessage(descriptor, messageDescriptor, opts, filename || undefined, messages);
57
+ var descriptor = (0, utils_1.evaluateMessageDescriptor)(descriptorPath, false, filename || undefined, idInterpolationPattern, overrideIdFn, preserveWhitespace);
58
+ (0, utils_1.storeMessage)(descriptor, messageDescriptor, opts, filename || undefined, messages);
59
59
  var firstProp = properties[0];
60
60
  var defaultMessageProp = properties.find(function (prop) {
61
61
  var keyProp = prop.get('key');
@@ -89,14 +89,14 @@ var visitor = function (path, _a) {
89
89
  else if (descriptor.defaultMessage) {
90
90
  var valueProp = defaultMessageProp.get('value');
91
91
  if (ast) {
92
- valueProp.replaceWithSourceString(JSON.stringify(icu_messageformat_parser_1.parse(descriptor.defaultMessage)));
92
+ valueProp.replaceWithSourceString(JSON.stringify((0, icu_messageformat_parser_1.parse)(descriptor.defaultMessage)));
93
93
  }
94
94
  else {
95
95
  valueProp.replaceWith(t.stringLiteral(descriptor.defaultMessage));
96
96
  }
97
97
  }
98
98
  }
99
- utils_1.tagAsExtracted(path);
99
+ (0, utils_1.tagAsExtracted)(path);
100
100
  }
101
101
  // Check that this is `defineMessages` call
102
102
  if (callee.isIdentifier({ name: 'defineMessages' }) ||
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.visitor = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var t = tslib_1.__importStar(require("@babel/types"));
5
+ var t = (0, tslib_1.__importStar)(require("@babel/types"));
6
6
  var icu_messageformat_parser_1 = require("@formatjs/icu-messageformat-parser");
7
7
  var utils_1 = require("../utils");
8
8
  var visitor = function (path, _a) {
9
9
  var opts = _a.opts, filename = _a.file.opts.filename;
10
10
  var _b = opts, removeDefaultMessage = _b.removeDefaultMessage, idInterpolationPattern = _b.idInterpolationPattern, overrideIdFn = _b.overrideIdFn, ast = _b.ast, preserveWhitespace = _b.preserveWhitespace;
11
11
  var _c = this, componentNames = _c.componentNames, messages = _c.messages;
12
- if (utils_1.wasExtracted(path)) {
12
+ if ((0, utils_1.wasExtracted)(path)) {
13
13
  return;
14
14
  }
15
15
  var name = path.get('name');
@@ -19,7 +19,7 @@ var visitor = function (path, _a) {
19
19
  var attributes = path
20
20
  .get('attributes')
21
21
  .filter(function (attr) { return attr.isJSXAttribute(); });
22
- var descriptorPath = utils_1.createMessageDescriptor(attributes.map(function (attr) { return [
22
+ var descriptorPath = (0, utils_1.createMessageDescriptor)(attributes.map(function (attr) { return [
23
23
  attr.get('name'),
24
24
  attr.get('value'),
25
25
  ]; }));
@@ -34,8 +34,8 @@ var visitor = function (path, _a) {
34
34
  }
35
35
  // Evaluate the Message Descriptor values in a JSX
36
36
  // context, then store it.
37
- var descriptor = utils_1.evaluateMessageDescriptor(descriptorPath, true, filename || undefined, idInterpolationPattern, overrideIdFn, preserveWhitespace);
38
- utils_1.storeMessage(descriptor, path, opts, filename || undefined, messages);
37
+ var descriptor = (0, utils_1.evaluateMessageDescriptor)(descriptorPath, true, filename || undefined, idInterpolationPattern, overrideIdFn, preserveWhitespace);
38
+ (0, utils_1.storeMessage)(descriptor, path, opts, filename || undefined, messages);
39
39
  var idAttr;
40
40
  var descriptionAttr;
41
41
  var defaultMessageAttr;
@@ -45,7 +45,7 @@ var visitor = function (path, _a) {
45
45
  if (!attr.isJSXAttribute()) {
46
46
  continue;
47
47
  }
48
- switch (utils_1.getMessageDescriptorKey(attr.get('name'))) {
48
+ switch ((0, utils_1.getMessageDescriptorKey)(attr.get('name'))) {
49
49
  case 'description':
50
50
  descriptionAttr = attr;
51
51
  break;
@@ -80,10 +80,10 @@ var visitor = function (path, _a) {
80
80
  var valueAttr = defaultMessageAttr.get('value');
81
81
  valueAttr
82
82
  .get('expression')
83
- .replaceWithSourceString(JSON.stringify(icu_messageformat_parser_1.parse(descriptor.defaultMessage)));
83
+ .replaceWithSourceString(JSON.stringify((0, icu_messageformat_parser_1.parse)(descriptor.defaultMessage)));
84
84
  }
85
85
  }
86
86
  // Tag the AST node so we don't try to extract it twice.
87
- utils_1.tagAsExtracted(path);
87
+ (0, utils_1.tagAsExtracted)(path);
88
88
  };
89
89
  exports.visitor = visitor;