babel-plugin-formatjs 10.5.25 → 10.5.27
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/README.md +1 -1
- package/lib_esnext/index.d.ts +9 -0
- package/lib_esnext/index.js +67 -0
- package/lib_esnext/types.d.ts +30 -0
- package/lib_esnext/types.js +1 -0
- package/lib_esnext/utils.d.ts +33 -0
- package/lib_esnext/utils.js +143 -0
- package/lib_esnext/visitors/call-expression.d.ts +5 -0
- package/lib_esnext/visitors/call-expression.js +119 -0
- package/lib_esnext/visitors/jsx-opening-element.d.ts +5 -0
- package/lib_esnext/visitors/jsx-opening-element.js +82 -0
- package/package.json +3 -3
- package/utils.d.ts +1 -1
- package/utils.js +1 -1
- package/index.js.map +0 -1
- package/types.js.map +0 -1
- package/utils.js.map +0 -1
- package/visitors/call-expression.js.map +0 -1
- package/visitors/jsx-opening-element.js.map +0 -1
package/README.md
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PluginObj, PluginPass } from '@babel/core';
|
|
2
|
+
import { ExtractedMessageDescriptor, Options } from './types';
|
|
3
|
+
export type ExtractionResult<M = Record<string, string>> = {
|
|
4
|
+
messages: ExtractedMessageDescriptor[];
|
|
5
|
+
meta: M;
|
|
6
|
+
};
|
|
7
|
+
export declare const DEFAULT_ID_INTERPOLATION_PATTERN = "[sha512:contenthash:base64:6]";
|
|
8
|
+
declare const _default: (api: object, options: Options | null | undefined, dirname: string) => PluginObj<PluginPass>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { declare } from '@babel/helper-plugin-utils';
|
|
2
|
+
import babelPluginSyntaxJsx from '@babel/plugin-syntax-jsx';
|
|
3
|
+
import { visitor as JSXOpeningElement } from './visitors/jsx-opening-element';
|
|
4
|
+
import { visitor as CallExpression } from './visitors/call-expression';
|
|
5
|
+
export const DEFAULT_ID_INTERPOLATION_PATTERN = '[sha512:contenthash:base64:6]';
|
|
6
|
+
// @ts-expect-error PluginPass doesn't allow custom state but it actually does
|
|
7
|
+
export default declare((api, options) => {
|
|
8
|
+
api.assertVersion(7);
|
|
9
|
+
if (!options.idInterpolationPattern) {
|
|
10
|
+
options.idInterpolationPattern = DEFAULT_ID_INTERPOLATION_PATTERN;
|
|
11
|
+
}
|
|
12
|
+
const { pragma } = options;
|
|
13
|
+
const componentNames = new Set(options.additionalComponentNames);
|
|
14
|
+
componentNames.add('FormattedMessage');
|
|
15
|
+
const functionNames = new Set(options.additionalFunctionNames);
|
|
16
|
+
functionNames.add('formatMessage');
|
|
17
|
+
// Short hand
|
|
18
|
+
functionNames.add('$t');
|
|
19
|
+
// Vue
|
|
20
|
+
functionNames.add('$formatMessage');
|
|
21
|
+
return {
|
|
22
|
+
inherits: babelPluginSyntaxJsx,
|
|
23
|
+
pre() {
|
|
24
|
+
this.componentNames = Array.from(componentNames);
|
|
25
|
+
this.functionNames = Array.from(functionNames);
|
|
26
|
+
},
|
|
27
|
+
visitor: {
|
|
28
|
+
Program: {
|
|
29
|
+
enter(path) {
|
|
30
|
+
this.messages = [];
|
|
31
|
+
this.meta = {};
|
|
32
|
+
if (!pragma) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
for (const { leadingComments } of path.node.body) {
|
|
36
|
+
if (!leadingComments) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const pragmaLineNode = leadingComments.find(c => c.value.includes(pragma));
|
|
40
|
+
if (!pragmaLineNode) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
pragmaLineNode.value
|
|
44
|
+
.split(pragma)[1]
|
|
45
|
+
.trim()
|
|
46
|
+
.split(/\s+/g)
|
|
47
|
+
.forEach(kv => {
|
|
48
|
+
const [k, v] = kv.split(':');
|
|
49
|
+
this.meta[k] = v;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
exit(_, { opts: _opts, file: { opts: { filename }, }, }) {
|
|
54
|
+
const opts = _opts;
|
|
55
|
+
if (typeof opts?.onMetaExtracted === 'function') {
|
|
56
|
+
opts.onMetaExtracted(filename || '', this.meta);
|
|
57
|
+
}
|
|
58
|
+
if (typeof opts?.onMsgExtracted === 'function') {
|
|
59
|
+
opts.onMsgExtracted(filename || '', this.messages);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
JSXOpeningElement,
|
|
64
|
+
CallExpression,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { NodePath } from '@babel/core';
|
|
2
|
+
import { JSXExpressionContainer, SourceLocation, StringLiteral } from '@babel/types';
|
|
3
|
+
export interface MessageDescriptor {
|
|
4
|
+
id: string;
|
|
5
|
+
defaultMessage?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface State {
|
|
9
|
+
messages: ExtractedMessageDescriptor[];
|
|
10
|
+
meta: Record<string, string>;
|
|
11
|
+
componentNames: string[];
|
|
12
|
+
functionNames: string[];
|
|
13
|
+
}
|
|
14
|
+
export type ExtractedMessageDescriptor = MessageDescriptor & Partial<SourceLocation> & {
|
|
15
|
+
file?: string;
|
|
16
|
+
};
|
|
17
|
+
export type MessageDescriptorPath = Record<keyof MessageDescriptor, NodePath<StringLiteral> | NodePath<JSXExpressionContainer> | undefined>;
|
|
18
|
+
export interface Options {
|
|
19
|
+
overrideIdFn?: (id?: string, defaultMessage?: string, description?: string, filePath?: string) => string;
|
|
20
|
+
onMsgExtracted?: (filePath: string, msgs: MessageDescriptor[]) => void;
|
|
21
|
+
onMetaExtracted?: (filePath: string, meta: Record<string, string>) => void;
|
|
22
|
+
idInterpolationPattern?: string;
|
|
23
|
+
removeDefaultMessage?: boolean;
|
|
24
|
+
additionalComponentNames?: string[];
|
|
25
|
+
additionalFunctionNames?: string[];
|
|
26
|
+
pragma?: string;
|
|
27
|
+
extractSourceLocation?: boolean;
|
|
28
|
+
ast?: boolean;
|
|
29
|
+
preserveWhitespace?: boolean;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { NodePath } from '@babel/core';
|
|
3
|
+
import { ExtractedMessageDescriptor, MessageDescriptor, MessageDescriptorPath, Options } from './types';
|
|
4
|
+
export declare function getMessageDescriptorKey(path: NodePath<any>): string;
|
|
5
|
+
export declare function createMessageDescriptor(propPaths: [
|
|
6
|
+
NodePath<t.JSXIdentifier> | NodePath<t.Identifier>,
|
|
7
|
+
NodePath<t.StringLiteral> | NodePath<t.JSXExpressionContainer>
|
|
8
|
+
][]): MessageDescriptorPath;
|
|
9
|
+
export declare function evaluateMessageDescriptor(descriptorPath: MessageDescriptorPath, isJSXSource: boolean | undefined, filename: string | undefined, idInterpolationPattern?: string, overrideIdFn?: Options['overrideIdFn'], preserveWhitespace?: Options['preserveWhitespace']): MessageDescriptor;
|
|
10
|
+
/**
|
|
11
|
+
* Tag a node as extracted
|
|
12
|
+
* Store this in the node itself so that multiple passes work. Specifically
|
|
13
|
+
* if we remove `description` in the 1st pass, 2nd pass will fail since
|
|
14
|
+
* it expect `description` to be there.
|
|
15
|
+
* HACK: We store this in the node instance since this persists across
|
|
16
|
+
* multiple plugin runs
|
|
17
|
+
* @param path
|
|
18
|
+
*/
|
|
19
|
+
export declare function tagAsExtracted(path: NodePath<any>): void;
|
|
20
|
+
/**
|
|
21
|
+
* Check if a node was extracted
|
|
22
|
+
* @param path
|
|
23
|
+
*/
|
|
24
|
+
export declare function wasExtracted(path: NodePath<any>): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Store a message in our global messages
|
|
27
|
+
* @param messageDescriptor
|
|
28
|
+
* @param path
|
|
29
|
+
* @param opts
|
|
30
|
+
* @param filename
|
|
31
|
+
* @param messages
|
|
32
|
+
*/
|
|
33
|
+
export declare function storeMessage({ id, description, defaultMessage }: MessageDescriptor, path: NodePath<any>, { extractSourceLocation }: Options, filename: string | undefined, messages: ExtractedMessageDescriptor[]): void;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { parse } from '@formatjs/icu-messageformat-parser';
|
|
2
|
+
import { interpolateName } from '@formatjs/ts-transformer';
|
|
3
|
+
const DESCRIPTOR_PROPS = new Set([
|
|
4
|
+
'id',
|
|
5
|
+
'description',
|
|
6
|
+
'defaultMessage',
|
|
7
|
+
]);
|
|
8
|
+
function evaluatePath(path) {
|
|
9
|
+
const evaluated = path.evaluate();
|
|
10
|
+
if (evaluated.confident) {
|
|
11
|
+
return evaluated.value;
|
|
12
|
+
}
|
|
13
|
+
throw path.buildCodeFrameError('[React Intl] Messages must be statically evaluate-able for extraction.');
|
|
14
|
+
}
|
|
15
|
+
export function getMessageDescriptorKey(path) {
|
|
16
|
+
if (path.isIdentifier() || path.isJSXIdentifier()) {
|
|
17
|
+
return path.node.name;
|
|
18
|
+
}
|
|
19
|
+
return evaluatePath(path);
|
|
20
|
+
}
|
|
21
|
+
function getMessageDescriptorValue(path, isMessageNode) {
|
|
22
|
+
if (!path) {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
if (path.isJSXExpressionContainer()) {
|
|
26
|
+
// If this is already compiled, no need to recompiled it
|
|
27
|
+
if (isMessageNode && path.get('expression').isArrayExpression()) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
path = path.get('expression');
|
|
31
|
+
}
|
|
32
|
+
// Always trim the Message Descriptor values.
|
|
33
|
+
const descriptorValue = evaluatePath(path);
|
|
34
|
+
return descriptorValue;
|
|
35
|
+
}
|
|
36
|
+
export function createMessageDescriptor(propPaths) {
|
|
37
|
+
return propPaths.reduce((hash, [keyPath, valuePath]) => {
|
|
38
|
+
const key = getMessageDescriptorKey(keyPath);
|
|
39
|
+
if (DESCRIPTOR_PROPS.has(key)) {
|
|
40
|
+
hash[key] = valuePath;
|
|
41
|
+
}
|
|
42
|
+
return hash;
|
|
43
|
+
}, {
|
|
44
|
+
id: undefined,
|
|
45
|
+
defaultMessage: undefined,
|
|
46
|
+
description: undefined,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export function evaluateMessageDescriptor(descriptorPath, isJSXSource = false, filename, idInterpolationPattern, overrideIdFn, preserveWhitespace) {
|
|
50
|
+
let id = getMessageDescriptorValue(descriptorPath.id);
|
|
51
|
+
const defaultMessage = getICUMessageValue(descriptorPath.defaultMessage, {
|
|
52
|
+
isJSXSource,
|
|
53
|
+
}, preserveWhitespace);
|
|
54
|
+
const description = getMessageDescriptorValue(descriptorPath.description);
|
|
55
|
+
if (overrideIdFn) {
|
|
56
|
+
id = overrideIdFn(id, defaultMessage, description, filename);
|
|
57
|
+
}
|
|
58
|
+
else if (!id && idInterpolationPattern && defaultMessage) {
|
|
59
|
+
id = interpolateName({ resourcePath: filename }, idInterpolationPattern, {
|
|
60
|
+
content: description
|
|
61
|
+
? `${defaultMessage}#${description}`
|
|
62
|
+
: defaultMessage,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const descriptor = {
|
|
66
|
+
id,
|
|
67
|
+
};
|
|
68
|
+
if (description) {
|
|
69
|
+
descriptor.description = description;
|
|
70
|
+
}
|
|
71
|
+
if (defaultMessage) {
|
|
72
|
+
descriptor.defaultMessage = defaultMessage;
|
|
73
|
+
}
|
|
74
|
+
return descriptor;
|
|
75
|
+
}
|
|
76
|
+
function getICUMessageValue(messagePath, { isJSXSource = false } = {}, preserveWhitespace) {
|
|
77
|
+
if (!messagePath) {
|
|
78
|
+
return '';
|
|
79
|
+
}
|
|
80
|
+
let message = getMessageDescriptorValue(messagePath, true);
|
|
81
|
+
if (!preserveWhitespace) {
|
|
82
|
+
message = message.trim().replace(/\s+/gm, ' ');
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
parse(message);
|
|
86
|
+
}
|
|
87
|
+
catch (parseError) {
|
|
88
|
+
if (isJSXSource &&
|
|
89
|
+
messagePath.isLiteral() &&
|
|
90
|
+
message.indexOf('\\\\') >= 0) {
|
|
91
|
+
throw messagePath.buildCodeFrameError('[React Intl] Message failed to parse. ' +
|
|
92
|
+
'It looks like `\\`s were used for escaping, ' +
|
|
93
|
+
"this won't work with JSX string literals. " +
|
|
94
|
+
'Wrap with `{}`. ' +
|
|
95
|
+
'See: http://facebook.github.io/react/docs/jsx-gotchas.html');
|
|
96
|
+
}
|
|
97
|
+
throw messagePath.buildCodeFrameError('[React Intl] Message failed to parse. ' +
|
|
98
|
+
'See: https://formatjs.github.io/docs/core-concepts/icu-syntax' +
|
|
99
|
+
`\n${parseError}`);
|
|
100
|
+
}
|
|
101
|
+
return message;
|
|
102
|
+
}
|
|
103
|
+
const EXTRACTED = Symbol('FormatJSExtracted');
|
|
104
|
+
/**
|
|
105
|
+
* Tag a node as extracted
|
|
106
|
+
* Store this in the node itself so that multiple passes work. Specifically
|
|
107
|
+
* if we remove `description` in the 1st pass, 2nd pass will fail since
|
|
108
|
+
* it expect `description` to be there.
|
|
109
|
+
* HACK: We store this in the node instance since this persists across
|
|
110
|
+
* multiple plugin runs
|
|
111
|
+
* @param path
|
|
112
|
+
*/
|
|
113
|
+
export function tagAsExtracted(path) {
|
|
114
|
+
path.node[EXTRACTED] = true;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Check if a node was extracted
|
|
118
|
+
* @param path
|
|
119
|
+
*/
|
|
120
|
+
export function wasExtracted(path) {
|
|
121
|
+
return !!path.node[EXTRACTED];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Store a message in our global messages
|
|
125
|
+
* @param messageDescriptor
|
|
126
|
+
* @param path
|
|
127
|
+
* @param opts
|
|
128
|
+
* @param filename
|
|
129
|
+
* @param messages
|
|
130
|
+
*/
|
|
131
|
+
export function storeMessage({ id, description, defaultMessage }, path, { extractSourceLocation }, filename, messages) {
|
|
132
|
+
if (!id && !defaultMessage) {
|
|
133
|
+
throw path.buildCodeFrameError('[React Intl] Message Descriptors require an `id` or `defaultMessage`.');
|
|
134
|
+
}
|
|
135
|
+
let loc = {};
|
|
136
|
+
if (extractSourceLocation) {
|
|
137
|
+
loc = {
|
|
138
|
+
file: filename,
|
|
139
|
+
...path.node.loc,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
messages.push({ id, description, defaultMessage, ...loc });
|
|
143
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { createMessageDescriptor, evaluateMessageDescriptor, wasExtracted, storeMessage, tagAsExtracted, } from '../utils';
|
|
3
|
+
import { parse } from '@formatjs/icu-messageformat-parser';
|
|
4
|
+
function assertObjectExpression(path, callee) {
|
|
5
|
+
if (!path || !path.isObjectExpression()) {
|
|
6
|
+
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.`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function isFormatMessageCall(callee, functionNames) {
|
|
10
|
+
if (functionNames.find(name => callee.isIdentifier({ name }))) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (callee.isMemberExpression()) {
|
|
14
|
+
const property = callee.get('property');
|
|
15
|
+
return !!functionNames.find(name => property.isIdentifier({ name }));
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
function getMessagesObjectFromExpression(nodePath) {
|
|
20
|
+
let currentPath = nodePath;
|
|
21
|
+
while (t.isTSAsExpression(currentPath.node) ||
|
|
22
|
+
t.isTSTypeAssertion(currentPath.node) ||
|
|
23
|
+
t.isTypeCastExpression(currentPath.node)) {
|
|
24
|
+
currentPath = currentPath.get('expression');
|
|
25
|
+
}
|
|
26
|
+
return currentPath;
|
|
27
|
+
}
|
|
28
|
+
export const visitor = function (path, { opts, file: { opts: { filename }, }, }) {
|
|
29
|
+
const { overrideIdFn, idInterpolationPattern, removeDefaultMessage, ast, preserveWhitespace, } = opts;
|
|
30
|
+
if (wasExtracted(path)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const { messages, functionNames } = this;
|
|
34
|
+
const callee = path.get('callee');
|
|
35
|
+
const args = path.get('arguments');
|
|
36
|
+
/**
|
|
37
|
+
* Process MessageDescriptor
|
|
38
|
+
* @param messageDescriptor Message Descriptor
|
|
39
|
+
*/
|
|
40
|
+
function processMessageObject(messageDescriptor) {
|
|
41
|
+
assertObjectExpression(messageDescriptor, callee);
|
|
42
|
+
const properties = messageDescriptor.get('properties');
|
|
43
|
+
const descriptorPath = createMessageDescriptor(properties.map(prop => [prop.get('key'), prop.get('value')]));
|
|
44
|
+
// If the message is already compiled, don't re-compile it
|
|
45
|
+
if (descriptorPath.defaultMessage?.isArrayExpression()) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// Evaluate the Message Descriptor values, then store it.
|
|
49
|
+
const descriptor = evaluateMessageDescriptor(descriptorPath, false, filename || undefined, idInterpolationPattern, overrideIdFn, preserveWhitespace);
|
|
50
|
+
storeMessage(descriptor, messageDescriptor, opts, filename || undefined, messages);
|
|
51
|
+
const firstProp = properties[0];
|
|
52
|
+
const defaultMessageProp = properties.find(prop => {
|
|
53
|
+
const keyProp = prop.get('key');
|
|
54
|
+
return (keyProp.isIdentifier({ name: 'defaultMessage' }) ||
|
|
55
|
+
keyProp.isStringLiteral({ value: 'defaultMessage' }));
|
|
56
|
+
});
|
|
57
|
+
const idProp = properties.find(prop => {
|
|
58
|
+
const keyProp = prop.get('key');
|
|
59
|
+
return (keyProp.isIdentifier({ name: 'id' }) ||
|
|
60
|
+
keyProp.isStringLiteral({ value: 'id' }));
|
|
61
|
+
});
|
|
62
|
+
// Insert ID potentially 1st before removing nodes
|
|
63
|
+
if (idProp) {
|
|
64
|
+
idProp.get('value').replaceWith(t.stringLiteral(descriptor.id));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
firstProp.insertBefore(t.objectProperty(t.identifier('id'), t.stringLiteral(descriptor.id)));
|
|
68
|
+
}
|
|
69
|
+
// Remove description
|
|
70
|
+
properties
|
|
71
|
+
.find(prop => {
|
|
72
|
+
const keyProp = prop.get('key');
|
|
73
|
+
return (keyProp.isIdentifier({ name: 'description' }) ||
|
|
74
|
+
keyProp.isStringLiteral({ value: 'description' }));
|
|
75
|
+
})
|
|
76
|
+
?.remove();
|
|
77
|
+
// Pre-parse or remove defaultMessage
|
|
78
|
+
if (defaultMessageProp) {
|
|
79
|
+
if (removeDefaultMessage) {
|
|
80
|
+
defaultMessageProp?.remove();
|
|
81
|
+
}
|
|
82
|
+
else if (descriptor.defaultMessage) {
|
|
83
|
+
const valueProp = defaultMessageProp.get('value');
|
|
84
|
+
if (ast) {
|
|
85
|
+
valueProp.replaceWithSourceString(JSON.stringify(parse(descriptor.defaultMessage)));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
valueProp.replaceWith(t.stringLiteral(descriptor.defaultMessage));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
tagAsExtracted(path);
|
|
93
|
+
}
|
|
94
|
+
// Check that this is `defineMessages` call
|
|
95
|
+
if (callee.isIdentifier({ name: 'defineMessages' }) ||
|
|
96
|
+
callee.isIdentifier({ name: 'defineMessage' })) {
|
|
97
|
+
const firstArgument = args[0];
|
|
98
|
+
const messagesObj = getMessagesObjectFromExpression(firstArgument);
|
|
99
|
+
assertObjectExpression(messagesObj, callee);
|
|
100
|
+
if (callee.isIdentifier({ name: 'defineMessage' })) {
|
|
101
|
+
processMessageObject(messagesObj);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const properties = messagesObj.get('properties');
|
|
105
|
+
if (Array.isArray(properties)) {
|
|
106
|
+
properties
|
|
107
|
+
.map(prop => prop.get('value'))
|
|
108
|
+
.forEach(processMessageObject);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Check that this is `intl.formatMessage` call
|
|
113
|
+
if (isFormatMessageCall(callee, functionNames)) {
|
|
114
|
+
const messageDescriptor = args[0];
|
|
115
|
+
if (messageDescriptor && messageDescriptor.isObjectExpression()) {
|
|
116
|
+
processMessageObject(messageDescriptor);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { parse } from '@formatjs/icu-messageformat-parser';
|
|
3
|
+
import { createMessageDescriptor, evaluateMessageDescriptor, getMessageDescriptorKey, storeMessage, tagAsExtracted, wasExtracted, } from '../utils';
|
|
4
|
+
export const visitor = function (path, { opts, file: { opts: { filename }, }, }) {
|
|
5
|
+
const { removeDefaultMessage, idInterpolationPattern, overrideIdFn, ast, preserveWhitespace, } = opts;
|
|
6
|
+
const { componentNames, messages } = this;
|
|
7
|
+
if (wasExtracted(path)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const name = path.get('name');
|
|
11
|
+
if (!componentNames.find(n => name.isJSXIdentifier({ name: n }))) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const attributes = path
|
|
15
|
+
.get('attributes')
|
|
16
|
+
.filter(attr => attr.isJSXAttribute());
|
|
17
|
+
const descriptorPath = createMessageDescriptor(attributes.map(attr => [
|
|
18
|
+
attr.get('name'),
|
|
19
|
+
attr.get('value'),
|
|
20
|
+
]));
|
|
21
|
+
// In order for a default message to be extracted when
|
|
22
|
+
// declaring a JSX element, it must be done with standard
|
|
23
|
+
// `key=value` attributes. But it's completely valid to
|
|
24
|
+
// write `<FormattedMessage {...descriptor} />`, because it will be
|
|
25
|
+
// skipped here and extracted elsewhere. The descriptor will
|
|
26
|
+
// be extracted only (storeMessage) if a `defaultMessage` prop.
|
|
27
|
+
if (!descriptorPath.defaultMessage) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// Evaluate the Message Descriptor values in a JSX
|
|
31
|
+
// context, then store it.
|
|
32
|
+
const descriptor = evaluateMessageDescriptor(descriptorPath, true, filename || undefined, idInterpolationPattern, overrideIdFn, preserveWhitespace);
|
|
33
|
+
storeMessage(descriptor, path, opts, filename || undefined, messages);
|
|
34
|
+
let idAttr;
|
|
35
|
+
let descriptionAttr;
|
|
36
|
+
let defaultMessageAttr;
|
|
37
|
+
const firstAttr = attributes[0];
|
|
38
|
+
for (const attr of attributes) {
|
|
39
|
+
if (!attr.isJSXAttribute()) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
switch (getMessageDescriptorKey(attr.get('name'))) {
|
|
43
|
+
case 'description':
|
|
44
|
+
descriptionAttr = attr;
|
|
45
|
+
break;
|
|
46
|
+
case 'defaultMessage':
|
|
47
|
+
defaultMessageAttr = attr;
|
|
48
|
+
break;
|
|
49
|
+
case 'id':
|
|
50
|
+
idAttr = attr;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Insert ID before removing node to prevent null node insertBefore
|
|
55
|
+
if (overrideIdFn || (descriptor.id && idInterpolationPattern)) {
|
|
56
|
+
if (idAttr) {
|
|
57
|
+
idAttr.get('value').replaceWith(t.stringLiteral(descriptor.id));
|
|
58
|
+
}
|
|
59
|
+
else if (firstAttr) {
|
|
60
|
+
firstAttr.insertBefore(t.jsxAttribute(t.jsxIdentifier('id'), t.stringLiteral(descriptor.id)));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (descriptionAttr) {
|
|
64
|
+
descriptionAttr.remove();
|
|
65
|
+
}
|
|
66
|
+
if (defaultMessageAttr) {
|
|
67
|
+
if (removeDefaultMessage) {
|
|
68
|
+
defaultMessageAttr.remove();
|
|
69
|
+
}
|
|
70
|
+
else if (ast && descriptor.defaultMessage) {
|
|
71
|
+
defaultMessageAttr
|
|
72
|
+
.get('value')
|
|
73
|
+
.replaceWith(t.jsxExpressionContainer(t.nullLiteral()));
|
|
74
|
+
const valueAttr = defaultMessageAttr.get('value');
|
|
75
|
+
valueAttr
|
|
76
|
+
.get('expression')
|
|
77
|
+
.replaceWithSourceString(JSON.stringify(parse(descriptor.defaultMessage)));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Tag the AST node so we don't try to extract it twice.
|
|
81
|
+
tagAsExtracted(path);
|
|
82
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-formatjs",
|
|
3
|
-
"version": "10.5.
|
|
3
|
+
"version": "10.5.27",
|
|
4
4
|
"description": "Extracts string messages for translation from modules that use formatjs.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"@types/babel__helper-plugin-utils": "^7.10.3",
|
|
21
21
|
"@types/babel__traverse": "^7.20.6",
|
|
22
22
|
"tslib": "2",
|
|
23
|
-
"@formatjs/icu-messageformat-parser": "2.9.
|
|
24
|
-
"@formatjs/ts-transformer": "3.13.
|
|
23
|
+
"@formatjs/icu-messageformat-parser": "2.9.5",
|
|
24
|
+
"@formatjs/ts-transformer": "3.13.24"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
27
27
|
"babel-plugin",
|
package/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from '@babel/types';
|
|
2
|
-
import { Options, ExtractedMessageDescriptor, MessageDescriptor, MessageDescriptorPath } from './types';
|
|
3
2
|
import { NodePath } from '@babel/core';
|
|
3
|
+
import { ExtractedMessageDescriptor, MessageDescriptor, MessageDescriptorPath, Options } from './types';
|
|
4
4
|
export declare function getMessageDescriptorKey(path: NodePath<any>): string;
|
|
5
5
|
export declare function createMessageDescriptor(propPaths: [
|
|
6
6
|
NodePath<t.JSXIdentifier> | NodePath<t.Identifier>,
|
package/utils.js
CHANGED
|
@@ -103,7 +103,7 @@ function getICUMessageValue(messagePath, { isJSXSource = false } = {}, preserveW
|
|
|
103
103
|
'See: http://facebook.github.io/react/docs/jsx-gotchas.html');
|
|
104
104
|
}
|
|
105
105
|
throw messagePath.buildCodeFrameError('[React Intl] Message failed to parse. ' +
|
|
106
|
-
'See: https://formatjs.io/docs/core-concepts/icu-syntax' +
|
|
106
|
+
'See: https://formatjs.github.io/docs/core-concepts/icu-syntax' +
|
|
107
107
|
`\n${parseError}`);
|
|
108
108
|
}
|
|
109
109
|
return message;
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;AAAA,oEAAkD;AAElD,yFAA2D;AAE3D,wEAA2E;AAC3E,gEAAoE;AAOvD,QAAA,gCAAgC,GAAG,+BAA+B,CAAA;AAE/E,8EAA8E;AAC9E,kBAAe,IAAA,6BAAO,EAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;IAC1D,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAA;IACpB,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC;QACpC,OAAO,CAAC,sBAAsB,GAAG,wCAAgC,CAAA;IACnE,CAAC;IAED,MAAM,EAAC,MAAM,EAAC,GAAG,OAAO,CAAA;IACxB,MAAM,cAAc,GAAG,IAAI,GAAG,CAAS,OAAO,CAAC,wBAAwB,CAAC,CAAA;IACxE,cAAc,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IACtC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAS,OAAO,CAAC,uBAAuB,CAAC,CAAA;IACtE,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IAClC,aAAa;IACb,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACvB,MAAM;IACN,aAAa,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;IACnC,OAAO;QACL,QAAQ,EAAE,2BAAoB;QAC9B,GAAG;YACD,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,I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U,EAAE,CAAC;wBAChD,IAAI,CAAC,eAAe,CAAC,QAAQ,IAAI,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;oBACjD,CAAC;oBACD,IAAI,OAAO,IAAI,EAAE,cAAc,KAAK,UAAU,EAAE,CAAC;wBAC/C,IAAI,CAAC,cAAc,CAAC,QAAQ,IAAI,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;oBACpD,CAAC;gBACH,CAAC;aACF;YACD,iBAAiB,EAAjB,6BAAiB;YACjB,cAAc,EAAd,yBAAc;SACf;KACF,CAAA;AACH,CAAC,CAAC,CAAA"}
|
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":""}
|
package/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":";;AA6BA,0DAMC;AA0BD,0DAwBC;AAED,8DA2CC;AAsDD,wCAEC;AAKD,oCAEC;AAUD,oCAsBC;AAhOD,iFAAwD;AACxD,6DAAwD;AAUxD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAA8B;IAC5D,IAAI;IACJ,aAAa;IACb,gBAAgB;CACjB,CAAC,CAAA;AAEF,SAAS,YAAY,CAAC,IAAmB;IACvC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;IACjC,IAAI,SAAS,CAAC,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC,KAAK,CAAA;IACxB,CAAC;IAED,MAAM,IAAI,CAAC,mBAAmB,CAC5B,wEAAwE,CACzE,CAAA;AACH,CAAC;AAED,SAAgB,uBAAuB,CAAC,IAAmB;IACzD,IAAI,IAAI,CAAC,YAAY,EAAE,IAAI,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;I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