Skip to content

Commit

Permalink
fix: cannot resolve vue-i18n and petite-vue-i18n in monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Jun 25, 2024
1 parent a943f07 commit 0d2a93f
Show file tree
Hide file tree
Showing 18 changed files with 1,258 additions and 560 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"ts-jest": "^27.0.5",
"typescript": "^4.9.3",
"vite": "^4.4.9",
"vitest": "^0.34.0",
"vitest": "^1.6.0",
"vue": "^3.2.25",
"vue-i18n": "next",
"vue-loader": "^16.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ exports[`generateMessageFunction > development 1`] = `
"start": 0,
"type": 0,
},
"code": "(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"hello\\"])};fn.source=\\"hello\\";return fn;})()",
"code": "(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["hello"])};fn.source="hello";return fn;})()",
"errors": [],
"map": {
"mappings": "mEAAAA",
Expand All @@ -75,9 +75,9 @@ exports[`generateMessageFunction > development 1`] = `
}
`;

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;})()"`;
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;})()"`;

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;})()"`;
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;})()"`;

exports[`generateMessageFunction > production 1`] = `
{
Expand Down Expand Up @@ -136,7 +136,7 @@ exports[`generateMessageFunction > production 1`] = `
"start": 0,
"type": 0,
},
"code": "(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"hello\\"])}",
"code": "(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["hello"])}",
"errors": [],
"map": undefined,
}
Expand Down Expand Up @@ -199,7 +199,7 @@ exports[`generateResourceAst > development 1`] = `
"start": 0,
"type": 0,
},
"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\\"}]}}",
"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"}]}}",
"errors": [],
"map": undefined,
}
Expand All @@ -219,7 +219,7 @@ exports[`generateResourceAst > production 1`] = `
},
"t": 0,
},
"code": "{\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"hello\\"}}",
"code": "{"t":0,"b":{"t":2,"i":[{"t":3}],"s":"hello"}}",
"errors": [],
"map": undefined,
}
Expand Down
168 changes: 84 additions & 84 deletions packages/bundle-utils/test/generator/__snapshots__/js.test.ts.snap

Large diffs are not rendered by default.

330 changes: 165 additions & 165 deletions packages/bundle-utils/test/generator/__snapshots__/json.test.ts.snap

Large diffs are not rendered by default.

110 changes: 55 additions & 55 deletions packages/bundle-utils/test/generator/__snapshots__/json5.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@

