@lingo.dev/_compiler 0.2.1 → 0.2.2
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/build/index.cjs +59 -37
- package/build/index.mjs +59 -37
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ var _unplugin = require('unplugin');
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "@lingo.dev/_compiler",
|
|
7
|
-
version: "0.2.
|
|
7
|
+
version: "0.2.2",
|
|
8
8
|
description: "Lingo.dev Compiler",
|
|
9
9
|
private: false,
|
|
10
10
|
publishConfig: {
|
|
@@ -1767,6 +1767,17 @@ function collectCallExpressions(path7, importNames, result, functionName) {
|
|
|
1767
1767
|
|
|
1768
1768
|
// src/rsc-dictionary-loader.ts
|
|
1769
1769
|
|
|
1770
|
+
|
|
1771
|
+
// src/_utils.ts
|
|
1772
|
+
|
|
1773
|
+
var getDictionaryPath = (params) => {
|
|
1774
|
+
return path.default.relative(
|
|
1775
|
+
params.relativeFilePath,
|
|
1776
|
+
path.default.resolve(params.sourceRoot, params.lingoDir, LCP_DICTIONARY_FILE_NAME)
|
|
1777
|
+
);
|
|
1778
|
+
};
|
|
1779
|
+
|
|
1780
|
+
// src/rsc-dictionary-loader.ts
|
|
1770
1781
|
var rscDictionaryLoaderMutation = createCodeMutation((payload) => {
|
|
1771
1782
|
const mode = getModuleExecutionMode(payload.ast, payload.params.rsc);
|
|
1772
1783
|
if (mode === "client") {
|
|
@@ -1787,6 +1798,11 @@ var rscDictionaryLoaderMutation = createCodeMutation((payload) => {
|
|
|
1787
1798
|
if (t12.isIdentifier(invokation.callee)) {
|
|
1788
1799
|
invokation.callee.name = internalDictionaryLoader.importedName;
|
|
1789
1800
|
}
|
|
1801
|
+
const dictionaryPath = getDictionaryPath({
|
|
1802
|
+
sourceRoot: payload.params.sourceRoot,
|
|
1803
|
+
lingoDir: payload.params.lingoDir,
|
|
1804
|
+
relativeFilePath: payload.relativeFilePath
|
|
1805
|
+
});
|
|
1790
1806
|
const localeImportMap = t12.objectExpression(
|
|
1791
1807
|
allLocales.map(
|
|
1792
1808
|
(locale) => t12.objectProperty(
|
|
@@ -1794,9 +1810,7 @@ var rscDictionaryLoaderMutation = createCodeMutation((payload) => {
|
|
|
1794
1810
|
t12.arrowFunctionExpression(
|
|
1795
1811
|
[],
|
|
1796
1812
|
t12.callExpression(t12.identifier("import"), [
|
|
1797
|
-
t12.stringLiteral(
|
|
1798
|
-
`@/${payload.params.lingoDir}/${LCP_DICTIONARY_FILE_NAME}?locale=${locale}`
|
|
1799
|
-
)
|
|
1813
|
+
t12.stringLiteral(`${dictionaryPath}?locale=${locale}`)
|
|
1800
1814
|
])
|
|
1801
1815
|
)
|
|
1802
1816
|
)
|
|
@@ -1830,6 +1844,11 @@ var reactRouterDictionaryLoaderMutation = createCodeMutation(
|
|
|
1830
1844
|
if (t13.isIdentifier(invokation.callee)) {
|
|
1831
1845
|
invokation.callee.name = internalDictionaryLoader.importedName;
|
|
1832
1846
|
}
|
|
1847
|
+
const dictionaryPath = getDictionaryPath({
|
|
1848
|
+
sourceRoot: payload.params.sourceRoot,
|
|
1849
|
+
lingoDir: payload.params.lingoDir,
|
|
1850
|
+
relativeFilePath: payload.relativeFilePath
|
|
1851
|
+
});
|
|
1833
1852
|
const localeImportMap = t13.objectExpression(
|
|
1834
1853
|
allLocales.map(
|
|
1835
1854
|
(locale) => t13.objectProperty(
|
|
@@ -1837,9 +1856,7 @@ var reactRouterDictionaryLoaderMutation = createCodeMutation(
|
|
|
1837
1856
|
t13.arrowFunctionExpression(
|
|
1838
1857
|
[],
|
|
1839
1858
|
t13.callExpression(t13.identifier("import"), [
|
|
1840
|
-
t13.stringLiteral(
|
|
1841
|
-
`~/${payload.params.lingoDir}/${LCP_DICTIONARY_FILE_NAME}?locale=${locale}`
|
|
1842
|
-
)
|
|
1859
|
+
t13.stringLiteral(`${dictionaryPath}?locale=${locale}`)
|
|
1843
1860
|
])
|
|
1844
1861
|
)
|
|
1845
1862
|
)
|
|
@@ -1951,18 +1968,22 @@ function jsxAttributeScopesExportMutation(payload) {
|
|
|
1951
1968
|
for (const [scope, attributes] of attributeScopes) {
|
|
1952
1969
|
for (const attributeDefinition of attributes) {
|
|
1953
1970
|
const [attribute, scopeKey] = attributeDefinition.split(":");
|
|
1954
|
-
lcp.resetScope(payload.
|
|
1971
|
+
lcp.resetScope(payload.relativeFilePath, scopeKey);
|
|
1955
1972
|
const attributeValue = getJsxAttributeValue(scope, attribute);
|
|
1956
1973
|
if (!attributeValue) {
|
|
1957
1974
|
continue;
|
|
1958
1975
|
}
|
|
1959
|
-
lcp.setScopeType(payload.
|
|
1976
|
+
lcp.setScopeType(payload.relativeFilePath, scopeKey, "attribute");
|
|
1960
1977
|
const hash = getJsxAttributeValueHash(String(attributeValue));
|
|
1961
|
-
lcp.setScopeHash(payload.
|
|
1962
|
-
lcp.setScopeContext(payload.
|
|
1963
|
-
lcp.setScopeSkip(payload.
|
|
1964
|
-
lcp.setScopeOverrides(payload.
|
|
1965
|
-
lcp.setScopeContent(
|
|
1978
|
+
lcp.setScopeHash(payload.relativeFilePath, scopeKey, hash);
|
|
1979
|
+
lcp.setScopeContext(payload.relativeFilePath, scopeKey, "");
|
|
1980
|
+
lcp.setScopeSkip(payload.relativeFilePath, scopeKey, false);
|
|
1981
|
+
lcp.setScopeOverrides(payload.relativeFilePath, scopeKey, {});
|
|
1982
|
+
lcp.setScopeContent(
|
|
1983
|
+
payload.relativeFilePath,
|
|
1984
|
+
scopeKey,
|
|
1985
|
+
String(attributeValue)
|
|
1986
|
+
);
|
|
1966
1987
|
}
|
|
1967
1988
|
}
|
|
1968
1989
|
lcp.save();
|
|
@@ -2093,21 +2114,29 @@ function jsxScopesExportMutation(payload) {
|
|
|
2093
2114
|
});
|
|
2094
2115
|
for (const scope of scopes) {
|
|
2095
2116
|
const scopeKey = getAstKey(scope);
|
|
2096
|
-
lcp.resetScope(payload.
|
|
2097
|
-
lcp.setScopeType(payload.
|
|
2117
|
+
lcp.resetScope(payload.relativeFilePath, scopeKey);
|
|
2118
|
+
lcp.setScopeType(payload.relativeFilePath, scopeKey, "element");
|
|
2098
2119
|
const hash = getJsxElementHash(scope);
|
|
2099
|
-
lcp.setScopeHash(payload.
|
|
2120
|
+
lcp.setScopeHash(payload.relativeFilePath, scopeKey, hash);
|
|
2100
2121
|
const context = getJsxAttributeValue(scope, "data-lingo-context");
|
|
2101
|
-
lcp.setScopeContext(
|
|
2122
|
+
lcp.setScopeContext(
|
|
2123
|
+
payload.relativeFilePath,
|
|
2124
|
+
scopeKey,
|
|
2125
|
+
String(context || "")
|
|
2126
|
+
);
|
|
2102
2127
|
const skip = getJsxAttributeValue(scope, "data-lingo-skip");
|
|
2103
|
-
lcp.setScopeSkip(
|
|
2128
|
+
lcp.setScopeSkip(
|
|
2129
|
+
payload.relativeFilePath,
|
|
2130
|
+
scopeKey,
|
|
2131
|
+
Boolean(skip || false)
|
|
2132
|
+
);
|
|
2104
2133
|
const attributesMap = getJsxAttributesMap(scope);
|
|
2105
2134
|
const overrides = _lodash2.default.chain(attributesMap).entries().filter(
|
|
2106
2135
|
([attributeKey]) => attributeKey.startsWith("data-lingo-override-")
|
|
2107
2136
|
).map(([k, v]) => [k.split("data-lingo-override-")[1], v]).filter(([k]) => !!k).filter(([, v]) => !!v).fromPairs().value();
|
|
2108
|
-
lcp.setScopeOverrides(payload.
|
|
2137
|
+
lcp.setScopeOverrides(payload.relativeFilePath, scopeKey, overrides);
|
|
2109
2138
|
const content = extractJsxContent(scope);
|
|
2110
|
-
lcp.setScopeContent(payload.
|
|
2139
|
+
lcp.setScopeContent(payload.relativeFilePath, scopeKey, content);
|
|
2111
2140
|
}
|
|
2112
2141
|
lcp.save();
|
|
2113
2142
|
return payload;
|
|
@@ -2144,7 +2173,7 @@ var lingoJsxAttributeScopeInjectMutation = createCodeMutation(
|
|
|
2144
2173
|
jsxScope.node.openingElement.attributes.push(
|
|
2145
2174
|
t17.jsxAttribute(
|
|
2146
2175
|
t17.jsxIdentifier("$fileKey"),
|
|
2147
|
-
t17.stringLiteral(payload.
|
|
2176
|
+
t17.stringLiteral(payload.relativeFilePath)
|
|
2148
2177
|
)
|
|
2149
2178
|
);
|
|
2150
2179
|
jsxScope.node.openingElement.attributes.push(
|
|
@@ -2321,7 +2350,7 @@ var lingoJsxScopeInjectMutation = createCodeMutation((payload) => {
|
|
|
2321
2350
|
originalAttributes.push(
|
|
2322
2351
|
t21.jsxAttribute(
|
|
2323
2352
|
t21.jsxIdentifier("$fileKey"),
|
|
2324
|
-
t21.stringLiteral(payload.
|
|
2353
|
+
t21.stringLiteral(payload.relativeFilePath)
|
|
2325
2354
|
)
|
|
2326
2355
|
);
|
|
2327
2356
|
originalAttributes.push(
|
|
@@ -2432,17 +2461,7 @@ var jsxRemoveAttributesMutation = createCodeMutation(
|
|
|
2432
2461
|
|
|
2433
2462
|
// src/client-dictionary-loader.ts
|
|
2434
2463
|
|
|
2435
|
-
|
|
2436
2464
|
var clientDictionaryLoaderMutation = createCodeMutation((payload) => {
|
|
2437
|
-
const lingoDir = path.default.resolve(
|
|
2438
|
-
process.cwd(),
|
|
2439
|
-
payload.params.sourceRoot,
|
|
2440
|
-
payload.params.lingoDir
|
|
2441
|
-
);
|
|
2442
|
-
const currentDir = path.default.dirname(
|
|
2443
|
-
path.default.resolve(process.cwd(), payload.params.sourceRoot, payload.fileKey)
|
|
2444
|
-
);
|
|
2445
|
-
const relativeLingoPath = path.default.relative(currentDir, lingoDir);
|
|
2446
2465
|
const invokations = findInvokations(payload.ast, {
|
|
2447
2466
|
moduleName: "lingo.dev/react/client" /* ReactClient */,
|
|
2448
2467
|
functionName: "loadDictionary"
|
|
@@ -2458,6 +2477,11 @@ var clientDictionaryLoaderMutation = createCodeMutation((payload) => {
|
|
|
2458
2477
|
if (t23.isIdentifier(invokation.callee)) {
|
|
2459
2478
|
invokation.callee.name = internalDictionaryLoader.importedName;
|
|
2460
2479
|
}
|
|
2480
|
+
const dictionaryPath = getDictionaryPath({
|
|
2481
|
+
sourceRoot: payload.params.sourceRoot,
|
|
2482
|
+
lingoDir: payload.params.lingoDir,
|
|
2483
|
+
relativeFilePath: payload.relativeFilePath
|
|
2484
|
+
});
|
|
2461
2485
|
const localeImportMap = t23.objectExpression(
|
|
2462
2486
|
allLocales.map(
|
|
2463
2487
|
(locale) => t23.objectProperty(
|
|
@@ -2465,9 +2489,7 @@ var clientDictionaryLoaderMutation = createCodeMutation((payload) => {
|
|
|
2465
2489
|
t23.arrowFunctionExpression(
|
|
2466
2490
|
[],
|
|
2467
2491
|
t23.callExpression(t23.identifier("import"), [
|
|
2468
|
-
t23.stringLiteral(
|
|
2469
|
-
`./${relativeLingoPath}/${LCP_DICTIONARY_FILE_NAME}?locale=${locale}`
|
|
2470
|
-
)
|
|
2492
|
+
t23.stringLiteral(`${dictionaryPath}?locale=${locale}`)
|
|
2471
2493
|
])
|
|
2472
2494
|
)
|
|
2473
2495
|
)
|
|
@@ -2552,7 +2574,7 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
2552
2574
|
const result = _lodash2.default.chain({
|
|
2553
2575
|
code,
|
|
2554
2576
|
params,
|
|
2555
|
-
|
|
2577
|
+
relativeFilePath: path.default.relative(path.default.resolve(process.cwd(), params.sourceRoot), id).split(path.default.sep).join("/")
|
|
2556
2578
|
// Always normalize for consistent dictionaries
|
|
2557
2579
|
}).thru(createPayload).thru(
|
|
2558
2580
|
composeMutations(
|
package/build/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { createUnplugin } from "unplugin";
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "@lingo.dev/_compiler",
|
|
7
|
-
version: "0.2.
|
|
7
|
+
version: "0.2.2",
|
|
8
8
|
description: "Lingo.dev Compiler",
|
|
9
9
|
private: false,
|
|
10
10
|
publishConfig: {
|
|
@@ -1767,6 +1767,17 @@ function collectCallExpressions(path7, importNames, result, functionName) {
|
|
|
1767
1767
|
|
|
1768
1768
|
// src/rsc-dictionary-loader.ts
|
|
1769
1769
|
import * as t12 from "@babel/types";
|
|
1770
|
+
|
|
1771
|
+
// src/_utils.ts
|
|
1772
|
+
import path5 from "path";
|
|
1773
|
+
var getDictionaryPath = (params) => {
|
|
1774
|
+
return path5.relative(
|
|
1775
|
+
params.relativeFilePath,
|
|
1776
|
+
path5.resolve(params.sourceRoot, params.lingoDir, LCP_DICTIONARY_FILE_NAME)
|
|
1777
|
+
);
|
|
1778
|
+
};
|
|
1779
|
+
|
|
1780
|
+
// src/rsc-dictionary-loader.ts
|
|
1770
1781
|
var rscDictionaryLoaderMutation = createCodeMutation((payload) => {
|
|
1771
1782
|
const mode = getModuleExecutionMode(payload.ast, payload.params.rsc);
|
|
1772
1783
|
if (mode === "client") {
|
|
@@ -1787,6 +1798,11 @@ var rscDictionaryLoaderMutation = createCodeMutation((payload) => {
|
|
|
1787
1798
|
if (t12.isIdentifier(invokation.callee)) {
|
|
1788
1799
|
invokation.callee.name = internalDictionaryLoader.importedName;
|
|
1789
1800
|
}
|
|
1801
|
+
const dictionaryPath = getDictionaryPath({
|
|
1802
|
+
sourceRoot: payload.params.sourceRoot,
|
|
1803
|
+
lingoDir: payload.params.lingoDir,
|
|
1804
|
+
relativeFilePath: payload.relativeFilePath
|
|
1805
|
+
});
|
|
1790
1806
|
const localeImportMap = t12.objectExpression(
|
|
1791
1807
|
allLocales.map(
|
|
1792
1808
|
(locale) => t12.objectProperty(
|
|
@@ -1794,9 +1810,7 @@ var rscDictionaryLoaderMutation = createCodeMutation((payload) => {
|
|
|
1794
1810
|
t12.arrowFunctionExpression(
|
|
1795
1811
|
[],
|
|
1796
1812
|
t12.callExpression(t12.identifier("import"), [
|
|
1797
|
-
t12.stringLiteral(
|
|
1798
|
-
`@/${payload.params.lingoDir}/${LCP_DICTIONARY_FILE_NAME}?locale=${locale}`
|
|
1799
|
-
)
|
|
1813
|
+
t12.stringLiteral(`${dictionaryPath}?locale=${locale}`)
|
|
1800
1814
|
])
|
|
1801
1815
|
)
|
|
1802
1816
|
)
|
|
@@ -1830,6 +1844,11 @@ var reactRouterDictionaryLoaderMutation = createCodeMutation(
|
|
|
1830
1844
|
if (t13.isIdentifier(invokation.callee)) {
|
|
1831
1845
|
invokation.callee.name = internalDictionaryLoader.importedName;
|
|
1832
1846
|
}
|
|
1847
|
+
const dictionaryPath = getDictionaryPath({
|
|
1848
|
+
sourceRoot: payload.params.sourceRoot,
|
|
1849
|
+
lingoDir: payload.params.lingoDir,
|
|
1850
|
+
relativeFilePath: payload.relativeFilePath
|
|
1851
|
+
});
|
|
1833
1852
|
const localeImportMap = t13.objectExpression(
|
|
1834
1853
|
allLocales.map(
|
|
1835
1854
|
(locale) => t13.objectProperty(
|
|
@@ -1837,9 +1856,7 @@ var reactRouterDictionaryLoaderMutation = createCodeMutation(
|
|
|
1837
1856
|
t13.arrowFunctionExpression(
|
|
1838
1857
|
[],
|
|
1839
1858
|
t13.callExpression(t13.identifier("import"), [
|
|
1840
|
-
t13.stringLiteral(
|
|
1841
|
-
`~/${payload.params.lingoDir}/${LCP_DICTIONARY_FILE_NAME}?locale=${locale}`
|
|
1842
|
-
)
|
|
1859
|
+
t13.stringLiteral(`${dictionaryPath}?locale=${locale}`)
|
|
1843
1860
|
])
|
|
1844
1861
|
)
|
|
1845
1862
|
)
|
|
@@ -1951,18 +1968,22 @@ function jsxAttributeScopesExportMutation(payload) {
|
|
|
1951
1968
|
for (const [scope, attributes] of attributeScopes) {
|
|
1952
1969
|
for (const attributeDefinition of attributes) {
|
|
1953
1970
|
const [attribute, scopeKey] = attributeDefinition.split(":");
|
|
1954
|
-
lcp.resetScope(payload.
|
|
1971
|
+
lcp.resetScope(payload.relativeFilePath, scopeKey);
|
|
1955
1972
|
const attributeValue = getJsxAttributeValue(scope, attribute);
|
|
1956
1973
|
if (!attributeValue) {
|
|
1957
1974
|
continue;
|
|
1958
1975
|
}
|
|
1959
|
-
lcp.setScopeType(payload.
|
|
1976
|
+
lcp.setScopeType(payload.relativeFilePath, scopeKey, "attribute");
|
|
1960
1977
|
const hash = getJsxAttributeValueHash(String(attributeValue));
|
|
1961
|
-
lcp.setScopeHash(payload.
|
|
1962
|
-
lcp.setScopeContext(payload.
|
|
1963
|
-
lcp.setScopeSkip(payload.
|
|
1964
|
-
lcp.setScopeOverrides(payload.
|
|
1965
|
-
lcp.setScopeContent(
|
|
1978
|
+
lcp.setScopeHash(payload.relativeFilePath, scopeKey, hash);
|
|
1979
|
+
lcp.setScopeContext(payload.relativeFilePath, scopeKey, "");
|
|
1980
|
+
lcp.setScopeSkip(payload.relativeFilePath, scopeKey, false);
|
|
1981
|
+
lcp.setScopeOverrides(payload.relativeFilePath, scopeKey, {});
|
|
1982
|
+
lcp.setScopeContent(
|
|
1983
|
+
payload.relativeFilePath,
|
|
1984
|
+
scopeKey,
|
|
1985
|
+
String(attributeValue)
|
|
1986
|
+
);
|
|
1966
1987
|
}
|
|
1967
1988
|
}
|
|
1968
1989
|
lcp.save();
|
|
@@ -2093,21 +2114,29 @@ function jsxScopesExportMutation(payload) {
|
|
|
2093
2114
|
});
|
|
2094
2115
|
for (const scope of scopes) {
|
|
2095
2116
|
const scopeKey = getAstKey(scope);
|
|
2096
|
-
lcp.resetScope(payload.
|
|
2097
|
-
lcp.setScopeType(payload.
|
|
2117
|
+
lcp.resetScope(payload.relativeFilePath, scopeKey);
|
|
2118
|
+
lcp.setScopeType(payload.relativeFilePath, scopeKey, "element");
|
|
2098
2119
|
const hash = getJsxElementHash(scope);
|
|
2099
|
-
lcp.setScopeHash(payload.
|
|
2120
|
+
lcp.setScopeHash(payload.relativeFilePath, scopeKey, hash);
|
|
2100
2121
|
const context = getJsxAttributeValue(scope, "data-lingo-context");
|
|
2101
|
-
lcp.setScopeContext(
|
|
2122
|
+
lcp.setScopeContext(
|
|
2123
|
+
payload.relativeFilePath,
|
|
2124
|
+
scopeKey,
|
|
2125
|
+
String(context || "")
|
|
2126
|
+
);
|
|
2102
2127
|
const skip = getJsxAttributeValue(scope, "data-lingo-skip");
|
|
2103
|
-
lcp.setScopeSkip(
|
|
2128
|
+
lcp.setScopeSkip(
|
|
2129
|
+
payload.relativeFilePath,
|
|
2130
|
+
scopeKey,
|
|
2131
|
+
Boolean(skip || false)
|
|
2132
|
+
);
|
|
2104
2133
|
const attributesMap = getJsxAttributesMap(scope);
|
|
2105
2134
|
const overrides = _10.chain(attributesMap).entries().filter(
|
|
2106
2135
|
([attributeKey]) => attributeKey.startsWith("data-lingo-override-")
|
|
2107
2136
|
).map(([k, v]) => [k.split("data-lingo-override-")[1], v]).filter(([k]) => !!k).filter(([, v]) => !!v).fromPairs().value();
|
|
2108
|
-
lcp.setScopeOverrides(payload.
|
|
2137
|
+
lcp.setScopeOverrides(payload.relativeFilePath, scopeKey, overrides);
|
|
2109
2138
|
const content = extractJsxContent(scope);
|
|
2110
|
-
lcp.setScopeContent(payload.
|
|
2139
|
+
lcp.setScopeContent(payload.relativeFilePath, scopeKey, content);
|
|
2111
2140
|
}
|
|
2112
2141
|
lcp.save();
|
|
2113
2142
|
return payload;
|
|
@@ -2144,7 +2173,7 @@ var lingoJsxAttributeScopeInjectMutation = createCodeMutation(
|
|
|
2144
2173
|
jsxScope.node.openingElement.attributes.push(
|
|
2145
2174
|
t17.jsxAttribute(
|
|
2146
2175
|
t17.jsxIdentifier("$fileKey"),
|
|
2147
|
-
t17.stringLiteral(payload.
|
|
2176
|
+
t17.stringLiteral(payload.relativeFilePath)
|
|
2148
2177
|
)
|
|
2149
2178
|
);
|
|
2150
2179
|
jsxScope.node.openingElement.attributes.push(
|
|
@@ -2321,7 +2350,7 @@ var lingoJsxScopeInjectMutation = createCodeMutation((payload) => {
|
|
|
2321
2350
|
originalAttributes.push(
|
|
2322
2351
|
t21.jsxAttribute(
|
|
2323
2352
|
t21.jsxIdentifier("$fileKey"),
|
|
2324
|
-
t21.stringLiteral(payload.
|
|
2353
|
+
t21.stringLiteral(payload.relativeFilePath)
|
|
2325
2354
|
)
|
|
2326
2355
|
);
|
|
2327
2356
|
originalAttributes.push(
|
|
@@ -2431,18 +2460,8 @@ var jsxRemoveAttributesMutation = createCodeMutation(
|
|
|
2431
2460
|
);
|
|
2432
2461
|
|
|
2433
2462
|
// src/client-dictionary-loader.ts
|
|
2434
|
-
import path5 from "path";
|
|
2435
2463
|
import * as t23 from "@babel/types";
|
|
2436
2464
|
var clientDictionaryLoaderMutation = createCodeMutation((payload) => {
|
|
2437
|
-
const lingoDir = path5.resolve(
|
|
2438
|
-
process.cwd(),
|
|
2439
|
-
payload.params.sourceRoot,
|
|
2440
|
-
payload.params.lingoDir
|
|
2441
|
-
);
|
|
2442
|
-
const currentDir = path5.dirname(
|
|
2443
|
-
path5.resolve(process.cwd(), payload.params.sourceRoot, payload.fileKey)
|
|
2444
|
-
);
|
|
2445
|
-
const relativeLingoPath = path5.relative(currentDir, lingoDir);
|
|
2446
2465
|
const invokations = findInvokations(payload.ast, {
|
|
2447
2466
|
moduleName: "lingo.dev/react/client" /* ReactClient */,
|
|
2448
2467
|
functionName: "loadDictionary"
|
|
@@ -2458,6 +2477,11 @@ var clientDictionaryLoaderMutation = createCodeMutation((payload) => {
|
|
|
2458
2477
|
if (t23.isIdentifier(invokation.callee)) {
|
|
2459
2478
|
invokation.callee.name = internalDictionaryLoader.importedName;
|
|
2460
2479
|
}
|
|
2480
|
+
const dictionaryPath = getDictionaryPath({
|
|
2481
|
+
sourceRoot: payload.params.sourceRoot,
|
|
2482
|
+
lingoDir: payload.params.lingoDir,
|
|
2483
|
+
relativeFilePath: payload.relativeFilePath
|
|
2484
|
+
});
|
|
2461
2485
|
const localeImportMap = t23.objectExpression(
|
|
2462
2486
|
allLocales.map(
|
|
2463
2487
|
(locale) => t23.objectProperty(
|
|
@@ -2465,9 +2489,7 @@ var clientDictionaryLoaderMutation = createCodeMutation((payload) => {
|
|
|
2465
2489
|
t23.arrowFunctionExpression(
|
|
2466
2490
|
[],
|
|
2467
2491
|
t23.callExpression(t23.identifier("import"), [
|
|
2468
|
-
t23.stringLiteral(
|
|
2469
|
-
`./${relativeLingoPath}/${LCP_DICTIONARY_FILE_NAME}?locale=${locale}`
|
|
2470
|
-
)
|
|
2492
|
+
t23.stringLiteral(`${dictionaryPath}?locale=${locale}`)
|
|
2471
2493
|
])
|
|
2472
2494
|
)
|
|
2473
2495
|
)
|
|
@@ -2552,7 +2574,7 @@ var unplugin = createUnplugin(
|
|
|
2552
2574
|
const result = _11.chain({
|
|
2553
2575
|
code,
|
|
2554
2576
|
params,
|
|
2555
|
-
|
|
2577
|
+
relativeFilePath: path6.relative(path6.resolve(process.cwd(), params.sourceRoot), id).split(path6.sep).join("/")
|
|
2556
2578
|
// Always normalize for consistent dictionaries
|
|
2557
2579
|
}).thru(createPayload).thru(
|
|
2558
2580
|
composeMutations(
|