Skip to content

Commit 286afb0

Browse files
authored
fix: cannot resolve vue-i18n and petite-vue-i18n in monorepo (#385)
* fix: cannot resolve vue-i18n and petite-vue-i18n in monorepo * fix: eslint error
1 parent f1d0b9b commit 286afb0

File tree

18 files changed

+1258
-561
lines changed

18 files changed

+1258
-561
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"ts-jest": "^27.0.5",
8484
"typescript": "^4.9.3",
8585
"vite": "^4.4.9",
86-
"vitest": "^0.34.0",
86+
"vitest": "^1.6.0",
8787
"vue": "^3.2.25",
8888
"vue-i18n": "next",
8989
"vue-loader": "^16.3.0",

packages/bundle-utils/test/generator/__snapshots__/codegen.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ exports[`generateMessageFunction > development 1`] = `
5757
"start": 0,
5858
"type": 0,
5959
},
60-
"code": "(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"hello\\"])};fn.source=\\"hello\\";return fn;})()",
60+
"code": "(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["hello"])};fn.source="hello";return fn;})()",
6161
"errors": [],
6262
"map": {
6363
"mappings": "mEAAAA",
@@ -75,9 +75,9 @@ exports[`generateMessageFunction > development 1`] = `
7575
}
7676
`;
7777

78-
exports[`generateMessageFunction > escapeHtml > default: should not be escaped 1`] = `"(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"<p>hello</p>\\"])};fn.source=\\"<p>hello</p>\\";return fn;})()"`;
78+
exports[`generateMessageFunction > escapeHtml > default: should not be escaped 1`] = `"(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["<p>hello</p>"])};fn.source="<p>hello</p>";return fn;})()"`;
7979

80-
exports[`generateMessageFunction > escapeHtml > true: should be escaped 1`] = `"(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"&lt;p&gt;hello&lt;/p&gt;\\"])};fn.source=\\"<p>hello</p>\\";return fn;})()"`;
80+
exports[`generateMessageFunction > escapeHtml > true: should be escaped 1`] = `"(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;p&gt;hello&lt;/p&gt;"])};fn.source="<p>hello</p>";return fn;})()"`;
8181

8282
exports[`generateMessageFunction > production 1`] = `
8383
{
@@ -136,7 +136,7 @@ exports[`generateMessageFunction > production 1`] = `
136136
"start": 0,
137137
"type": 0,
138138
},
139-
"code": "(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"hello\\"])}",
139+
"code": "(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["hello"])}",
140140
"errors": [],
141141
"map": undefined,
142142
}
@@ -199,7 +199,7 @@ exports[`generateResourceAst > development 1`] = `
199199
"start": 0,
200200
"type": 0,
201201
},
202-
"code": "{\\"type\\":0,\\"start\\":0,\\"end\\":5,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":1,\\"offset\\":0},\\"end\\":{\\"line\\":1,\\"column\\":6,\\"offset\\":5},\\"source\\":\\"hello\\"},\\"body\\":{\\"type\\":2,\\"start\\":0,\\"end\\":5,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":1,\\"offset\\":0},\\"end\\":{\\"line\\":1,\\"column\\":6,\\"offset\\":5}},\\"items\\":[{\\"type\\":3,\\"start\\":0,\\"end\\":5,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":1,\\"offset\\":0},\\"end\\":{\\"line\\":1,\\"column\\":6,\\"offset\\":5}},\\"value\\":\\"hello\\"}]}}",
202+
"code": "{"type":0,"start":0,"end":5,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":6,"offset":5},"source":"hello"},"body":{"type":2,"start":0,"end":5,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":6,"offset":5}},"items":[{"type":3,"start":0,"end":5,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":6,"offset":5}},"value":"hello"}]}}",
203203
"errors": [],
204204
"map": undefined,
205205
}
@@ -219,7 +219,7 @@ exports[`generateResourceAst > production 1`] = `
219219
},
220220
"t": 0,
221221
},
222-
"code": "{\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"hello\\"}}",
222+
"code": "{"t":0,"b":{"t":2,"i":[{"t":3}],"s":"hello"}}",
223223
"errors": [],
224224
"map": undefined,
225225
}

