@koine/i18n 2.0.0-beta.203 → 2.0.0-beta.205
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/LLM.md +23 -0
- package/adapter-js/generators/loadTranslations.cjs.js +3 -4
- package/adapter-js/generators/loadTranslations.esm.js +3 -4
- package/adapter-next/index.cjs.js +11 -10
- package/adapter-next/index.d.ts +6 -0
- package/adapter-next/index.esm.js +11 -10
- package/adapter-next/plugin/utils.cjs.js +12 -12
- package/adapter-next/plugin/utils.d.ts +2 -1
- package/adapter-next/plugin/utils.esm.js +12 -12
- package/compiler/api.d.ts +6 -2
- package/compiler/code/write.cjs.js +1 -1
- package/compiler/code/write.esm.js +1 -1
- package/compiler/createSwcTransforms.cjs.js +4 -4
- package/compiler/createSwcTransforms.d.ts +3 -1
- package/compiler/createSwcTransforms.esm.js +4 -4
- package/package.json +4 -4
package/LLM.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Prompts
|
|
2
|
+
|
|
3
|
+
To localize a project start by looking at applications source code. Each should have a `i18n` folder where `@koine/i18n` generates various i18n related source files, for instance translations functions are created in `$t` subfolder. These functions are used to output localised text.
|
|
4
|
+
Divide the localization process in these phases:
|
|
5
|
+
|
|
6
|
+
1. Go through applications codebase and extract all strings. By "extract" I mean you should get the string value and assign it to a unique key. All they keys you gather will construct a single JSON object with various levels of nested objects. Each nested level represent a portion of the path where the string was found. For instance if you find "Hello world" in `/src/components/header.tsx -> HeaderButton component` the key will be `header.button.text` where the *first* level is the relative path to the file, the *second* level is the component name (excluding the folder name), and the *third* level is the text key based on what the component does. Constructing the key is up to you, but it should be unique and descriptive, not too long or complex. Note: you should ignore `src/components` and `src/app` folders when constructing the key. You must hold in your memory a reference of the key and its position in the codebase as that will need to be replaced at step 5.
|
|
7
|
+
It is very important to understand the needed interpolation and plurals when extracting the strings, you might need:
|
|
8
|
+
- a **simple** interpolated value: `{ myKey: "example of a {{ dynamicValue }}" }`
|
|
9
|
+
- a **component** based interpolated value: `{ myKey: "example of <dynamic-value></dynamic-value>" }`
|
|
10
|
+
- a **plural** formatted value: `{ myKey: { one: "example of a plural form", other: "example of some plural forms" } }`.
|
|
11
|
+
|
|
12
|
+
2. Now you have a JSON object with all the strings you need to localize. You need to create a new file in the `i18n` folder mentioned above called `{locale}.json` and save the JSON object to it, where `{locale}` is the language code the text are written in the application source code.
|
|
13
|
+
|
|
14
|
+
3. Now setup the `@koine/i18n` compiler (if not already set) in the application codebase, it should use as `source` the just generated JSON files for each language.
|
|
15
|
+
|
|
16
|
+
4. Run the compiler.
|
|
17
|
+
|
|
18
|
+
5. Now look into the `i18n` folder containing the generated artifacts and use the generated `$t` functions to replace the hardcoded string in the codebase. The function names reflect the keys so you should just match those. Do not pass the locale to each `$t` function invokation, that is set globally and all `$t` function will read it from there. Here how you should treat interpolation gathered at step 1:
|
|
19
|
+
- a **simple** interpolated value will just use first function argument, e.g. `$t_myKey({ dynamicValue: "user name" })`
|
|
20
|
+
- a **component** based interpolated value should use `TransText` component from the `i18n` folder generated artifacts (typically importable in TypeScript from `@/i18n`), .e.g. `<TransText text={$t_myKey()} components={{ "dynamic-value": () => <b>Whatever JSX</b> }}> />`
|
|
21
|
+
- a **plural** formatted value uses `count` special function argument value, e.g. `$t_myKey({ count: 3 })`
|
|
22
|
+
|
|
23
|
+
When asked to localize an application for the first time go through all the steps, when done already you can only look for untranslated strings in step 1 and skip step 3.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
var helpers = require('../../compiler/helpers.cjs.js');
|
|
5
5
|
|
|
6
|
-
var l = createAdapter.createGenerator("js", (n)=>({
|
|
6
|
+
var l = createAdapter.createGenerator("js", ({ input: n })=>({
|
|
7
7
|
loadTranslations: {
|
|
8
8
|
dir: createAdapter.createGenerator.dirs.internal,
|
|
9
9
|
name: "loadTranslations",
|
|
@@ -18,10 +18,9 @@ import type { I18n } from "../types";
|
|
|
18
18
|
export const loadTranslations = (
|
|
19
19
|
locale: I18n.Locale,
|
|
20
20
|
namespace: I18n.TranslationsNamespace,
|
|
21
|
-
) =>
|
|
22
|
-
import(\`${helpers.getTranslationsDir(1)}/\${locale}/\${namespace}.json\`).then(
|
|
21
|
+
) => ${n.translationFiles?.length ? `\n import(\`${helpers.getTranslationsDir(1)}/\${locale}/\${namespace}.json\`).then(
|
|
23
22
|
(m) => m.default,
|
|
24
|
-
);
|
|
23
|
+
)` : "{}"};
|
|
25
24
|
`
|
|
26
25
|
}
|
|
27
26
|
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
import { getTranslationsDir } from '../../compiler/helpers.esm.js';
|
|
3
3
|
|
|
4
|
-
var l = createGenerator("js", (n)=>({
|
|
4
|
+
var l = createGenerator("js", ({ input: n })=>({
|
|
5
5
|
loadTranslations: {
|
|
6
6
|
dir: createGenerator.dirs.internal,
|
|
7
7
|
name: "loadTranslations",
|
|
@@ -16,10 +16,9 @@ import type { I18n } from "../types";
|
|
|
16
16
|
export const loadTranslations = (
|
|
17
17
|
locale: I18n.Locale,
|
|
18
18
|
namespace: I18n.TranslationsNamespace,
|
|
19
|
-
) =>
|
|
20
|
-
import(\`${getTranslationsDir(1)}/\${locale}/\${namespace}.json\`).then(
|
|
19
|
+
) => ${n.translationFiles?.length ? `\n import(\`${getTranslationsDir(1)}/\${locale}/\${namespace}.json\`).then(
|
|
21
20
|
(m) => m.default,
|
|
22
|
-
);
|
|
21
|
+
)` : "{}"};
|
|
23
22
|
`
|
|
24
23
|
}
|
|
25
24
|
}));
|
|
@@ -19,15 +19,15 @@ var i18nGet = require('./generators/router-pages/i18nGet.cjs.js');
|
|
|
19
19
|
var useRouteId = require('./generators/useRouteId.cjs.js');
|
|
20
20
|
var webpackDefine = require('./generators/webpack-define.cjs.js');
|
|
21
21
|
|
|
22
|
-
function resolveGlobalizeOption(
|
|
23
|
-
let { functions:
|
|
22
|
+
function resolveGlobalizeOption(r) {
|
|
23
|
+
let { functions: e, prefix: t } = r;
|
|
24
24
|
return {
|
|
25
25
|
prefix: t || "",
|
|
26
26
|
prefixSafe: t ? (t + "_").replace(/_+$/, "_") : "",
|
|
27
|
-
functions: "boolean" == typeof
|
|
27
|
+
functions: "boolean" == typeof e ? {
|
|
28
28
|
routes: true,
|
|
29
29
|
translations: true
|
|
30
|
-
} :
|
|
30
|
+
} : e
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
const adapterNext = createAdapter.createAdapter({
|
|
@@ -35,6 +35,7 @@ const adapterNext = createAdapter.createAdapter({
|
|
|
35
35
|
defaultOptions: {
|
|
36
36
|
...index.adapterReact.defaultOptions,
|
|
37
37
|
router: "app",
|
|
38
|
+
modularizeI18nImports: true,
|
|
38
39
|
globalize: {
|
|
39
40
|
prefix: "i18n",
|
|
40
41
|
functions: true
|
|
@@ -47,10 +48,10 @@ const adapterNext = createAdapter.createAdapter({
|
|
|
47
48
|
nextVersion: o
|
|
48
49
|
};
|
|
49
50
|
},
|
|
50
|
-
getGenerators: (
|
|
51
|
-
let { router: t } =
|
|
51
|
+
getGenerators: (r)=>{
|
|
52
|
+
let { router: t } = r.options.adapter.options;
|
|
52
53
|
return [
|
|
53
|
-
...index.adapterReact.getGenerators(
|
|
54
|
+
...index.adapterReact.getGenerators(r),
|
|
54
55
|
nextRedirects,
|
|
55
56
|
nextRewrites,
|
|
56
57
|
..."app" === t || "migrating" === t ? [
|
|
@@ -70,11 +71,11 @@ const adapterNext = createAdapter.createAdapter({
|
|
|
70
71
|
webpackDefine
|
|
71
72
|
];
|
|
72
73
|
},
|
|
73
|
-
getTransformers: (
|
|
74
|
-
let { router:
|
|
74
|
+
getTransformers: (r)=>{
|
|
75
|
+
let { router: e } = r.options.adapter.options;
|
|
75
76
|
return {
|
|
76
77
|
I18nHeadTags: false,
|
|
77
|
-
..."app" ===
|
|
78
|
+
..."app" === e ? {
|
|
78
79
|
I18nEffects: false
|
|
79
80
|
} : {}
|
|
80
81
|
};
|
package/adapter-next/index.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ export type Options = AdapterReact.Options & {
|
|
|
4
4
|
* @default "app"
|
|
5
5
|
*/
|
|
6
6
|
router: "app" | "pages" | "migrating";
|
|
7
|
+
/**
|
|
8
|
+
* Uses `swc` transforms to modularize i18n imports with NextJS `modularizeImports` option
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
modularizeI18nImports?: boolean;
|
|
7
12
|
/**
|
|
8
13
|
* Configure the generation of globally exposed api
|
|
9
14
|
*/
|
|
@@ -203,6 +208,7 @@ export declare const adapterNext: {
|
|
|
203
208
|
getMeta: <TAdapterName extends import("../compiler").I18nCompiler.AdapterName>(options: import("../compiler").I18nCompiler.AdapterConfigurationResolved<TAdapterName>["options"]) => import("../compiler").I18nCompiler.AdapterConfigurationResolved<import("../compiler").I18nCompiler.AdapterName>["meta"];
|
|
204
209
|
defaultOptions: {
|
|
205
210
|
router: "app";
|
|
211
|
+
modularizeI18nImports: true;
|
|
206
212
|
globalize: {
|
|
207
213
|
prefix: string;
|
|
208
214
|
functions: true;
|
|
@@ -15,15 +15,15 @@ import d from './generators/router-pages/i18nGet.esm.js';
|
|
|
15
15
|
import l from './generators/useRouteId.esm.js';
|
|
16
16
|
import c from './generators/webpack-define.esm.js';
|
|
17
17
|
|
|
18
|
-
function resolveGlobalizeOption(
|
|
19
|
-
let { functions:
|
|
18
|
+
function resolveGlobalizeOption(r) {
|
|
19
|
+
let { functions: e, prefix: t } = r;
|
|
20
20
|
return {
|
|
21
21
|
prefix: t || "",
|
|
22
22
|
prefixSafe: t ? (t + "_").replace(/_+$/, "_") : "",
|
|
23
|
-
functions: "boolean" == typeof
|
|
23
|
+
functions: "boolean" == typeof e ? {
|
|
24
24
|
routes: true,
|
|
25
25
|
translations: true
|
|
26
|
-
} :
|
|
26
|
+
} : e
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
const adapterNext = createAdapter({
|
|
@@ -31,6 +31,7 @@ const adapterNext = createAdapter({
|
|
|
31
31
|
defaultOptions: {
|
|
32
32
|
...adapterReact.defaultOptions,
|
|
33
33
|
router: "app",
|
|
34
|
+
modularizeI18nImports: true,
|
|
34
35
|
globalize: {
|
|
35
36
|
prefix: "i18n",
|
|
36
37
|
functions: true
|
|
@@ -43,10 +44,10 @@ const adapterNext = createAdapter({
|
|
|
43
44
|
nextVersion: o
|
|
44
45
|
};
|
|
45
46
|
},
|
|
46
|
-
getGenerators: (
|
|
47
|
-
let { router: t } =
|
|
47
|
+
getGenerators: (r)=>{
|
|
48
|
+
let { router: t } = r.options.adapter.options;
|
|
48
49
|
return [
|
|
49
|
-
...adapterReact.getGenerators(
|
|
50
|
+
...adapterReact.getGenerators(r),
|
|
50
51
|
o,
|
|
51
52
|
a,
|
|
52
53
|
..."app" === t || "migrating" === t ? [
|
|
@@ -66,11 +67,11 @@ const adapterNext = createAdapter({
|
|
|
66
67
|
c
|
|
67
68
|
];
|
|
68
69
|
},
|
|
69
|
-
getTransformers: (
|
|
70
|
-
let { router:
|
|
70
|
+
getTransformers: (r)=>{
|
|
71
|
+
let { router: e } = r.options.adapter.options;
|
|
71
72
|
return {
|
|
72
73
|
I18nHeadTags: false,
|
|
73
|
-
..."app" ===
|
|
74
|
+
..."app" === e ? {
|
|
74
75
|
I18nEffects: false
|
|
75
76
|
} : {}
|
|
76
77
|
};
|
|
@@ -13,32 +13,32 @@ function shouldIgnoreNextJsConfigRun() {
|
|
|
13
13
|
function transformPathname(e, t) {
|
|
14
14
|
return "/" + e.split("/").filter(Boolean).map((e)=>e.startsWith("[[...") ? `:${encodeURIComponent(e.slice(5, -2))}` : e.startsWith("[[") ? `:${encodeURIComponent(e.slice(2, -2))}` : e.startsWith("[") ? `:${encodeURIComponent(e.slice(1, -1))}` : `${encodeURIComponent(e)}`).join("/") + (t ? "/:wildcard*" : "");
|
|
15
15
|
}
|
|
16
|
-
let tweakNextConfig = (n, i,
|
|
17
|
-
let { config: { defaultLocale:
|
|
18
|
-
...
|
|
16
|
+
let tweakNextConfig = (n, i, a)=>{
|
|
17
|
+
let { config: { defaultLocale: l, locales: p }, options: { adapter: { options: { modularizeI18nImports: c } }, routes: { localeParamName: f }, write: u } } = i, { webpack: m, i18n: d, modularizeImports: w = {}, ...g } = a, R = {
|
|
18
|
+
...g,
|
|
19
19
|
modularizeImports: {
|
|
20
|
-
...createSwcTransforms.createSwcTransforms(i.options),
|
|
21
|
-
...
|
|
20
|
+
...createSwcTransforms.createSwcTransforms(i.options, c),
|
|
21
|
+
...w
|
|
22
22
|
},
|
|
23
23
|
...n.webpackPlugin && {
|
|
24
24
|
webpack: (r, i)=>{
|
|
25
|
-
let
|
|
25
|
+
let a = "function" == typeof m ? m(r, i) : r;
|
|
26
26
|
return {
|
|
27
|
-
...
|
|
27
|
+
...a,
|
|
28
28
|
plugins: [
|
|
29
|
-
...
|
|
29
|
+
...a.plugins || [],
|
|
30
30
|
new webpackPluginI18n.I18nWebpackPlugin(n),
|
|
31
31
|
new webpack.ContextReplacementPlugin(/^date-fns[/\\]locale$/, RegExp(`\\.[/\\\\](${p.join("|")})[/\\\\]index\\.js$`)),
|
|
32
|
-
|
|
32
|
+
u && new webpack.DefinePlugin(require(path.join(u.cwd, u.output, "internal/webpack-define-granular.cjs")))
|
|
33
33
|
].filter(Boolean)
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
return
|
|
38
|
+
return f ? delete R.i18n : (R.i18n = R.i18n || {
|
|
39
39
|
locales: p,
|
|
40
|
-
defaultLocale:
|
|
41
|
-
},
|
|
40
|
+
defaultLocale: l
|
|
41
|
+
}, R.i18n.locales = p, R.i18n.defaultLocale = l), R;
|
|
42
42
|
};
|
|
43
43
|
let getRedirects = async (e, t)=>{
|
|
44
44
|
let o = redirects.generateRedirects(t.config, t.options.routes, t.routes.byId);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { NextConfig } from "next";
|
|
2
2
|
import type { I18nCompilerOptions, I18nCompilerReturn } from "../../compiler";
|
|
3
|
+
import type { I18nCompilerReturnForAdapter } from "../../compiler/api";
|
|
3
4
|
/**
|
|
4
5
|
* `next.config` runs twice, running the compiler only once is enough, the condition
|
|
5
6
|
* is dependent on the environment as
|
|
@@ -24,7 +25,7 @@ export type I18nCompilerOptionsNext = {
|
|
|
24
25
|
*/
|
|
25
26
|
webpackPlugin?: boolean;
|
|
26
27
|
};
|
|
27
|
-
export declare let tweakNextConfig: (i18nCompilerOptions: I18nCompilerOptions & I18nCompilerOptionsNext, i18nCompilerReturn:
|
|
28
|
+
export declare let tweakNextConfig: (i18nCompilerOptions: I18nCompilerOptions & I18nCompilerOptionsNext, i18nCompilerReturn: I18nCompilerReturnForAdapter<"next">, options: NextConfig) => NextConfig;
|
|
28
29
|
export declare let getRedirects: (prevRedirects: NextConfig["redirects"], i18nResult: I18nCompilerReturn) => Promise<import("next/dist/lib/load-custom-routes").Redirect[]>;
|
|
29
30
|
export declare let getRewrites: (prevRewrites: NextConfig["rewrites"], i18nResult: I18nCompilerReturn) => Promise<{
|
|
30
31
|
beforeFiles: import("next/dist/lib/load-custom-routes").Rewrite[];
|
|
@@ -11,32 +11,32 @@ function shouldIgnoreNextJsConfigRun() {
|
|
|
11
11
|
function transformPathname(e, t) {
|
|
12
12
|
return "/" + e.split("/").filter(Boolean).map((e)=>e.startsWith("[[...") ? `:${encodeURIComponent(e.slice(5, -2))}` : e.startsWith("[[") ? `:${encodeURIComponent(e.slice(2, -2))}` : e.startsWith("[") ? `:${encodeURIComponent(e.slice(1, -1))}` : `${encodeURIComponent(e)}`).join("/") + (t ? "/:wildcard*" : "");
|
|
13
13
|
}
|
|
14
|
-
let tweakNextConfig = (n, i,
|
|
15
|
-
let { config: { defaultLocale:
|
|
16
|
-
...
|
|
14
|
+
let tweakNextConfig = (n, i, a)=>{
|
|
15
|
+
let { config: { defaultLocale: l, locales: p }, options: { adapter: { options: { modularizeI18nImports: c } }, routes: { localeParamName: f }, write: u } } = i, { webpack: m, i18n: d, modularizeImports: w = {}, ...g } = a, R = {
|
|
16
|
+
...g,
|
|
17
17
|
modularizeImports: {
|
|
18
|
-
...createSwcTransforms(i.options),
|
|
19
|
-
...
|
|
18
|
+
...createSwcTransforms(i.options, c),
|
|
19
|
+
...w
|
|
20
20
|
},
|
|
21
21
|
...n.webpackPlugin && {
|
|
22
22
|
webpack: (r, i)=>{
|
|
23
|
-
let
|
|
23
|
+
let a = "function" == typeof m ? m(r, i) : r;
|
|
24
24
|
return {
|
|
25
|
-
...
|
|
25
|
+
...a,
|
|
26
26
|
plugins: [
|
|
27
|
-
...
|
|
27
|
+
...a.plugins || [],
|
|
28
28
|
new I18nWebpackPlugin(n),
|
|
29
29
|
new ContextReplacementPlugin(/^date-fns[/\\]locale$/, RegExp(`\\.[/\\\\](${p.join("|")})[/\\\\]index\\.js$`)),
|
|
30
|
-
|
|
30
|
+
u && new DefinePlugin(require(join(u.cwd, u.output, "internal/webpack-define-granular.cjs")))
|
|
31
31
|
].filter(Boolean)
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
return
|
|
36
|
+
return f ? delete R.i18n : (R.i18n = R.i18n || {
|
|
37
37
|
locales: p,
|
|
38
|
-
defaultLocale:
|
|
39
|
-
},
|
|
38
|
+
defaultLocale: l
|
|
39
|
+
}, R.i18n.locales = p, R.i18n.defaultLocale = l), R;
|
|
40
40
|
};
|
|
41
41
|
let getRedirects = async (e, t)=>{
|
|
42
42
|
let o = generateRedirects(t.config, t.options.routes, t.routes.byId);
|
package/compiler/api.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type CodeDataOptions, type CodeWriteOptions } from "./code";
|
|
1
|
+
import { type CodeDataOptions, type CodeDataOptionsResolved, type CodeWriteOptions } from "./code";
|
|
2
2
|
import { type I18nCompilerConfig } from "./config";
|
|
3
3
|
import { type InputDataOptions, type InputWriteOptions } from "./input";
|
|
4
4
|
import { type SummaryDataOptions, type SummaryWriteOptions } from "./summary";
|
|
5
|
+
import type { I18nCompiler } from "./types";
|
|
5
6
|
type OptionsInput = InputDataOptions & {
|
|
6
7
|
/**
|
|
7
8
|
* Options for _input_ writing
|
|
@@ -33,10 +34,13 @@ export type I18nCompilerOptions = I18nCompilerConfig & {
|
|
|
33
34
|
};
|
|
34
35
|
};
|
|
35
36
|
export type I18nCompilerReturn = Awaited<ReturnType<typeof i18nCompiler>>;
|
|
37
|
+
export type I18nCompilerReturnForAdapter<TAdapterName extends I18nCompiler.AdapterName> = Omit<I18nCompilerReturn, "options"> & {
|
|
38
|
+
options: CodeDataOptionsResolved<TAdapterName>;
|
|
39
|
+
};
|
|
36
40
|
/**
|
|
37
41
|
* i18nCompiler async api
|
|
38
42
|
*
|
|
39
43
|
* @public
|
|
40
44
|
*/
|
|
41
|
-
export declare let i18nCompiler: (options: I18nCompilerOptions) => Promise<
|
|
45
|
+
export declare let i18nCompiler: (options: I18nCompilerOptions) => Promise<I18nCompiler.DataCode<I18nCompiler.AdapterName>>;
|
|
42
46
|
export {};
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var swc = require('@koine/node/swc');
|
|
4
4
|
|
|
5
|
-
let createSwcTransforms = (e)=>{
|
|
6
|
-
let { write:
|
|
5
|
+
let createSwcTransforms = (e, o)=>{
|
|
6
|
+
let { write: n } = e, r = n?.tsconfig ? n.tsconfig.alias : "";
|
|
7
7
|
return {
|
|
8
8
|
...swc.swcCreateTransform({
|
|
9
9
|
path: "@koine/i18n"
|
|
10
10
|
}),
|
|
11
|
-
...
|
|
12
|
-
path:
|
|
11
|
+
...o && r ? swc.swcCreateTransform({
|
|
12
|
+
path: r
|
|
13
13
|
}) : {}
|
|
14
14
|
};
|
|
15
15
|
};
|
|
@@ -3,7 +3,9 @@ import type { CodeDataOptionsResolved } from "./code";
|
|
|
3
3
|
/**
|
|
4
4
|
* Automatically create swc transforms based on given options
|
|
5
5
|
*/
|
|
6
|
-
export declare let createSwcTransforms: (resolvedOptions: PickDeep<CodeDataOptionsResolved, "write.tsconfig"
|
|
6
|
+
export declare let createSwcTransforms: (resolvedOptions: PickDeep<CodeDataOptionsResolved, "write.tsconfig">,
|
|
7
|
+
/** */
|
|
8
|
+
modularizeI18nImports?: boolean) => {
|
|
7
9
|
[x: `${string}/?(((\\$*\\w*)?/?)*)`]: {
|
|
8
10
|
transform: `${string}/{{member}}`;
|
|
9
11
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { swcCreateTransform } from '@koine/node/swc';
|
|
2
2
|
|
|
3
|
-
let createSwcTransforms = (e)=>{
|
|
4
|
-
let { write:
|
|
3
|
+
let createSwcTransforms = (e, o)=>{
|
|
4
|
+
let { write: n } = e, r = n?.tsconfig ? n.tsconfig.alias : "";
|
|
5
5
|
return {
|
|
6
6
|
...swcCreateTransform({
|
|
7
7
|
path: "@koine/i18n"
|
|
8
8
|
}),
|
|
9
|
-
...
|
|
10
|
-
path:
|
|
9
|
+
...o && r ? swcCreateTransform({
|
|
10
|
+
path: r
|
|
11
11
|
}) : {}
|
|
12
12
|
};
|
|
13
13
|
};
|
package/package.json
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
"node": ">=18.0.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@koine/dom": "2.0.0-beta.
|
|
9
|
-
"@koine/node": "2.0.0-beta.
|
|
10
|
-
"@koine/utils": "2.0.0-beta.
|
|
8
|
+
"@koine/dom": "2.0.0-beta.205",
|
|
9
|
+
"@koine/node": "2.0.0-beta.205",
|
|
10
|
+
"@koine/utils": "2.0.0-beta.205",
|
|
11
11
|
"comment-json": "^4.2.4",
|
|
12
12
|
"consola": "^3.2.3",
|
|
13
13
|
"glob": "^11.0.0",
|
|
@@ -130,5 +130,5 @@
|
|
|
130
130
|
"module": "./index.esm.js",
|
|
131
131
|
"main": "./index.cjs.js",
|
|
132
132
|
"types": "./index.d.ts",
|
|
133
|
-
"version": "2.0.0-beta.
|
|
133
|
+
"version": "2.0.0-beta.205"
|
|
134
134
|
}
|