@intlayer/webpack 1.0.0 → 1.0.1
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/dist/cjs/index.cjs +16 -21
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/scripts/bundle.cjs +17 -20
- package/dist/cjs/scripts/bundle.d.ts +7 -0
- package/dist/cjs/scripts/index.cjs +11 -19
- package/dist/cjs/scripts/index.d.ts +3 -0
- package/dist/cjs/scripts/startServer.cjs +10 -18
- package/dist/cjs/scripts/startServer.d.ts +5 -0
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.cjs +14 -30
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.d.ts +6 -0
- package/dist/cjs/transpiler/dictionary_to_main/index.cjs +9 -21
- package/dist/cjs/transpiler/dictionary_to_main/index.d.ts +1 -0
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +37 -33
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.d.ts +7 -0
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs +16 -28
- package/dist/cjs/transpiler/dictionary_to_type/createType.d.ts +42 -0
- package/dist/cjs/transpiler/dictionary_to_type/index.cjs +11 -27
- package/dist/cjs/transpiler/dictionary_to_type/index.d.ts +3 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.cjs +8 -13
- package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.d.ts +44 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/index.cjs +13 -33
- package/dist/cjs/transpiler/intlater_module_to_dictionary/index.d.ts +4 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.cjs +11 -14
- package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.d.ts +8 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs +14 -30
- package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.d.ts +6 -0
- package/dist/cjs/utils.cjs +10 -18
- package/dist/cjs/utils.d.ts +4 -0
- package/dist/cjs/webpack-plugin.cjs +21 -40
- package/dist/cjs/webpack-plugin.d.ts +15 -0
- package/dist/cjs/webpack.config.cjs +34 -47
- package/dist/cjs/webpack.config.d.ts +7 -0
- package/dist/esm/index.d.mts +6 -9
- package/dist/esm/index.mjs +5 -5
- package/dist/esm/scripts/bundle.d.mts +2 -2
- package/dist/esm/scripts/bundle.mjs +13 -8
- package/dist/esm/scripts/index.d.mts +3 -3
- package/dist/esm/scripts/index.mjs +3 -3
- package/dist/esm/scripts/startServer.d.mts +1 -1
- package/dist/esm/scripts/startServer.mjs +5 -3
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.mjs +7 -7
- package/dist/esm/transpiler/dictionary_to_main/index.d.mts +1 -1
- package/dist/esm/transpiler/dictionary_to_main/index.mjs +2 -2
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +31 -12
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createType.d.mts +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs +14 -12
- package/dist/esm/transpiler/dictionary_to_type/index.d.mts +3 -10
- package/dist/esm/transpiler/dictionary_to_type/index.mjs +3 -3
- package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.d.mts +1 -1
- package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.mjs +4 -2
- package/dist/esm/transpiler/intlater_module_to_dictionary/index.d.mts +4 -4
- package/dist/esm/transpiler/intlater_module_to_dictionary/index.mjs +4 -4
- package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.d.mts +2 -4
- package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.mjs +7 -3
- package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.d.mts +1 -3
- package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.mjs +6 -4
- package/dist/esm/utils.mjs +6 -6
- package/dist/esm/webpack-plugin.d.mts +10 -10
- package/dist/esm/webpack-plugin.mjs +16 -20
- package/dist/esm/webpack.config.d.mts +2 -2
- package/dist/esm/webpack.config.mjs +29 -23
- package/package.json +7 -7
- package/src/transpiler/dictionary_to_type/createModuleAugmentation.ts +30 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -8,18 +8,14 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
var src_exports = {};
|
|
24
20
|
__export(src_exports, {
|
|
25
21
|
IntLayerPlugin: () => import_webpack_plugin.IntLayerPlugin,
|
|
@@ -27,20 +23,19 @@ __export(src_exports, {
|
|
|
27
23
|
devServerConfig: () => import_webpack.devServerConfig,
|
|
28
24
|
startServer: () => import_scripts.startServer,
|
|
29
25
|
watch: () => import_scripts.watch,
|
|
30
|
-
webpackConfig: () => import_webpack.webpackConfig
|
|
26
|
+
webpackConfig: () => import_webpack.webpackConfig
|
|
31
27
|
});
|
|
32
28
|
module.exports = __toCommonJS(src_exports);
|
|
33
|
-
var import_scripts = require(
|
|
34
|
-
var import_webpack_plugin = require(
|
|
35
|
-
var import_webpack = require(
|
|
29
|
+
var import_scripts = require('./scripts/index.cjs');
|
|
30
|
+
var import_webpack_plugin = require('./webpack-plugin.cjs');
|
|
31
|
+
var import_webpack = require('./webpack.config.cjs');
|
|
36
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
-
0 &&
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
//# sourceMappingURL=index.cjs.map
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
IntLayerPlugin,
|
|
35
|
+
bundle,
|
|
36
|
+
devServerConfig,
|
|
37
|
+
startServer,
|
|
38
|
+
watch,
|
|
39
|
+
webpackConfig
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { startServer } from './scripts/startServer.js';
|
|
2
|
+
export { bundle, watch } from './scripts/bundle.js';
|
|
3
|
+
export { IntLayerPlugin } from './webpack-plugin.js';
|
|
4
|
+
export { devServerConfig, default as webpackConfig } from './webpack.config.js';
|
|
5
|
+
import 'webpack';
|
|
6
|
+
import 'webpack-dev-server';
|
|
@@ -8,25 +8,21 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
var bundle_exports = {};
|
|
24
20
|
__export(bundle_exports, {
|
|
25
21
|
bundle: () => bundle,
|
|
26
|
-
watch: () => watch
|
|
22
|
+
watch: () => watch
|
|
27
23
|
});
|
|
28
24
|
module.exports = __toCommonJS(bundle_exports);
|
|
29
|
-
const bundle = (compiler) =>
|
|
25
|
+
const bundle = (compiler) => (
|
|
30
26
|
// Run the compiler
|
|
31
27
|
compiler.run((err, stats) => {
|
|
32
28
|
if (err) {
|
|
@@ -38,11 +34,12 @@ const bundle = (compiler) =>
|
|
|
38
34
|
console.info(
|
|
39
35
|
stats.toString({
|
|
40
36
|
// Add options here to customize the stats output
|
|
41
|
-
colors: true
|
|
37
|
+
colors: true
|
|
42
38
|
})
|
|
43
39
|
);
|
|
44
|
-
})
|
|
45
|
-
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
const watch = (compiler) => (
|
|
46
43
|
// Run the compiler
|
|
47
44
|
compiler.watch({}, (err, stats) => {
|
|
48
45
|
if (err) {
|
|
@@ -54,15 +51,15 @@ const watch = (compiler) =>
|
|
|
54
51
|
console.info(
|
|
55
52
|
stats.toString({
|
|
56
53
|
// Add options here to customize the stats output
|
|
57
|
-
colors: true
|
|
54
|
+
colors: true
|
|
58
55
|
})
|
|
59
56
|
);
|
|
60
57
|
console.info("Watch IntLayer content...");
|
|
61
|
-
})
|
|
58
|
+
})
|
|
59
|
+
);
|
|
62
60
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
-
0 &&
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
//# sourceMappingURL=bundle.cjs.map
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
bundle,
|
|
63
|
+
watch
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=bundle.cjs.map
|
|
@@ -4,30 +4,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
6
|
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
8
|
for (let key of __getOwnPropNames(from))
|
|
9
9
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, {
|
|
11
|
-
get: () => from[key],
|
|
12
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
13
|
-
});
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
11
|
}
|
|
15
12
|
return to;
|
|
16
13
|
};
|
|
17
|
-
var __reExport = (target, mod, secondTarget) => (
|
|
18
|
-
|
|
19
|
-
secondTarget && __copyProps(secondTarget, mod, "default")
|
|
20
|
-
);
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
16
|
var scripts_exports = {};
|
|
24
17
|
module.exports = __toCommonJS(scripts_exports);
|
|
25
|
-
__reExport(scripts_exports, require(
|
|
26
|
-
__reExport(scripts_exports, require(
|
|
18
|
+
__reExport(scripts_exports, require('./startServer.cjs'), module.exports);
|
|
19
|
+
__reExport(scripts_exports, require('./bundle.cjs'), module.exports);
|
|
27
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 &&
|
|
29
|
-
(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=index.cjs.map
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require('./startServer.cjs'),
|
|
23
|
+
...require('./bundle.cjs')
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -8,37 +8,29 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
var startServer_exports = {};
|
|
24
20
|
__export(startServer_exports, {
|
|
25
|
-
startServer: () => startServer
|
|
21
|
+
startServer: () => startServer
|
|
26
22
|
});
|
|
27
23
|
module.exports = __toCommonJS(startServer_exports);
|
|
28
|
-
var import_webpack = require(
|
|
24
|
+
var import_webpack = require('../webpack.config.cjs');
|
|
29
25
|
const WebpackDevServer = require("webpack-dev-server");
|
|
30
26
|
const startServer = (compiler) => {
|
|
31
|
-
const devServer = new WebpackDevServer(
|
|
32
|
-
import_webpack.devServerConfig,
|
|
33
|
-
compiler
|
|
34
|
-
);
|
|
27
|
+
const devServer = new WebpackDevServer(import_webpack.devServerConfig, compiler);
|
|
35
28
|
devServer.startCallback(() => {
|
|
36
29
|
console.info("Webpack Dev Server is running...");
|
|
37
30
|
});
|
|
38
31
|
};
|
|
39
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 &&
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
//# sourceMappingURL=startServer.cjs.map
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
startServer
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=startServer.cjs.map
|
|
@@ -8,40 +8,33 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
var createDictionaryList_exports = {};
|
|
24
20
|
__export(createDictionaryList_exports, {
|
|
25
|
-
createDictionaryList: () => createDictionaryList
|
|
21
|
+
createDictionaryList: () => createDictionaryList
|
|
26
22
|
});
|
|
27
23
|
module.exports = __toCommonJS(createDictionaryList_exports);
|
|
28
24
|
var import_fs = require("fs");
|
|
29
25
|
var import_path = require("path");
|
|
30
26
|
var import_config = require("@intlayer/config");
|
|
31
27
|
var import_glob = require("glob");
|
|
32
|
-
var import_utils = require(
|
|
28
|
+
var import_utils = require('../../utils.cjs');
|
|
33
29
|
const { content } = (0, import_config.getConfiguration)();
|
|
34
30
|
const { dictionariesDir, mainDir } = content;
|
|
35
31
|
const generateDictionaryListContent = (dictionaries, format = "esm") => {
|
|
36
32
|
let content2 = "";
|
|
37
33
|
const dictionariesRef = dictionaries.map((dictionaryPath) => ({
|
|
38
34
|
relativePath: (0, import_path.relative)(mainDir, dictionaryPath),
|
|
39
|
-
id: (0, import_path.basename)(
|
|
40
|
-
dictionaryPath,
|
|
41
|
-
(0, import_path.extname)(dictionaryPath)
|
|
42
|
-
),
|
|
35
|
+
id: (0, import_path.basename)(dictionaryPath, (0, import_path.extname)(dictionaryPath)),
|
|
43
36
|
// Get the base name as the dictionary id
|
|
44
|
-
hash: `_${(0, import_utils.getFileHash)(dictionaryPath)}
|
|
37
|
+
hash: `_${(0, import_utils.getFileHash)(dictionaryPath)}`
|
|
45
38
|
// Get the hash of the dictionary to avoid conflicts
|
|
46
39
|
}));
|
|
47
40
|
dictionariesRef.forEach((dictionary) => {
|
|
@@ -53,9 +46,7 @@ const generateDictionaryListContent = (dictionaries, format = "esm") => {
|
|
|
53
46
|
`;
|
|
54
47
|
});
|
|
55
48
|
content2 += "\n";
|
|
56
|
-
const formattedDictionaryMap = dictionariesRef
|
|
57
|
-
.map((dictionary) => `"${dictionary.id}": ${dictionary.hash}`)
|
|
58
|
-
.join(",\n");
|
|
49
|
+
const formattedDictionaryMap = dictionariesRef.map((dictionary) => `"${dictionary.id}": ${dictionary.hash}`).join(",\n");
|
|
59
50
|
if (format === "esm")
|
|
60
51
|
content2 += `export default {
|
|
61
52
|
${formattedDictionaryMap}
|
|
@@ -74,19 +65,12 @@ const createDictionaryList = () => {
|
|
|
74
65
|
}
|
|
75
66
|
const dictionaries = (0, import_glob.sync)(`${dictionariesDir}/**/*.json`);
|
|
76
67
|
const cjsContent = generateDictionaryListContent(dictionaries, "cjs");
|
|
77
|
-
(0, import_fs.writeFileSync)(
|
|
78
|
-
(0, import_path.resolve)(mainDir, "dictionaries.cjs"),
|
|
79
|
-
cjsContent
|
|
80
|
-
);
|
|
68
|
+
(0, import_fs.writeFileSync)((0, import_path.resolve)(mainDir, "dictionaries.cjs"), cjsContent);
|
|
81
69
|
const esmContent = generateDictionaryListContent(dictionaries, "esm");
|
|
82
|
-
(0, import_fs.writeFileSync)(
|
|
83
|
-
(0, import_path.resolve)(mainDir, "dictionaries.mjs"),
|
|
84
|
-
esmContent
|
|
85
|
-
);
|
|
70
|
+
(0, import_fs.writeFileSync)((0, import_path.resolve)(mainDir, "dictionaries.mjs"), esmContent);
|
|
86
71
|
};
|
|
87
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
-
0 &&
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
//# sourceMappingURL=createDictionaryList.cjs.map
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
createDictionaryList
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=createDictionaryList.cjs.map
|
|
@@ -4,32 +4,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
6
|
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
8
|
for (let key of __getOwnPropNames(from))
|
|
9
9
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, {
|
|
11
|
-
get: () => from[key],
|
|
12
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
13
|
-
});
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
11
|
}
|
|
15
12
|
return to;
|
|
16
13
|
};
|
|
17
|
-
var __reExport = (target, mod, secondTarget) => (
|
|
18
|
-
|
|
19
|
-
secondTarget && __copyProps(secondTarget, mod, "default")
|
|
20
|
-
);
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
16
|
var dictionary_to_main_exports = {};
|
|
24
17
|
module.exports = __toCommonJS(dictionary_to_main_exports);
|
|
25
|
-
__reExport(
|
|
26
|
-
dictionary_to_main_exports,
|
|
27
|
-
require("./createDictionaryList.cjs"),
|
|
28
|
-
module.exports
|
|
29
|
-
);
|
|
18
|
+
__reExport(dictionary_to_main_exports, require('./createDictionaryList.cjs'), module.exports);
|
|
30
19
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
-
0 &&
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=index.cjs.map
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require('./createDictionaryList.cjs')
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createDictionaryList } from './createDictionaryList.js';
|
|
@@ -8,43 +8,36 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
var createModuleAugmentation_exports = {};
|
|
24
20
|
__export(createModuleAugmentation_exports, {
|
|
25
21
|
createModuleAugmentation: () => createModuleAugmentation,
|
|
26
|
-
getTypeName: () => getTypeName
|
|
22
|
+
getTypeName: () => getTypeName
|
|
27
23
|
});
|
|
28
24
|
module.exports = __toCommonJS(createModuleAugmentation_exports);
|
|
29
25
|
var import_fs = require("fs");
|
|
30
26
|
var import_path = require("path");
|
|
31
27
|
var import_config = require("@intlayer/config");
|
|
32
28
|
var import_glob = require("glob");
|
|
33
|
-
var import_utils = require(
|
|
34
|
-
const { content } = (0, import_config.getConfiguration)();
|
|
29
|
+
var import_utils = require('../../utils.cjs');
|
|
30
|
+
const { content, internationalization } = (0, import_config.getConfiguration)();
|
|
35
31
|
const { typesDir, moduleAugmentationDir } = content;
|
|
36
|
-
const
|
|
37
|
-
|
|
32
|
+
const { locales } = internationalization;
|
|
33
|
+
const getTypeName = (id) => (0, import_utils.transformToCamelCase)(`${id}Content`);
|
|
38
34
|
const generateTypeIndexContent = (typeFiles) => {
|
|
39
|
-
let content2 = "
|
|
35
|
+
let content2 = "/* eslint-disable */\nimport 'intlayer';\nimport { Locales } from '@intlayer/config'\n";
|
|
40
36
|
const dictionariesRef = typeFiles.map((dictionaryPath) => ({
|
|
41
|
-
relativePath: (0, import_path.relative)(
|
|
42
|
-
moduleAugmentationDir,
|
|
43
|
-
dictionaryPath
|
|
44
|
-
),
|
|
37
|
+
relativePath: (0, import_path.relative)(moduleAugmentationDir, dictionaryPath),
|
|
45
38
|
id: (0, import_path.basename)(dictionaryPath, ".d.ts"),
|
|
46
39
|
// Get the base name as the dictionary id
|
|
47
|
-
hash: `_${(0, import_utils.getFileHash)(dictionaryPath)}
|
|
40
|
+
hash: `_${(0, import_utils.getFileHash)(dictionaryPath)}`
|
|
48
41
|
// Get the hash of the dictionary to avoid conflicts
|
|
49
42
|
}));
|
|
50
43
|
dictionariesRef.forEach((dictionary) => {
|
|
@@ -53,14 +46,29 @@ const generateTypeIndexContent = (typeFiles) => {
|
|
|
53
46
|
`;
|
|
54
47
|
});
|
|
55
48
|
content2 += "\n";
|
|
56
|
-
const formattedDictionaryMap = dictionariesRef
|
|
57
|
-
|
|
58
|
-
.
|
|
49
|
+
const formattedDictionaryMap = dictionariesRef.map((dictionary) => ` "${dictionary.id}": ${dictionary.hash};`).join("\n");
|
|
50
|
+
const formatLocales = locales.map((locale) => {
|
|
51
|
+
for (const key in import_config.Locales) {
|
|
52
|
+
if (import_config.Locales[key] === locale) {
|
|
53
|
+
return ` ${key} = '${locale}'`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}).join(",\n");
|
|
59
57
|
content2 += `declare module 'intlayer' {
|
|
60
|
-
|
|
58
|
+
`;
|
|
59
|
+
content2 += ` interface IntlayerDictionaryTypesConnector {
|
|
61
60
|
${formattedDictionaryMap}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
`;
|
|
64
|
+
content2 += ` enum ConfigLocales {
|
|
65
|
+
${formatLocales}
|
|
62
66
|
};
|
|
63
|
-
|
|
67
|
+
|
|
68
|
+
`;
|
|
69
|
+
content2 += ` interface IConfigLocales<Content> extends Record<ConfigLocales, Content> {}
|
|
70
|
+
`;
|
|
71
|
+
content2 += `};`;
|
|
64
72
|
return content2;
|
|
65
73
|
};
|
|
66
74
|
const createModuleAugmentation = () => {
|
|
@@ -69,15 +77,11 @@ const createModuleAugmentation = () => {
|
|
|
69
77
|
}
|
|
70
78
|
const dictionaries = (0, import_glob.sync)(`${typesDir}/**/*.d.ts`);
|
|
71
79
|
const tsContent = generateTypeIndexContent(dictionaries);
|
|
72
|
-
(0, import_fs.writeFileSync)(
|
|
73
|
-
(0, import_path.join)(moduleAugmentationDir, "intlayer.d.ts"),
|
|
74
|
-
tsContent
|
|
75
|
-
);
|
|
80
|
+
(0, import_fs.writeFileSync)((0, import_path.join)(moduleAugmentationDir, "intlayer.d.ts"), tsContent);
|
|
76
81
|
};
|
|
77
82
|
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
-
0 &&
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//# sourceMappingURL=createModuleAugmentation.cjs.map
|
|
83
|
+
0 && (module.exports = {
|
|
84
|
+
createModuleAugmentation,
|
|
85
|
+
getTypeName
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=createModuleAugmentation.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, join, relative } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { sync } from 'glob';\nimport { getFileHash, transformToCamelCase } from '../../utils';\n\nconst { content } = getConfiguration();\nconst { typesDir, moduleAugmentationDir } = content;\n\nexport const getTypeName = (id: string): string =>\n transformToCamelCase(`${id}Content`);\n\n/**\n * This function generates the content of the module augmentation file\n */\nconst generateTypeIndexContent = (typeFiles: string[]): string => {\n let content
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, join, relative } from 'path';\nimport { Locales, getConfiguration } from '@intlayer/config';\nimport { sync } from 'glob';\nimport { getFileHash, transformToCamelCase } from '../../utils';\n\nconst { content, internationalization } = getConfiguration();\nconst { typesDir, moduleAugmentationDir } = content;\nconst { locales } = internationalization;\n\nexport const getTypeName = (id: string): string =>\n transformToCamelCase(`${id}Content`);\n\n/**\n * This function generates the content of the module augmentation file\n */\nconst generateTypeIndexContent = (typeFiles: string[]): string => {\n let content =\n \"/* eslint-disable */\\nimport 'intlayer';\\nimport { Locales } from '@intlayer/config'\\n\";\n\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: relative(moduleAugmentationDir, dictionaryPath),\n id: basename(dictionaryPath, '.d.ts'), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n const typeName = getTypeName(dictionary.id);\n content += `import type { ${typeName} as ${dictionary.hash} } from '${dictionary.relativePath}';\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash};`)\n .join('\\n');\n\n const formatLocales = locales\n .map((locale) => {\n for (const key in Locales) {\n if (Locales[key as keyof typeof Locales] === locale) {\n return ` ${key} = '${locale}'`;\n }\n }\n })\n .join(',\\n');\n\n /**\n * Write the module augmentation to extend the intlayer module with the dictionaries types\n * Will suggest the type resulting of the dictionaries\n *\n * declare module 'intlayer' {\n * interface IntlayerDictionaryTypesConnector = {\n * dictionaries: {\n * id: DictionaryType;\n * }\n * }\n *\n * enum ConfigLocales {\n * ENGLISH = 'en',\n * FRENCH = 'fr',\n * SPANISH = 'es',\n * }\n *\n * interface IConfigLocales<Content> extends Record<ConfigLocales, Content> {}\n *\n * }\n * See https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\n */\n content += `declare module 'intlayer' {\\n`;\n content += ` interface IntlayerDictionaryTypesConnector {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n content += ` enum ConfigLocales {\\n${formatLocales}\\n };\\n\\n`;\n content += ` interface IConfigLocales<Content> extends Record<ConfigLocales, Content> {}\\n`;\n content += `};`;\n\n return content;\n};\n\n/**\n * This function generates a index file merging all the types\n */\nexport const createModuleAugmentation = () => {\n // Create main directory if it doesn't exist\n if (!existsSync(moduleAugmentationDir)) {\n mkdirSync(moduleAugmentationDir, { recursive: true });\n }\n\n const dictionaries: string[] = sync(`${typesDir}/**/*.d.ts`);\n // Create the dictionary list file\n\n const tsContent = generateTypeIndexContent(dictionaries);\n writeFileSync(join(moduleAugmentationDir, 'intlayer.d.ts'), tsContent);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqD;AACrD,kBAAyC;AACzC,oBAA0C;AAC1C,kBAAqB;AACrB,mBAAkD;AAElD,MAAM,EAAE,SAAS,qBAAqB,QAAI,gCAAiB;AAC3D,MAAM,EAAE,UAAU,sBAAsB,IAAI;AAC5C,MAAM,EAAE,QAAQ,IAAI;AAEb,MAAM,cAAc,CAAC,WAC1B,mCAAqB,GAAG,EAAE,SAAS;AAKrC,MAAM,2BAA2B,CAAC,cAAgC;AAChE,MAAIA,WACF;AAEF,QAAM,kBAAkB,UAAU,IAAI,CAAC,oBAAoB;AAAA,IACzD,kBAAc,sBAAS,uBAAuB,cAAc;AAAA,IAC5D,QAAI,sBAAS,gBAAgB,OAAO;AAAA;AAAA,IACpC,MAAM,QAAI,0BAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,UAAM,WAAW,YAAY,WAAW,EAAE;AAC1C,IAAAA,YAAW,iBAAiB,QAAQ,OAAO,WAAW,IAAI,YAAY,WAAW,YAAY;AAAA;AAAA,EAC/F,CAAC;AAED,EAAAA,YAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,QAAQ,WAAW,EAAE,MAAM,WAAW,IAAI,GAAG,EACjE,KAAK,IAAI;AAEZ,QAAM,gBAAgB,QACnB,IAAI,CAAC,WAAW;AACf,eAAW,OAAO,uBAAS;AACzB,UAAI,sBAAQ,GAA2B,MAAM,QAAQ;AACnD,eAAO,OAAO,GAAG,OAAO,MAAM;AAAA,MAChC;AAAA,IACF;AAAA,EACF,CAAC,EACA,KAAK,KAAK;AAwBb,EAAAA,YAAW;AAAA;AACX,EAAAA,YAAW;AAAA,EAAmD,sBAAsB;AAAA;AAAA;AAAA;AACpF,EAAAA,YAAW;AAAA,EAA2B,aAAa;AAAA;AAAA;AAAA;AACnD,EAAAA,YAAW;AAAA;AACX,EAAAA,YAAW;AAEX,SAAOA;AACT;AAKO,MAAM,2BAA2B,MAAM;AAE5C,MAAI,KAAC,sBAAW,qBAAqB,GAAG;AACtC,6BAAU,uBAAuB,EAAE,WAAW,KAAK,CAAC;AAAA,EACtD;AAEA,QAAM,mBAAyB,kBAAK,GAAG,QAAQ,YAAY;AAG3D,QAAM,YAAY,yBAAyB,YAAY;AACvD,mCAAc,kBAAK,uBAAuB,eAAe,GAAG,SAAS;AACvE;","names":["content"]}
|
|
@@ -8,30 +8,26 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
var createType_exports = {};
|
|
24
20
|
__export(createType_exports, {
|
|
25
21
|
createTypes: () => createTypes,
|
|
26
22
|
generateTypeScriptType: () => generateTypeScriptType,
|
|
27
|
-
generateTypeScriptTypeContent: () => generateTypeScriptTypeContent
|
|
23
|
+
generateTypeScriptTypeContent: () => generateTypeScriptTypeContent
|
|
28
24
|
});
|
|
29
25
|
module.exports = __toCommonJS(createType_exports);
|
|
30
26
|
var import_fs = require("fs");
|
|
31
27
|
var import_path = require("path");
|
|
32
28
|
var import_config = require("@intlayer/config");
|
|
33
29
|
var import_core = require("@intlayer/core");
|
|
34
|
-
var import_createModuleAugmentation = require(
|
|
30
|
+
var import_createModuleAugmentation = require('./createModuleAugmentation.cjs');
|
|
35
31
|
const { content, internationalization } = (0, import_config.getConfiguration)();
|
|
36
32
|
const { typesDir } = content;
|
|
37
33
|
const generateTypeScriptType = (obj) => {
|
|
@@ -49,24 +45,21 @@ const generateTypeScriptTypeContent = (obj) => {
|
|
|
49
45
|
const nodeType = value.nodeType;
|
|
50
46
|
if (
|
|
51
47
|
// Check if the value is a typed node
|
|
52
|
-
typeof value === "object" &&
|
|
53
|
-
nodeType === import_core.NodeType.Translation
|
|
48
|
+
typeof value === "object" && nodeType === import_core.NodeType.Translation
|
|
54
49
|
) {
|
|
55
50
|
const tsType = typeof value[internationalization.defaultLocale];
|
|
56
51
|
typeDefinition += ` ${key}: ${tsType},
|
|
57
52
|
`;
|
|
58
53
|
} else if (
|
|
59
54
|
// Check if the value is a typed node
|
|
60
|
-
typeof value === "object" &&
|
|
61
|
-
nodeType === import_core.NodeType.Enumeration
|
|
55
|
+
typeof value === "object" && nodeType === import_core.NodeType.Enumeration
|
|
62
56
|
) {
|
|
63
57
|
const tsType = typeof value[internationalization.defaultLocale];
|
|
64
58
|
typeDefinition += ` ${key}: (quantity: number) => ${tsType},
|
|
65
59
|
`;
|
|
66
60
|
} else if (
|
|
67
61
|
// Check if the value is a nested object
|
|
68
|
-
typeof value === "object" &&
|
|
69
|
-
!Array.isArray(value)
|
|
62
|
+
typeof value === "object" && !Array.isArray(value)
|
|
70
63
|
) {
|
|
71
64
|
const nestedType = generateTypeScriptTypeContent(value);
|
|
72
65
|
typeDefinition += ` ${key}: {${nestedType}},
|
|
@@ -80,8 +73,7 @@ const generateTypeScriptTypeContent = (obj) => {
|
|
|
80
73
|
`;
|
|
81
74
|
} else if (
|
|
82
75
|
// Check if the value is an 'id'
|
|
83
|
-
typeof value === "string" &&
|
|
84
|
-
key === "id"
|
|
76
|
+
typeof value === "string" && key === "id"
|
|
85
77
|
) {
|
|
86
78
|
const tsType = `"${value}"`;
|
|
87
79
|
typeDefinition += ` ${key}: ${tsType},
|
|
@@ -103,20 +95,16 @@ const createTypes = (dictionariesPaths) => {
|
|
|
103
95
|
const contentModule = require(dictionaryPath);
|
|
104
96
|
const dictionaryName = contentModule.id;
|
|
105
97
|
const typeDefinition = generateTypeScriptType(contentModule);
|
|
106
|
-
const outputPath = (0, import_path.resolve)(
|
|
107
|
-
typesDir,
|
|
108
|
-
`${dictionaryName}.d.ts`
|
|
109
|
-
);
|
|
98
|
+
const outputPath = (0, import_path.resolve)(typesDir, `${dictionaryName}.d.ts`);
|
|
110
99
|
(0, import_fs.writeFileSync)(outputPath, typeDefinition);
|
|
111
100
|
resultTypesPaths.push(outputPath);
|
|
112
101
|
}
|
|
113
102
|
return resultTypesPaths;
|
|
114
103
|
};
|
|
115
104
|
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
-
0 &&
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
//# sourceMappingURL=createType.cjs.map
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
createTypes,
|
|
107
|
+
generateTypeScriptType,
|
|
108
|
+
generateTypeScriptTypeContent
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=createType.cjs.map
|