packages/bundle-utils/test/generator/__snapshots__/js.test.ts.snap

Lines changed: 84 additions & 84 deletions
Large diffs are not rendered by default.

packages/bundle-utils/test/generator/__snapshots__/json.test.ts.snap

Lines changed: 165 additions & 165 deletions
Large diffs are not rendered by default.

packages/bundle-utils/test/generator/__snapshots__/json5.test.ts.snap

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22

33
exports[`AST code generation > code 1`] = `
44
"const resource = {
5-
\\"hi\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"hi there!\\"}},
6-
\\"nested\\": {
7-
\\"hello\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"hello world!\\"}},
8-
\\"more\\": {
9-
\\"plural\\": {\\"t\\":0,\\"b\\":{\\"t\\":1,\\"c\\":[{\\"t\\":2,\\"i\\":[{\\"t\\":6,\\"k\\":{\\"t\\":9,\\"v\\":\\"no apples\\"},\\"m\\":{\\"t\\":8,\\"v\\":\\"caml\\"}}]},{\\"t\\":2,\\"i\\":[{\\"t\\":5,\\"i\\":0},{\\"t\\":3,\\"v\\":\\" apple\\"}]},{\\"t\\":2,\\"i\\":[{\\"t\\":4,\\"k\\":\\"n\\"},{\\"t\\":3,\\"v\\":\\" apples\\"}]}]}}
5+
"hi": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"hi there!"}},
6+
"nested": {
7+
"hello": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"hello world!"}},
8+
"more": {
9+
"plural": {"t":0,"b":{"t":1,"c":[{"t":2,"i":[{"t":6,"k":{"t":9,"v":"no apples"},"m":{"t":8,"v":"caml"}}]},{"t":2,"i":[{"t":5,"i":0},{"t":3,"v":" apple"}]},{"t":2,"i":[{"t":4,"k":"n"},{"t":3,"v":" apples"}]}]}}
1010
},
11-
\\"list\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3,\\"v\\":\\"hi, \\"},{\\"t\\":5,\\"i\\":0},{\\"t\\":3,\\"v\\":\\" !\\"}]}}
11+
"list": {"t":0,"b":{"t":2,"i":[{"t":3,"v":"hi, "},{"t":5,"i":0},{"t":3,"v":" !"}]}}
1212
},
13-
\\"こんにちは\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"こんにちは!\\"}},
14-
\\"single-quote\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"I don\\\\u0027t know!\\"}},
15-
\\"emoji\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"😺\\"}},
16-
\\"unicode\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"A\\"}},
17-
\\"unicode-escape\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"\\\\\\\\u0041\\"}},
18-
\\"backslash-single-quote\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"\\\\\\\\\\\\u0027\\"}},
19-
\\"backslash-backslash\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"\\\\\\\\\\\\\\\\\\"}},
20-
\\"errors\\": [
21-
{\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"ERROR1001\\"}},
22-
{\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"ERROR1002\\"}},
13+
"こんにちは": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"こんにちは!"}},
14+
"single-quote": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"I don\\u0027t know!"}},
15+
"emoji": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"😺"}},
16+
"unicode": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"A"}},
17+
"unicode-escape": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"\\\\u0041"}},
18+
"backslash-single-quote": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"\\\\\\u0027"}},
19+
"backslash-backslash": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"\\\\\\\\"}},
20+
"errors": [
21+
{"t":0,"b":{"t":2,"i":[{"t":3}],"s":"ERROR1001"}},
22+
{"t":0,"b":{"t":2,"i":[{"t":3}],"s":"ERROR1002"}},
2323
2424
],
25-
\\"complex\\": {
26-
\\"warnings\\": [
27-
{\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"NOTE: This is warning\\"}},
25+
"complex": {
26+
"warnings": [
27+
{"t":0,"b":{"t":2,"i":[{"t":3}],"s":"NOTE: This is warning"}},
2828
{
29-
\\"named-waring\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3,\\"v\\":\\"this is \\"},{\\"t\\":4,\\"k\\":\\"type\\"},{\\"t\\":3,\\"v\\":\\" warining\\"}]}}
29+
"named-waring": {"t":0,"b":{"t":2,"i":[{"t":3,"v":"this is "},{"t":4,"k":"type"},{"t":3,"v":" warining"}]}}
3030
}
3131
]
3232
}
@@ -36,31 +36,31 @@ export default resource"
3636

3737
exports[`json5 > code 1`] = `
3838
"const resource = {
39-
\\"hi\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"hi there!\\"])};fn.source=\\"hi there!\\";return fn;})(),
40-
\\"nested\\": {
41-
\\"hello\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"hello world!\\"])};fn.source=\\"hello world!\\";return fn;})(),
42-
\\"more\\": {
43-
\\"plural\\": (()=>{const fn=(ctx) => {const { normalize: _normalize, linked: _linked, type: _type, interpolate: _interpolate, list: _list, named: _named, plural: _plural } = ctx;return _plural([_normalize([_linked(\\"no apples\\", \\"caml\\", _type)]), _normalize([_interpolate(_list(0)), \\" apple\\"]), _normalize([_interpolate(_named(\\"n\\")), \\" apples\\"])])};fn.source=\\"@.caml:{'no apples'} | {0} apple | {n} apples\\";return fn;})()
39+
"hi": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["hi there!"])};fn.source="hi there!";return fn;})(),
40+
"nested": {
41+
"hello": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["hello world!"])};fn.source="hello world!";return fn;})(),
42+
"more": {
43+
"plural": (()=>{const fn=(ctx) => {const { normalize: _normalize, linked: _linked, type: _type, interpolate: _interpolate, list: _list, named: _named, plural: _plural } = ctx;return _plural([_normalize([_linked("no apples", "caml", _type)]), _normalize([_interpolate(_list(0)), " apple"]), _normalize([_interpolate(_named("n")), " apples"])])};fn.source="@.caml:{'no apples'} | {0} apple | {n} apples";return fn;})()
4444
},
45-
\\"list\\": (()=>{const fn=(ctx) => {const { normalize: _normalize, interpolate: _interpolate, list: _list } = ctx;return _normalize([\\"hi, \\", _interpolate(_list(0)), \\" !\\"])};fn.source=\\"hi, {0} !\\";return fn;})()
45+
"list": (()=>{const fn=(ctx) => {const { normalize: _normalize, interpolate: _interpolate, list: _list } = ctx;return _normalize(["hi, ", _interpolate(_list(0)), " !"])};fn.source="hi, {0} !";return fn;})()
4646
},
47-
\\"こんにちは\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"こんにちは!\\"])};fn.source=\\"こんにちは!\\";return fn;})(),
48-
\\"single-quote\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"I don't know!\\"])};fn.source=\\"I don't know!\\";return fn;})(),
49-
\\"emoji\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"😺\\"])};fn.source=\\"😺\\";return fn;})(),
50-
\\"unicode\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"A\\"])};fn.source=\\"A\\";return fn;})(),
51-
\\"unicode-escape\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"\\\\\\\\u0041\\"])};fn.source=\\"\\\\\\\\u0041\\";return fn;})(),
52-
\\"backslash-single-quote\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"\\\\\\\\'\\"])};fn.source=\\"\\\\\\\\'\\";return fn;})(),
53-
\\"backslash-backslash\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"\\\\\\\\\\\\\\\\\\"])};fn.source=\\"\\\\\\\\\\\\\\\\\\";return fn;})(),
54-
\\"errors\\": [
55-
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"ERROR1001\\"])};fn.source=\\"ERROR1001\\";return fn;})(),
56-
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"ERROR1002\\"])};fn.source=\\"ERROR1002\\";return fn;})(),
47+
"こんにちは": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["こんにちは!"])};fn.source="こんにちは!";return fn;})(),
48+
"single-quote": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["I don't know!"])};fn.source="I don't know!";return fn;})(),
49+
"emoji": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["😺"])};fn.source="😺";return fn;})(),
50+
"unicode": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["A"])};fn.source="A";return fn;})(),
51+
"unicode-escape": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\u0041"])};fn.source="\\\\u0041";return fn;})(),
52+
"backslash-single-quote": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\'"])};fn.source="\\\\'";return fn;})(),
53+
"backslash-backslash": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\\\\\"])};fn.source="\\\\\\\\";return fn;})(),
54+
"errors": [
55+
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1001"])};fn.source="ERROR1001";return fn;})(),
56+
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1002"])};fn.source="ERROR1002";return fn;})(),
5757
5858
],
59-
\\"complex\\": {
60-
\\"warnings\\": [
61-
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"NOTE: This is warning\\"])};fn.source=\\"NOTE: This is warning\\";return fn;})(),
59+
"complex": {
60+
"warnings": [
61+
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["NOTE: This is warning"])};fn.source="NOTE: This is warning";return fn;})(),
6262
{
63-
\\"named-waring\\": (()=>{const fn=(ctx) => {const { normalize: _normalize, interpolate: _interpolate, named: _named } = ctx;return _normalize([\\"this is \\", _interpolate(_named(\\"type\\")), \\" warining\\"])};fn.source=\\"this is {type} warining\\";return fn;})()
63+
"named-waring": (()=>{const fn=(ctx) => {const { normalize: _normalize, interpolate: _interpolate, named: _named } = ctx;return _normalize(["this is ", _interpolate(_named("type")), " warining"])};fn.source="this is {type} warining";return fn;})()
6464
}
6565
]
6666
}
@@ -86,9 +86,9 @@ exports[`json5 > map 1`] = `
8686
"I don't know!",
8787
"😺",
8888
"A",
89-
"\\\\u0041",
90-
"\\\\'",
91-
"\\\\\\\\",
89+
"\\u0041",
90+
"\\'",
91+
"\\\\",
9292
"ERROR1001",
9393
"ERROR1002",
9494
"NOTE: This is warning",
@@ -101,30 +101,30 @@ exports[`json5 > map 1`] = `
101101
],
102102
"sourcesContent": [
103103
"{
104-
hi: \\"hi there!\\",
104+
hi: "hi there!",
105105
nested: {
106-
hello: \\"hello world!\\",
106+
hello: "hello world!",
107107
more: {
108-
plural: \\"@.caml:{'no apples'} | {0} apple | {n} apples\\"
108+
plural: "@.caml:{'no apples'} | {0} apple | {n} apples"
109109
},
110-
list: \\"hi, {0} !\\"
110+
list: "hi, {0} !"
111111
},
112112
// comment
113-
\\"こんにちは\\": \\"こんにちは!\\",
114-
\\"single-quote\\": \\"I don't know!\\",
115-
emoji: \\"😺\\",
116-
unicode: \\"\\\\u0041\\",
117-
\\"unicode-escape\\": \\"\\\\\\\\u0041\\",
118-
\\"backslash-single-quote\\": \\"\\\\\\\\'\\",
119-
\\"backslash-backslash\\": \\"\\\\\\\\\\\\\\\\\\",
113+
"こんにちは": "こんにちは!",
114+
"single-quote": "I don't know!",
115+
emoji: "😺",
116+
unicode: "\\u0041",
117+
"unicode-escape": "\\\\u0041",
118+
"backslash-single-quote": "\\\\'",
119+
"backslash-backslash": "\\\\\\\\",
120120
errors: [
121121
'ERROR1001', 'ERROR1002'
122122
],
123123
complex: {
124124
warnings: [
125125
'NOTE: This is warning',
126126
{
127-
\\"named-waring\\": 'this is {type} warining'
127+
"named-waring": 'this is {type} warining'
128128
}
129129
]
130130
}

0 commit comments

Comments
 (0)