@formatjs/cli-lib 6.3.7 → 6.3.8
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/package.json +3 -3
- package/src/vue_extractor.js +13 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/cli-lib",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.8",
|
|
4
4
|
"description": "Lib for CLI for formatjs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@formatjs/icu-messageformat-parser": "2.7.6"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@vue/compiler-core": "^3.
|
|
51
|
-
"vue": "^3.
|
|
50
|
+
"@vue/compiler-core": "^3.4.0",
|
|
51
|
+
"vue": "^3.4.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"vue": {
|
package/src/vue_extractor.js
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseFile = void 0;
|
|
4
|
+
const compiler_core_1 = require("@vue/compiler-core");
|
|
4
5
|
const compiler_sfc_1 = require("vue/compiler-sfc");
|
|
5
|
-
// Duplicate `NodeTypes` here because they are defined as
|
|
6
|
-
// const enum, which does not work with swc transpilation: https://github.com/vuejs/core/issues/1228
|
|
7
|
-
const ELEMENT = 1;
|
|
8
|
-
const SIMPLE_EXPRESSION = 4;
|
|
9
|
-
const INTERPOLATION = 5;
|
|
10
|
-
const DIRECTIVE = 7;
|
|
11
|
-
const COMPOUND_EXPRESSION = 8;
|
|
12
6
|
function walk(node, visitor) {
|
|
13
|
-
if (typeof node !== 'object') {
|
|
7
|
+
if (typeof node !== 'object' || node == null) {
|
|
14
8
|
return;
|
|
15
9
|
}
|
|
16
|
-
if (node.type
|
|
17
|
-
node.
|
|
18
|
-
|
|
10
|
+
if (node.type === compiler_core_1.NodeTypes.ROOT) {
|
|
11
|
+
node.children.forEach(n => walk(n, visitor));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (node.type !== compiler_core_1.NodeTypes.ELEMENT &&
|
|
15
|
+
node.type !== compiler_core_1.NodeTypes.COMPOUND_EXPRESSION &&
|
|
16
|
+
node.type !== compiler_core_1.NodeTypes.INTERPOLATION) {
|
|
19
17
|
return;
|
|
20
18
|
}
|
|
21
19
|
visitor(node);
|
|
22
|
-
if (node.type === INTERPOLATION) {
|
|
20
|
+
if (node.type === compiler_core_1.NodeTypes.INTERPOLATION) {
|
|
23
21
|
visitor(node.content);
|
|
24
22
|
}
|
|
25
|
-
else if (node.type === ELEMENT) {
|
|
23
|
+
else if (node.type === compiler_core_1.NodeTypes.ELEMENT) {
|
|
26
24
|
node.children.forEach(n => walk(n, visitor));
|
|
27
25
|
node.props
|
|
28
|
-
.filter((prop) => prop.type === DIRECTIVE)
|
|
26
|
+
.filter((prop) => prop.type === compiler_core_1.NodeTypes.DIRECTIVE)
|
|
29
27
|
.filter(prop => !!prop.exp)
|
|
30
28
|
.forEach(prop => visitor(prop.exp));
|
|
31
29
|
}
|
|
@@ -38,7 +36,7 @@ function templateSimpleExpressionNodeVisitor(parseScriptFn) {
|
|
|
38
36
|
if (typeof n !== 'object') {
|
|
39
37
|
return;
|
|
40
38
|
}
|
|
41
|
-
if (n.type !== SIMPLE_EXPRESSION) {
|
|
39
|
+
if (n.type !== compiler_core_1.NodeTypes.SIMPLE_EXPRESSION) {
|
|
42
40
|
return;
|
|
43
41
|
}
|
|
44
42
|
const { content } = n;
|