@koine/i18n 2.0.0-beta.149 → 2.0.0-beta.152

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.
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var swc = require('@koine/node/swc');
3
4
  var createAdapter = require('../../compiler/createAdapter.cjs.js');
4
5
 
5
- var o = createAdapter.createGenerator("js", (e)=>{
6
- let { config: o } = e, l = `[${o.locales.map((e)=>`"${e}"`).join(", ")}]`;
6
+ var o = createAdapter.createGenerator("js", (o)=>{
7
+ let { config: a } = o, l = `[${a.locales.map((e)=>`"${e}"`).join(", ")}]`;
7
8
  return {
8
9
  locales: {
9
10
  name: "locales",
@@ -22,7 +23,7 @@ export default locales;
22
23
  content: ()=>`
23
24
  import type { I18n } from "./types";
24
25
 
25
- export const defaultLocale: I18n.Locale = "${o.defaultLocale}";
26
+ export const defaultLocale: I18n.Locale = "${a.defaultLocale}";
26
27
 
27
28
  export default defaultLocale;
28
29
  `
@@ -41,7 +42,7 @@ import { defaultLocale } from "./defaultLocale";
41
42
  export const config = {
42
43
  locales,
43
44
  defaultLocale,
44
- hideDefaultLocaleInUrl: ${o.hideDefaultLocaleInUrl},
45
+ hideDefaultLocaleInUrl: ${a.hideDefaultLocaleInUrl},
45
46
  }
46
47
 
47
48
  export default config;
@@ -59,13 +60,59 @@ const { defaultLocale } = require("./defaultLocale");
59
60
  const config = {
60
61
  locales,
61
62
  defaultLocale,
62
- hideDefaultLocaleInUrl: ${o.hideDefaultLocaleInUrl},
63
+ hideDefaultLocaleInUrl: ${a.hideDefaultLocaleInUrl},
63
64
  };
64
65
 
65
66
  exports.config = config;
66
67
 
67
68
  module.exports = config;
68
69
  `
70
+ },
71
+ swcTransforms: {
72
+ name: "i18nSwcTransforms",
73
+ ext: "js",
74
+ index: !1,
75
+ disabled: !o.options.adapter.modularize,
76
+ content: ()=>{
77
+ let { tsconfig: a } = o.options.write || {};
78
+ if (!a) return "";
79
+ let l = swc.swcCreateTransforms([
80
+ {
81
+ path: "@koine/i18n",
82
+ flat: !0
83
+ },
84
+ {
85
+ path: a.alias,
86
+ flat: !0
87
+ },
88
+ {
89
+ path: a.alias + "/" + o.options.routes.functions.dir,
90
+ flat: !0
91
+ },
92
+ {
93
+ path: a.alias + "/" + o.options.translations.functions.dir,
94
+ flat: !0
95
+ },
96
+ {
97
+ path: a.alias + "/" + createAdapter.createGenerator.dirs.server,
98
+ flat: !0
99
+ }
100
+ ]), n = swc.swcCreateTransforms([
101
+ {
102
+ path: "@koine/i18n",
103
+ flat: !0
104
+ },
105
+ {
106
+ path: a.alias
107
+ }
108
+ ]);
109
+ return `
110
+ export const i18nSwcTransforms = {
111
+ flat: ${JSON.stringify(l, null, 2)};
112
+ deep: ${JSON.stringify(n, null, 2)};
113
+ }
114
+ `;
115
+ }
69
116
  }
70
117
  };
71
118
  });
@@ -25,5 +25,12 @@ declare const _default: (data: import("../../compiler").I18nCompiler.DataCode<"j
25
25
  disabled: true;
26
26
  content: () => string;
27
27
  };
28
+ swcTransforms: {
29
+ name: string;
30
+ ext: "js";
31
+ index: false;
32
+ disabled: boolean;
33
+ content: () => string;
34
+ };
28
35
  };
29
36
  export default _default;
@@ -1,7 +1,8 @@
1
+ import { swcCreateTransforms } from '@koine/node/swc';
1
2
  import { createGenerator } from '../../compiler/createAdapter.esm.js';
2
3
 
3
- var o = createGenerator("js", (e)=>{
4
- let { config: o } = e, l = `[${o.locales.map((e)=>`"${e}"`).join(", ")}]`;
4
+ var o = createGenerator("js", (o)=>{
5
+ let { config: a } = o, l = `[${a.locales.map((e)=>`"${e}"`).join(", ")}]`;
5
6
  return {
6
7
  locales: {
7
8
  name: "locales",
@@ -20,7 +21,7 @@ export default locales;
20
21
  content: ()=>`
21
22
  import type { I18n } from "./types";
22
23
 
23
- export const defaultLocale: I18n.Locale = "${o.defaultLocale}";
24
+ export const defaultLocale: I18n.Locale = "${a.defaultLocale}";
24
25
 
25
26
  export default defaultLocale;
26
27
  `
@@ -39,7 +40,7 @@ import { defaultLocale } from "./defaultLocale";
39
40
  export const config = {
40
41
  locales,
41
42
  defaultLocale,
42
- hideDefaultLocaleInUrl: ${o.hideDefaultLocaleInUrl},
43
+ hideDefaultLocaleInUrl: ${a.hideDefaultLocaleInUrl},
43
44
  }
44
45
 
45
46
  export default config;
@@ -57,13 +58,59 @@ const { defaultLocale } = require("./defaultLocale");
57
58
  const config = {
58
59
  locales,
59
60
  defaultLocale,
60
- hideDefaultLocaleInUrl: ${o.hideDefaultLocaleInUrl},
61
+ hideDefaultLocaleInUrl: ${a.hideDefaultLocaleInUrl},
61
62
  };
62
63
 
63
64
  exports.config = config;
64
65
 
65
66
  module.exports = config;
66
67
  `
68
+ },
69
+ swcTransforms: {
70
+ name: "i18nSwcTransforms",
71
+ ext: "js",
72
+ index: !1,
73
+ disabled: !o.options.adapter.modularize,
74
+ content: ()=>{
75
+ let { tsconfig: a } = o.options.write || {};
76
+ if (!a) return "";
77
+ let l = swcCreateTransforms([
78
+ {
79
+ path: "@koine/i18n",
80
+ flat: !0
81
+ },
82
+ {
83
+ path: a.alias,
84
+ flat: !0
85
+ },
86
+ {
87
+ path: a.alias + "/" + o.options.routes.functions.dir,
88
+ flat: !0
89
+ },
90
+ {
91
+ path: a.alias + "/" + o.options.translations.functions.dir,
92
+ flat: !0
93
+ },
94
+ {
95
+ path: a.alias + "/" + createGenerator.dirs.server,
96
+ flat: !0
97
+ }
98
+ ]), n = swcCreateTransforms([
99
+ {
100
+ path: "@koine/i18n",
101
+ flat: !0
102
+ },
103
+ {
104
+ path: a.alias
105
+ }
106
+ ]);
107
+ return `
108
+ export const i18nSwcTransforms = {
109
+ flat: ${JSON.stringify(l, null, 2)};
110
+ deep: ${JSON.stringify(n, null, 2)};
111
+ }
112
+ `;
113
+ }
67
114
  }
68
115
  };
69
116
  });
@@ -46,7 +46,7 @@ declare global {
46
46
  webpackDefineGranular: {
47
47
  dir: createAdapter.createGenerator.dirs.internal,
48
48
  name: "webpack-define-granular",
49
- ext: "js",
49
+ ext: "cjs",
50
50
  index: !1,
51
51
  content: ()=>`
52
52
  const { join } = require("path");
@@ -139,7 +139,7 @@ declare global {
139
139
  disabled: !0,
140
140
  dir: createAdapter.createGenerator.dirs.internal,
141
141
  name: "webpack-define-compact",
142
- ext: "js",
142
+ ext: "cjs",
143
143
  index: !1,
144
144
  content: ()=>`
145
145
  const { join } = require("path");
@@ -24,7 +24,7 @@ declare const _default: (data: import("../../compiler").I18nCompiler.DataCode<"n
24
24
  webpackDefineGranular: {
25
25
  dir: string;
26
26
  name: string;
27
- ext: "js";
27
+ ext: "cjs";
28
28
  index: false;
29
29
  content: () => string;
30
30
  };
@@ -40,7 +40,7 @@ declare const _default: (data: import("../../compiler").I18nCompiler.DataCode<"n
40
40
  disabled: true;
41
41
  dir: string;
42
42
  name: string;
43
- ext: "js";
43
+ ext: "cjs";
44
44
  index: false;
45
45
  content: () => string;
46
46
  };
@@ -44,7 +44,7 @@ declare global {
44
44
  webpackDefineGranular: {
45
45
  dir: createGenerator.dirs.internal,
46
46
  name: "webpack-define-granular",
47
- ext: "js",
47
+ ext: "cjs",
48
48
  index: !1,
49
49
  content: ()=>`
50
50
  const { join } = require("path");
@@ -137,7 +137,7 @@ declare global {
137
137
  disabled: !0,
138
138
  dir: createGenerator.dirs.internal,
139
139
  name: "webpack-define-compact",
140
- ext: "js",
140
+ ext: "cjs",
141
141
  index: !1,
142
142
  content: ()=>`
143
143
  const { join } = require("path");
@@ -32,73 +32,73 @@ function _interopNamespaceDefault(e) {
32
32
  var t__namespace = /*#__PURE__*/_interopNamespaceDefault(t);
33
33
 
34
34
  let writeCode = async (t, e, o)=>{
35
- let i = getWriteCodeConfig(t, e), n = await generate.generateCode(o);
36
- return await x(i), await R(i, n), v(i), W(i, n), await _(i, o.input), J(i), i;
35
+ let n = getWriteCodeConfig(t, e), i = await generate.generateCode(o);
36
+ return await x(n), await j(n, i), v(n), W(n, i), await _(n, o.input), J(n), n;
37
37
  };
38
38
  function resolveWriteCodeOptions(t) {
39
- let { cwd: e = process.cwd(), output: o, emptyOutputFolder: i = !0, tsconfig: n = {}, typescriptCompilation: r = !1, tsNoCheck: s = !process.env.JEST_WORKER_ID, eslintDisable: l = !process.env.JEST_WORKER_ID, copyTranslations: a = !0, gitignore: f = "all" } = t;
39
+ let { cwd: e = process.cwd(), output: o, emptyOutputFolder: n = !0, tsconfig: i = {}, typescriptCompilation: r = !1, tsNoCheck: s = !process.env.JEST_WORKER_ID, eslintDisable: l = !process.env.JEST_WORKER_ID, copyTranslations: a = !0, gitignore: c = "all" } = t;
40
40
  return {
41
41
  cwd: e,
42
42
  output: o,
43
- emptyOutputFolder: i,
43
+ emptyOutputFolder: n,
44
44
  tsconfig: {
45
45
  path: "../tsconfig.json",
46
46
  alias: `@/${o.split(node_path.sep).filter(Boolean).pop() || "i18n"}`,
47
- ...n
47
+ ...i
48
48
  },
49
49
  typescriptCompilation: r,
50
50
  tsNoCheck: s,
51
51
  eslintDisable: l,
52
52
  copyTranslations: a,
53
- gitignore: f
53
+ gitignore: c
54
54
  };
55
55
  }
56
56
  function getWriteCodeConfig(t, e) {
57
- let o = new Set(), i = new Set();
57
+ let o = new Set(), n = new Set();
58
58
  return {
59
59
  debug: t.debug,
60
60
  ...e,
61
61
  files: o,
62
- folders: i
62
+ folders: n
63
63
  };
64
64
  }
65
65
  async function x(t) {
66
- let { cwd: e, output: o, emptyOutputFolder: i } = t;
67
- i && await promises.rm(node_path.join(e, o), {
66
+ let { cwd: e, output: o, emptyOutputFolder: n } = t;
67
+ n && await promises.rm(node_path.join(e, o), {
68
68
  force: !0,
69
69
  recursive: !0
70
70
  });
71
71
  }
72
72
  function S(t, e) {
73
- let { path: o, dir: i } = e;
74
- i && "." !== i ? t.folders.add(i) : t.files.add(o);
73
+ let { path: o, dir: n } = e;
74
+ n && "." !== n ? t.folders.add(n) : t.files.add(o);
75
75
  }
76
76
  let C = (t, e)=>{
77
- let { tsNoCheck: o, eslintDisable: i } = t, { ext: n } = e, { content: r } = e;
78
- r = r.trim(), e.isBarrel || (o && ("d.ts" === n || "ts" === n || "tsx" === n) && (r = `// @ts-nocheck\n` + r), i && ("js" === n || "mjs" === n || "d.ts" === n || "ts" === n || "tsx" === n) && (r = `/* eslint-disable */\n` + r), e.content = r);
77
+ let { tsNoCheck: o, eslintDisable: n } = t, { ext: i } = e, { content: r } = e;
78
+ r = r.trim(), o && ("d.ts" === i || "ts" === i || "tsx" === i) && (r = `// @ts-nocheck\n` + r), n && ("js" === i || "cjs" === i || "mjs" === i || "d.ts" === i || "ts" === i || "tsx" === i) && (r = `/* eslint-disable */\n` + r), e.content = r;
79
79
  };
80
80
  function E(t, e) {
81
- let { path: o } = e, i = node_path.join(t.cwd, t.output, o);
82
- return S(t, e), C(t, e), i;
81
+ let { path: o } = e, n = node_path.join(t.cwd, t.output, o);
82
+ return S(t, e), C(t, e), n;
83
83
  }
84
- async function R(t, e) {
84
+ async function j(t, e) {
85
85
  return Promise.all(e.files.map(async (e)=>{
86
86
  let o = E(t, e);
87
87
  await node.fsWrite(o, e.content);
88
88
  }));
89
89
  }
90
- function j(t, e) {
91
- let { cwd: o, output: i, tsconfig: n } = t;
92
- if (!n) return;
93
- let { alias: r } = n, p = `${r}/*`, f = node_path.join(o, i), c = node_path.relative(node_path.dirname(node_path.join(o, n.path)), f);
94
- e.compilerOptions = e.compilerOptions || {}, e.compilerOptions.paths = e.compilerOptions.paths || {}, e.compilerOptions.baseUrl || (c = `./${c}`);
95
- let d = new Set(e.compilerOptions.paths[r] || []), m = new Set(e.compilerOptions.paths[p] || []), u = c + "/index.ts", h = c + "/*";
90
+ function R(t, e) {
91
+ let { cwd: o, output: n, tsconfig: i } = t;
92
+ if (!i) return;
93
+ let { alias: r } = i, p = `${r}/*`, c = node_path.join(o, n), f = node_path.relative(node_path.dirname(node_path.join(o, i.path)), c);
94
+ e.compilerOptions = e.compilerOptions || {}, e.compilerOptions.paths = e.compilerOptions.paths || {}, e.compilerOptions.baseUrl || (f = `./${f}`);
95
+ let d = new Set(e.compilerOptions.paths[r] || []), m = new Set(e.compilerOptions.paths[p] || []), u = f + "/index.ts", h = f + "/*";
96
96
  if (!d.has(u) || !m.has(h)) return d.add(u), m.add(h), e.compilerOptions.paths[r] = Array.from(d), e.compilerOptions.paths[p] = Array.from(m), e;
97
97
  }
98
98
  function v(o) {
99
- let { cwd: n, debug: s, tsconfig: a } = o;
99
+ let { cwd: i, debug: s, tsconfig: a } = o;
100
100
  if (!a) return;
101
- let p = node_path.join(n, a.path), d = !1, m = {
101
+ let p = node_path.join(i, a.path), d = !1, m = {
102
102
  compilerOptions: {
103
103
  baseUrl: ".",
104
104
  paths: {}
@@ -107,23 +107,23 @@ function v(o) {
107
107
  if (node_fs.existsSync(p)) try {
108
108
  let t = node_fs.readFileSync(p, {
109
109
  encoding: "utf-8"
110
- }), i = commentJson.parse(t), n = j(o, i);
111
- n && (d = !0, m = n);
110
+ }), n = commentJson.parse(t), i = R(o, n);
111
+ i && (d = !0, m = i);
112
112
  } catch (t) {
113
113
  logger.i18nLogger.info(`Failed to read tsconfig at given ${a.path}`), logger.i18nLogger.info("a tsconfig.json file will be created at the given path.");
114
114
  }
115
115
  else {
116
- let t = j(o, m);
116
+ let t = R(o, m);
117
117
  t && (d = !0, m = t);
118
118
  }
119
119
  let u = commentJson.stringify(m, null, 2);
120
120
  d ? (node_fs.writeFileSync(p, u + node_os.EOL), (s || process.env.JEST_WORKER_ID) && logger.i18nLogger.log("i18n: tsconfig.json updated. You need to manually check 'paths' are setup correctly.")) : (s || process.env.JEST_WORKER_ID) && logger.i18nLogger.info("i18n: tsconfig.json is up to date.");
121
121
  }
122
122
  function W(t, e) {
123
- let { cwd: i, output: n, typescriptCompilation: r } = t;
123
+ let { cwd: n, output: i, typescriptCompilation: r } = t;
124
124
  if (!r) return;
125
125
  let s = e.files.filter((t)=>"d.ts" === t.ext || "ts" === t.ext || "tsx" === t.ext);
126
- tsCompile.tsCompile(i, n, s.map((t)=>t.path), {
126
+ tsCompile.tsCompile(n, i, s.map((t)=>t.path), {
127
127
  module: t__namespace.ModuleKind.CommonJS,
128
128
  moduleResolution: t__namespace.ModuleResolutionKind.Bundler
129
129
  }), s.forEach((e)=>{
@@ -133,26 +133,26 @@ function W(t, e) {
133
133
  }), S(t, {
134
134
  ...e,
135
135
  path: e.path.replace(/\.tsx?$/, ".d.ts")
136
- }), t.files.delete(e.path), node_fs.rmSync(node_path.join(i, n, e.path), {
136
+ }), t.files.delete(e.path), node_fs.rmSync(node_path.join(n, i, e.path), {
137
137
  force: !0
138
138
  });
139
139
  });
140
140
  }
141
141
  async function _(t, { translationFiles: e }) {
142
- let { cwd: o, output: i, copyTranslations: n } = t;
143
- n && Promise.all(e.map(async ({ data: e, locale: n, path: r })=>{
144
- let s = node_path.join(helpers.getTranslationsDir(0), n);
145
- await node.fsWrite(node_path.join(o, i, s, r), JSON.stringify(e)), t.folders.add(s);
142
+ let { cwd: o, output: n, copyTranslations: i } = t;
143
+ i && Promise.all(e.map(async ({ data: e, locale: i, path: r })=>{
144
+ let s = node_path.join(helpers.getTranslationsDir(0), i);
145
+ await node.fsWrite(node_path.join(o, n, s, r), JSON.stringify(e)), t.folders.add(s);
146
146
  }));
147
147
  }
148
148
  function J(t) {
149
- let { cwd: e, output: o, gitignore: i } = t;
150
- if (!i) return;
151
- let n = "";
152
- "granular" === i ? n = Array.from(new Set([
149
+ let { cwd: e, output: o, gitignore: n } = t;
150
+ if (!n) return;
151
+ let i = "";
152
+ "granular" === n ? i = Array.from(new Set([
153
153
  ...t.folders,
154
154
  ...t.files
155
- ])).sort().map((t)=>`/${t}`).join(`\n`) : "all" === i && (n = "**/*\n!.gitignore"), node.fsWriteSync(node_path.join(e, o, ".gitignore"), n);
155
+ ])).sort().map((t)=>`/${t}`).join(`\n`) : "all" === n && (i = "**/*\n!.gitignore"), node.fsWriteSync(node_path.join(e, o, ".gitignore"), i);
156
156
  }
157
157
 
158
158
  exports.getWriteCodeConfig = getWriteCodeConfig;
@@ -11,73 +11,73 @@ import { generateCode } from './generate.esm.js';
11
11
  import { tsCompile } from './tsCompile.esm.js';
12
12
 
13
13
  let writeCode = async (t, e, o)=>{
14
- let i = getWriteCodeConfig(t, e), n = await generateCode(o);
15
- return await x(i), await R(i, n), v(i), W(i, n), await _(i, o.input), J(i), i;
14
+ let n = getWriteCodeConfig(t, e), i = await generateCode(o);
15
+ return await x(n), await j(n, i), v(n), W(n, i), await _(n, o.input), J(n), n;
16
16
  };
17
17
  function resolveWriteCodeOptions(t) {
18
- let { cwd: e = process.cwd(), output: o, emptyOutputFolder: i = !0, tsconfig: n = {}, typescriptCompilation: r = !1, tsNoCheck: s = !process.env.JEST_WORKER_ID, eslintDisable: l = !process.env.JEST_WORKER_ID, copyTranslations: a = !0, gitignore: f = "all" } = t;
18
+ let { cwd: e = process.cwd(), output: o, emptyOutputFolder: n = !0, tsconfig: i = {}, typescriptCompilation: r = !1, tsNoCheck: s = !process.env.JEST_WORKER_ID, eslintDisable: l = !process.env.JEST_WORKER_ID, copyTranslations: a = !0, gitignore: c = "all" } = t;
19
19
  return {
20
20
  cwd: e,
21
21
  output: o,
22
- emptyOutputFolder: i,
22
+ emptyOutputFolder: n,
23
23
  tsconfig: {
24
24
  path: "../tsconfig.json",
25
25
  alias: `@/${o.split(sep).filter(Boolean).pop() || "i18n"}`,
26
- ...n
26
+ ...i
27
27
  },
28
28
  typescriptCompilation: r,
29
29
  tsNoCheck: s,
30
30
  eslintDisable: l,
31
31
  copyTranslations: a,
32
- gitignore: f
32
+ gitignore: c
33
33
  };
34
34
  }
35
35
  function getWriteCodeConfig(t, e) {
36
- let o = new Set(), i = new Set();
36
+ let o = new Set(), n = new Set();
37
37
  return {
38
38
  debug: t.debug,
39
39
  ...e,
40
40
  files: o,
41
- folders: i
41
+ folders: n
42
42
  };
43
43
  }
44
44
  async function x(t) {
45
- let { cwd: e, output: o, emptyOutputFolder: i } = t;
46
- i && await rm(join(e, o), {
45
+ let { cwd: e, output: o, emptyOutputFolder: n } = t;
46
+ n && await rm(join(e, o), {
47
47
  force: !0,
48
48
  recursive: !0
49
49
  });
50
50
  }
51
51
  function S(t, e) {
52
- let { path: o, dir: i } = e;
53
- i && "." !== i ? t.folders.add(i) : t.files.add(o);
52
+ let { path: o, dir: n } = e;
53
+ n && "." !== n ? t.folders.add(n) : t.files.add(o);
54
54
  }
55
55
  let C = (t, e)=>{
56
- let { tsNoCheck: o, eslintDisable: i } = t, { ext: n } = e, { content: r } = e;
57
- r = r.trim(), e.isBarrel || (o && ("d.ts" === n || "ts" === n || "tsx" === n) && (r = `// @ts-nocheck\n` + r), i && ("js" === n || "mjs" === n || "d.ts" === n || "ts" === n || "tsx" === n) && (r = `/* eslint-disable */\n` + r), e.content = r);
56
+ let { tsNoCheck: o, eslintDisable: n } = t, { ext: i } = e, { content: r } = e;
57
+ r = r.trim(), o && ("d.ts" === i || "ts" === i || "tsx" === i) && (r = `// @ts-nocheck\n` + r), n && ("js" === i || "cjs" === i || "mjs" === i || "d.ts" === i || "ts" === i || "tsx" === i) && (r = `/* eslint-disable */\n` + r), e.content = r;
58
58
  };
59
59
  function E(t, e) {
60
- let { path: o } = e, i = join(t.cwd, t.output, o);
61
- return S(t, e), C(t, e), i;
60
+ let { path: o } = e, n = join(t.cwd, t.output, o);
61
+ return S(t, e), C(t, e), n;
62
62
  }
63
- async function R(t, e) {
63
+ async function j(t, e) {
64
64
  return Promise.all(e.files.map(async (e)=>{
65
65
  let o = E(t, e);
66
66
  await fsWrite(o, e.content);
67
67
  }));
68
68
  }
69
- function j(t, e) {
70
- let { cwd: o, output: i, tsconfig: n } = t;
71
- if (!n) return;
72
- let { alias: r } = n, p = `${r}/*`, f = join(o, i), c = relative(dirname(join(o, n.path)), f);
73
- e.compilerOptions = e.compilerOptions || {}, e.compilerOptions.paths = e.compilerOptions.paths || {}, e.compilerOptions.baseUrl || (c = `./${c}`);
74
- let d = new Set(e.compilerOptions.paths[r] || []), m = new Set(e.compilerOptions.paths[p] || []), u = c + "/index.ts", h = c + "/*";
69
+ function R(t, e) {
70
+ let { cwd: o, output: n, tsconfig: i } = t;
71
+ if (!i) return;
72
+ let { alias: r } = i, p = `${r}/*`, c = join(o, n), f = relative(dirname(join(o, i.path)), c);
73
+ e.compilerOptions = e.compilerOptions || {}, e.compilerOptions.paths = e.compilerOptions.paths || {}, e.compilerOptions.baseUrl || (f = `./${f}`);
74
+ let d = new Set(e.compilerOptions.paths[r] || []), m = new Set(e.compilerOptions.paths[p] || []), u = f + "/index.ts", h = f + "/*";
75
75
  if (!d.has(u) || !m.has(h)) return d.add(u), m.add(h), e.compilerOptions.paths[r] = Array.from(d), e.compilerOptions.paths[p] = Array.from(m), e;
76
76
  }
77
77
  function v(o) {
78
- let { cwd: n, debug: s, tsconfig: a } = o;
78
+ let { cwd: i, debug: s, tsconfig: a } = o;
79
79
  if (!a) return;
80
- let p = join(n, a.path), d = !1, m = {
80
+ let p = join(i, a.path), d = !1, m = {
81
81
  compilerOptions: {
82
82
  baseUrl: ".",
83
83
  paths: {}
@@ -86,23 +86,23 @@ function v(o) {
86
86
  if (existsSync(p)) try {
87
87
  let t = readFileSync(p, {
88
88
  encoding: "utf-8"
89
- }), i = parse(t), n = j(o, i);
90
- n && (d = !0, m = n);
89
+ }), n = parse(t), i = R(o, n);
90
+ i && (d = !0, m = i);
91
91
  } catch (t) {
92
92
  i18nLogger.info(`Failed to read tsconfig at given ${a.path}`), i18nLogger.info("a tsconfig.json file will be created at the given path.");
93
93
  }
94
94
  else {
95
- let t = j(o, m);
95
+ let t = R(o, m);
96
96
  t && (d = !0, m = t);
97
97
  }
98
98
  let u = stringify(m, null, 2);
99
99
  d ? (writeFileSync(p, u + EOL), (s || process.env.JEST_WORKER_ID) && i18nLogger.log("i18n: tsconfig.json updated. You need to manually check 'paths' are setup correctly.")) : (s || process.env.JEST_WORKER_ID) && i18nLogger.info("i18n: tsconfig.json is up to date.");
100
100
  }
101
101
  function W(t$1, e) {
102
- let { cwd: i, output: n, typescriptCompilation: r } = t$1;
102
+ let { cwd: n, output: i, typescriptCompilation: r } = t$1;
103
103
  if (!r) return;
104
104
  let s = e.files.filter((t)=>"d.ts" === t.ext || "ts" === t.ext || "tsx" === t.ext);
105
- tsCompile(i, n, s.map((t)=>t.path), {
105
+ tsCompile(n, i, s.map((t)=>t.path), {
106
106
  module: t.ModuleKind.CommonJS,
107
107
  moduleResolution: t.ModuleResolutionKind.Bundler
108
108
  }), s.forEach((e)=>{
@@ -112,26 +112,26 @@ function W(t$1, e) {
112
112
  }), S(t$1, {
113
113
  ...e,
114
114
  path: e.path.replace(/\.tsx?$/, ".d.ts")
115
- }), t$1.files.delete(e.path), rmSync(join(i, n, e.path), {
115
+ }), t$1.files.delete(e.path), rmSync(join(n, i, e.path), {
116
116
  force: !0
117
117
  });
118
118
  });
119
119
  }
120
120
  async function _(t, { translationFiles: e }) {
121
- let { cwd: o, output: i, copyTranslations: n } = t;
122
- n && Promise.all(e.map(async ({ data: e, locale: n, path: r })=>{
123
- let s = join(getTranslationsDir(0), n);
124
- await fsWrite(join(o, i, s, r), JSON.stringify(e)), t.folders.add(s);
121
+ let { cwd: o, output: n, copyTranslations: i } = t;
122
+ i && Promise.all(e.map(async ({ data: e, locale: i, path: r })=>{
123
+ let s = join(getTranslationsDir(0), i);
124
+ await fsWrite(join(o, n, s, r), JSON.stringify(e)), t.folders.add(s);
125
125
  }));
126
126
  }
127
127
  function J(t) {
128
- let { cwd: e, output: o, gitignore: i } = t;
129
- if (!i) return;
130
- let n = "";
131
- "granular" === i ? n = Array.from(new Set([
128
+ let { cwd: e, output: o, gitignore: n } = t;
129
+ if (!n) return;
130
+ let i = "";
131
+ "granular" === n ? i = Array.from(new Set([
132
132
  ...t.folders,
133
133
  ...t.files
134
- ])).sort().map((t)=>`/${t}`).join(`\n`) : "all" === i && (n = "**/*\n!.gitignore"), fsWriteSync(join(e, o, ".gitignore"), n);
134
+ ])).sort().map((t)=>`/${t}`).join(`\n`) : "all" === n && (i = "**/*\n!.gitignore"), fsWriteSync(join(e, o, ".gitignore"), i);
135
135
  }
136
136
 
137
137
  export { getWriteCodeConfig, resolveWriteCodeOptions, writeCode };
@@ -301,7 +301,7 @@ export declare namespace I18nCompiler {
301
301
  /**
302
302
  * File extension
303
303
  */
304
- ext: "d.ts" | "ts" | "tsx" | "mjs" | "js" | "json";
304
+ ext: "d.ts" | "ts" | "tsx" | "cjs" | "mjs" | "js" | "json";
305
305
  /**
306
306
  * Function that generates the file content
307
307
  */
package/package.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "node": "^14.18.0 || >=16.0.0"
6
6
  },
7
7
  "dependencies": {
8
- "@koine/node": "2.0.0-beta.149",
9
- "@koine/utils": "2.0.0-beta.149",
8
+ "@koine/node": "2.0.0-beta.152",
9
+ "@koine/utils": "2.0.0-beta.152",
10
10
  "comment-json": "^4.2.4",
11
11
  "consola": "^3.2.3",
12
12
  "glob": "^11.0.0",
@@ -100,5 +100,5 @@
100
100
  "module": "./index.esm.js",
101
101
  "main": "./index.cjs.js",
102
102
  "types": "./index.esm.d.ts",
103
- "version": "2.0.0-beta.149"
103
+ "version": "2.0.0-beta.152"
104
104
  }