exports[`AST code generation > code 1`] = `
"const resource = {
\\"hi\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"hi there!\\"}},
\\"nested\\": {
\\"hello\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"hello world!\\"}},
\\"more\\": {
\\"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\\"}]}]}}
"hi": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"hi there!"}},
"nested": {
"hello": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"hello world!"}},
"more": {
"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"}]}]}}
},
\\"list\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3,\\"v\\":\\"hi, \\"},{\\"t\\":5,\\"i\\":0},{\\"t\\":3,\\"v\\":\\" !\\"}]}}
"list": {"t":0,"b":{"t":2,"i":[{"t":3,"v":"hi, "},{"t":5,"i":0},{"t":3,"v":" !"}]}}
},
\\"こんにちは\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"こんにちは!\\"}},
\\"single-quote\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"I don\\\\u0027t know!\\"}},
\\"emoji\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"😺\\"}},
\\"unicode\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"A\\"}},
\\"unicode-escape\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"\\\\\\\\u0041\\"}},
\\"backslash-single-quote\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"\\\\\\\\\\\\u0027\\"}},
\\"backslash-backslash\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"\\\\\\\\\\\\\\\\\\"}},
\\"errors\\": [
{\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"ERROR1001\\"}},
{\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"ERROR1002\\"}},
"こんにちは": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"こんにちは!"}},
"single-quote": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"I don\\u0027t know!"}},
"emoji": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"😺"}},
"unicode": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"A"}},
"unicode-escape": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"\\\\u0041"}},
"backslash-single-quote": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"\\\\\\u0027"}},
"backslash-backslash": {"t":0,"b":{"t":2,"i":[{"t":3}],"s":"\\\\\\\\"}},
"errors": [
{"t":0,"b":{"t":2,"i":[{"t":3}],"s":"ERROR1001"}},
{"t":0,"b":{"t":2,"i":[{"t":3}],"s":"ERROR1002"}},
],
\\"complex\\": {
\\"warnings\\": [
{\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3}],\\"s\\":\\"NOTE: This is warning\\"}},
"complex": {
"warnings": [
{"t":0,"b":{"t":2,"i":[{"t":3}],"s":"NOTE: This is warning"}},
{
\\"named-waring\\": {\\"t\\":0,\\"b\\":{\\"t\\":2,\\"i\\":[{\\"t\\":3,\\"v\\":\\"this is \\"},{\\"t\\":4,\\"k\\":\\"type\\"},{\\"t\\":3,\\"v\\":\\" warining\\"}]}}
"named-waring": {"t":0,"b":{"t":2,"i":[{"t":3,"v":"this is "},{"t":4,"k":"type"},{"t":3,"v":" warining"}]}}
}
]
}
Expand All @@ -36,31 +36,31 @@ export default resource"

exports[`json5 > code 1`] = `
"const resource = {
\\"hi\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"hi there!\\"])};fn.source=\\"hi there!\\";return fn;})(),
\\"nested\\": {
\\"hello\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"hello world!\\"])};fn.source=\\"hello world!\\";return fn;})(),
\\"more\\": {
\\"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;})()
"hi": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["hi there!"])};fn.source="hi there!";return fn;})(),
"nested": {
"hello": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["hello world!"])};fn.source="hello world!";return fn;})(),
"more": {
"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;})()
},
\\"list\\": (()=>{const fn=(ctx) => {const { normalize: _normalize, interpolate: _interpolate, list: _list } = ctx;return _normalize([\\"hi, \\", _interpolate(_list(0)), \\" !\\"])};fn.source=\\"hi, {0} !\\";return fn;})()
"list": (()=>{const fn=(ctx) => {const { normalize: _normalize, interpolate: _interpolate, list: _list } = ctx;return _normalize(["hi, ", _interpolate(_list(0)), " !"])};fn.source="hi, {0} !";return fn;})()
},
\\"こんにちは\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"こんにちは!\\"])};fn.source=\\"こんにちは!\\";return fn;})(),
\\"single-quote\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"I don't know!\\"])};fn.source=\\"I don't know!\\";return fn;})(),
\\"emoji\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"😺\\"])};fn.source=\\"😺\\";return fn;})(),
\\"unicode\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"A\\"])};fn.source=\\"A\\";return fn;})(),
\\"unicode-escape\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"\\\\\\\\u0041\\"])};fn.source=\\"\\\\\\\\u0041\\";return fn;})(),
\\"backslash-single-quote\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"\\\\\\\\'\\"])};fn.source=\\"\\\\\\\\'\\";return fn;})(),
\\"backslash-backslash\\": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"\\\\\\\\\\\\\\\\\\"])};fn.source=\\"\\\\\\\\\\\\\\\\\\";return fn;})(),
\\"errors\\": [
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"ERROR1001\\"])};fn.source=\\"ERROR1001\\";return fn;})(),
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"ERROR1002\\"])};fn.source=\\"ERROR1002\\";return fn;})(),
"こんにちは": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["こんにちは!"])};fn.source="こんにちは!";return fn;})(),
"single-quote": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["I don't know!"])};fn.source="I don't know!";return fn;})(),
"emoji": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["😺"])};fn.source="😺";return fn;})(),
"unicode": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["A"])};fn.source="A";return fn;})(),
"unicode-escape": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\u0041"])};fn.source="\\\\u0041";return fn;})(),
"backslash-single-quote": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\'"])};fn.source="\\\\'";return fn;})(),
"backslash-backslash": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\\\\\"])};fn.source="\\\\\\\\";return fn;})(),
"errors": [
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1001"])};fn.source="ERROR1001";return fn;})(),
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1002"])};fn.source="ERROR1002";return fn;})(),
],
\\"complex\\": {
\\"warnings\\": [
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize([\\"NOTE: This is warning\\"])};fn.source=\\"NOTE: This is warning\\";return fn;})(),
"complex": {
"warnings": [
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["NOTE: This is warning"])};fn.source="NOTE: This is warning";return fn;})(),
{
\\"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;})()
"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;})()
}
]
}
Expand All @@ -86,9 +86,9 @@ exports[`json5 > map 1`] = `
"I don't know!",
"😺",
"A",
"\\\\u0041",
"\\\\'",
"\\\\\\\\",
"\\u0041",
"\\'",
"\\\\",
"ERROR1001",
"ERROR1002",
"NOTE: This is warning",
Expand All @@ -101,30 +101,30 @@ exports[`json5 > map 1`] = `
],
"sourcesContent": [
"{
hi: \\"hi there!\\",
hi: "hi there!",
nested: {
hello: \\"hello world!\\",
hello: "hello world!",
more: {
plural: \\"@.caml:{'no apples'} | {0} apple | {n} apples\\"
plural: "@.caml:{'no apples'} | {0} apple | {n} apples"
},
list: \\"hi, {0} !\\"
list: "hi, {0} !"
},
// comment
\\"こんにちは\\": \\"こんにちは!\\",
\\"single-quote\\": \\"I don't know!\\",
emoji: \\"😺\\",
unicode: \\"\\\\u0041\\",
\\"unicode-escape\\": \\"\\\\\\\\u0041\\",
\\"backslash-single-quote\\": \\"\\\\\\\\'\\",
\\"backslash-backslash\\": \\"\\\\\\\\\\\\\\\\\\",
"こんにちは": "こんにちは!",
"single-quote": "I don't know!",
emoji: "😺",
unicode: "\\u0041",
"unicode-escape": "\\\\u0041",
"backslash-single-quote": "\\\\'",
"backslash-backslash": "\\\\\\\\",
errors: [
'ERROR1001', 'ERROR1002'
],
complex: {
warnings: [
'NOTE: This is warning',
{
\\"named-waring\\": 'this is {type} warining'
"named-waring": 'this is {type} warining'
}
]
}
Expand Down
Loading

0 comments on commit 0d2a93f

Please sign in to comment.