@intlayer/webpack 1.0.0 → 1.2.0
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/getEntries.cjs +41 -0
- package/dist/cjs/getEntries.cjs.map +1 -0
- package/dist/cjs/getEntries.d.ts +5 -0
- package/dist/cjs/index.cjs +12 -24
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/utils.cjs +32 -31
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.ts +7 -0
- package/dist/cjs/webpack-plugin.cjs +12 -161
- package/dist/cjs/webpack-plugin.cjs.map +1 -1
- package/dist/cjs/webpack-plugin.d.ts +5 -0
- package/dist/cjs/webpack.config.cjs +53 -63
- package/dist/cjs/webpack.config.cjs.map +1 -1
- package/dist/cjs/webpack.config.d.ts +7 -0
- package/dist/esm/getEntries.d.mts +5 -0
- package/dist/esm/getEntries.mjs +17 -0
- package/dist/esm/getEntries.mjs.map +1 -0
- package/dist/esm/index.d.mts +4 -9
- package/dist/esm/index.mjs +4 -8
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/utils.d.mts +5 -2
- package/dist/esm/utils.mjs +15 -17
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/esm/webpack-plugin.d.mts +1 -11
- package/dist/esm/webpack-plugin.mjs +8 -142
- package/dist/esm/webpack-plugin.mjs.map +1 -1
- package/dist/esm/webpack.config.d.mts +2 -2
- package/dist/esm/webpack.config.mjs +48 -39
- package/dist/esm/webpack.config.mjs.map +1 -1
- package/package.json +14 -18
- package/src/getEntries.ts +19 -0
- package/src/index.ts +2 -12
- package/src/utils.ts +19 -19
- package/src/webpack-plugin.ts +5 -180
- package/src/webpack.config.ts +32 -28
- package/dist/cjs/scripts/bundle.cjs +0 -68
- package/dist/cjs/scripts/bundle.cjs.map +0 -1
- package/dist/cjs/scripts/index.cjs +0 -33
- package/dist/cjs/scripts/index.cjs.map +0 -1
- package/dist/cjs/scripts/startServer.cjs +0 -44
- package/dist/cjs/scripts/startServer.cjs.map +0 -1
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.cjs +0 -92
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.cjs.map +0 -1
- package/dist/cjs/transpiler/dictionary_to_main/index.cjs +0 -35
- package/dist/cjs/transpiler/dictionary_to_main/index.cjs.map +0 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +0 -83
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +0 -1
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs +0 -122
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs.map +0 -1
- package/dist/cjs/transpiler/dictionary_to_type/index.cjs +0 -41
- package/dist/cjs/transpiler/dictionary_to_type/index.cjs.map +0 -1
- package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.cjs +0 -50
- package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.cjs.map +0 -1
- package/dist/cjs/transpiler/intlater_module_to_dictionary/index.cjs +0 -47
- package/dist/cjs/transpiler/intlater_module_to_dictionary/index.cjs.map +0 -1
- package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.cjs +0 -70
- package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.cjs.map +0 -1
- package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs +0 -112
- package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs.map +0 -1
- package/dist/esm/scripts/bundle.d.mts +0 -7
- package/dist/esm/scripts/bundle.mjs +0 -35
- package/dist/esm/scripts/bundle.mjs.map +0 -1
- package/dist/esm/scripts/index.d.mts +0 -3
- package/dist/esm/scripts/index.mjs +0 -3
- package/dist/esm/scripts/index.mjs.map +0 -1
- package/dist/esm/scripts/startServer.d.mts +0 -5
- package/dist/esm/scripts/startServer.mjs +0 -10
- package/dist/esm/scripts/startServer.mjs.map +0 -1
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.d.mts +0 -6
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.mjs +0 -52
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.mjs.map +0 -1
- package/dist/esm/transpiler/dictionary_to_main/index.d.mts +0 -1
- package/dist/esm/transpiler/dictionary_to_main/index.mjs +0 -2
- package/dist/esm/transpiler/dictionary_to_main/index.mjs.map +0 -1
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.d.mts +0 -7
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +0 -43
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +0 -1
- package/dist/esm/transpiler/dictionary_to_type/createType.d.mts +0 -42
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs +0 -84
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs.map +0 -1
- package/dist/esm/transpiler/dictionary_to_type/index.d.mts +0 -10
- package/dist/esm/transpiler/dictionary_to_type/index.mjs +0 -3
- package/dist/esm/transpiler/dictionary_to_type/index.mjs.map +0 -1
- package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.d.mts +0 -44
- package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.mjs +0 -19
- package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.mjs.map +0 -1
- package/dist/esm/transpiler/intlater_module_to_dictionary/index.d.mts +0 -4
- package/dist/esm/transpiler/intlater_module_to_dictionary/index.mjs +0 -4
- package/dist/esm/transpiler/intlater_module_to_dictionary/index.mjs.map +0 -1
- package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.d.mts +0 -10
- package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.mjs +0 -39
- package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.mjs.map +0 -1
- package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.d.mts +0 -8
- package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.mjs +0 -70
- package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.mjs.map +0 -1
- package/src/scripts/bundle.ts +0 -44
- package/src/scripts/index.ts +0 -2
- package/src/scripts/startServer.ts +0 -14
- package/src/transpiler/dictionary_to_main/createDictionaryList.ts +0 -65
- package/src/transpiler/dictionary_to_main/index.ts +0 -1
- package/src/transpiler/dictionary_to_type/createModuleAugmentation.ts +0 -70
- package/src/transpiler/dictionary_to_type/createType.ts +0 -140
- package/src/transpiler/dictionary_to_type/index.ts +0 -2
- package/src/transpiler/intlater_module_to_dictionary/extractNestedJSON.ts +0 -60
- package/src/transpiler/intlater_module_to_dictionary/index.ts +0 -3
- package/src/transpiler/intlater_module_to_dictionary/processModule.ts +0 -69
- package/src/transpiler/intlater_module_to_dictionary/transpileBundledCode.ts +0 -107
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var getEntries_exports = {};
|
|
20
|
+
__export(getEntries_exports, {
|
|
21
|
+
getEntries: () => getEntries
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getEntries_exports);
|
|
24
|
+
var import_config = require("@intlayer/config");
|
|
25
|
+
var import_glob = require("glob");
|
|
26
|
+
var import_utils = require('./utils.cjs');
|
|
27
|
+
const { content } = (0, import_config.getConfiguration)();
|
|
28
|
+
const { watchedFilesPatternWithPath } = content;
|
|
29
|
+
const getEntries = () => (0, import_glob.sync)(watchedFilesPatternWithPath).reduce((obj, el) => {
|
|
30
|
+
const hash = (0, import_utils.getFileHash)(el);
|
|
31
|
+
obj[`intlayer-content/${hash}`] = {
|
|
32
|
+
import: el,
|
|
33
|
+
dependOn: void 0
|
|
34
|
+
};
|
|
35
|
+
return obj;
|
|
36
|
+
}, {});
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
getEntries
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=getEntries.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/getEntries.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { sync } from 'glob';\nimport type { EntryObject } from 'webpack';\nimport { getFileHash } from './utils';\n\nconst { content } = getConfiguration();\nconst { watchedFilesPatternWithPath } = content;\n\nexport const getEntries = (): EntryObject =>\n sync(watchedFilesPatternWithPath).reduce((obj, el) => {\n const hash = getFileHash(el);\n\n obj[`intlayer-content/${hash}`] = {\n import: el,\n dependOn: undefined,\n };\n\n return obj;\n }, {} as EntryObject);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,kBAAqB;AAErB,mBAA4B;AAE5B,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,4BAA4B,IAAI;AAEjC,MAAM,aAAa,UACxB,kBAAK,2BAA2B,EAAE,OAAO,CAAC,KAAK,OAAO;AACpD,QAAM,WAAO,0BAAY,EAAE;AAE3B,MAAI,oBAAoB,IAAI,EAAE,IAAI;AAAA,IAChC,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AAEA,SAAO;AACT,GAAG,CAAC,CAAgB;","names":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -8,39 +8,27 @@ 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,
|
|
26
|
-
bundle: () => import_scripts.bundle,
|
|
27
22
|
devServerConfig: () => import_webpack.devServerConfig,
|
|
28
|
-
|
|
29
|
-
watch: () => import_scripts.watch,
|
|
30
|
-
webpackConfig: () => import_webpack.webpackConfig,
|
|
23
|
+
webpackConfig: () => import_webpack.webpackConfig
|
|
31
24
|
});
|
|
32
25
|
module.exports = __toCommonJS(src_exports);
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var import_webpack = require("./webpack.config.cjs");
|
|
26
|
+
var import_webpack_plugin = require('./webpack-plugin.cjs');
|
|
27
|
+
var import_webpack = require('./webpack.config.cjs');
|
|
36
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
-
0 &&
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
watch,
|
|
44
|
-
webpackConfig,
|
|
45
|
-
});
|
|
46
|
-
//# sourceMappingURL=index.cjs.map
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
IntLayerPlugin,
|
|
31
|
+
devServerConfig,
|
|
32
|
+
webpackConfig
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { IntLayerPlugin } from './webpack-plugin';\nexport { devServerConfig, webpackConfig } from './webpack.config';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA+B;AAC/B,qBAA+C;","names":[]}
|
package/dist/cjs/utils.cjs
CHANGED
|
@@ -1,53 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
8
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
11
|
};
|
|
10
12
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
14
|
for (let key of __getOwnPropNames(from))
|
|
13
15
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
17
|
}
|
|
19
18
|
return to;
|
|
20
19
|
};
|
|
21
|
-
var
|
|
22
|
-
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
29
|
var utils_exports = {};
|
|
24
30
|
__export(utils_exports, {
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
defineDirname: () => defineDirname,
|
|
32
|
+
getFileHash: () => getFileHash
|
|
27
33
|
});
|
|
28
34
|
module.exports = __toCommonJS(utils_exports);
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_url = require("url");
|
|
37
|
+
var import_crypto_js = __toESM(require("crypto-js"));
|
|
38
|
+
const import_meta = {};
|
|
39
|
+
const defineDirname = () => {
|
|
40
|
+
const isESModule = typeof import_meta.url === "string";
|
|
41
|
+
const filename = isESModule ? (0, import_url.fileURLToPath)(import_meta.url) : require("url").pathToFileURL(__filename).toString();
|
|
42
|
+
globalThis.__filename = globalThis.__filename ?? filename;
|
|
43
|
+
globalThis.__dirname = globalThis.__dirname ?? import_path.default.dirname(__filename);
|
|
36
44
|
};
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
if (index === 0) {
|
|
41
|
-
return word[0].toUpperCase() + word.slice(1);
|
|
42
|
-
}
|
|
43
|
-
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
44
|
-
});
|
|
45
|
-
return camelCasedWords.join("");
|
|
45
|
+
const getFileHash = (filePath) => {
|
|
46
|
+
const hash = import_crypto_js.default.SHA3(filePath);
|
|
47
|
+
return hash.toString(import_crypto_js.default.enc.Base64).replace(/[^A-Z\d]/gi, "").substring(0, 20);
|
|
46
48
|
};
|
|
47
49
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
-
0 &&
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//# sourceMappingURL=utils.cjs.map
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
defineDirname,
|
|
52
|
+
getFileHash
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=utils.cjs.map
|
package/dist/cjs/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import path from 'path';\nimport { fileURLToPath } from 'url';\nimport crypto from 'crypto-js';\n\n/**\n * Set the __dirname global variable to make the config work in both ESM and CJS environments\n */\nexport const defineDirname = () => {\n const isESModule = typeof import.meta.url === 'string';\n\n const filename = isESModule\n ? fileURLToPath(import.meta.url)\n : require('url').pathToFileURL(__filename).toString();\n\n globalThis.__filename = globalThis.__filename ?? filename;\n globalThis.__dirname = globalThis.__dirname ?? path.dirname(__filename);\n};\n\nexport const getFileHash = (filePath: string) => {\n const hash = crypto.SHA3(filePath);\n\n return hash\n .toString(crypto.enc.Base64)\n .replace(/[^A-Z\\d]/gi, '')\n .substring(0, 20);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,iBAA8B;AAC9B,uBAAmB;AAFnB;AAOO,MAAM,gBAAgB,MAAM;AACjC,QAAM,aAAa,OAAO,YAAY,QAAQ;AAE9C,QAAM,WAAW,iBACb,0BAAc,YAAY,GAAG,IAC7B,QAAQ,KAAK,EAAE,cAAc,UAAU,EAAE,SAAS;AAEtD,aAAW,aAAa,WAAW,cAAc;AACjD,aAAW,YAAY,WAAW,aAAa,YAAAA,QAAK,QAAQ,UAAU;AACxE;AAEO,MAAM,cAAc,CAAC,aAAqB;AAC/C,QAAM,OAAO,iBAAAC,QAAO,KAAK,QAAQ;AAEjC,SAAO,KACJ,SAAS,iBAAAA,QAAO,IAAI,MAAM,EAC1B,QAAQ,cAAc,EAAE,EACxB,UAAU,GAAG,EAAE;AACpB;","names":["path","crypto"]}
|
|
@@ -8,177 +8,28 @@ 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 webpack_plugin_exports = {};
|
|
24
20
|
__export(webpack_plugin_exports, {
|
|
25
|
-
IntLayerPlugin: () => IntLayerPlugin
|
|
21
|
+
IntLayerPlugin: () => IntLayerPlugin
|
|
26
22
|
});
|
|
27
23
|
module.exports = __toCommonJS(webpack_plugin_exports);
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
var import_glob = require("glob");
|
|
31
|
-
var import_webpack = require("webpack");
|
|
32
|
-
var import_createDictionaryList = require("./transpiler/dictionary_to_main/createDictionaryList.cjs");
|
|
33
|
-
var import_createModuleAugmentation = require("./transpiler/dictionary_to_type/createModuleAugmentation.cjs");
|
|
34
|
-
var import_createType = require("./transpiler/dictionary_to_type/createType.cjs");
|
|
35
|
-
var import_transpileBundledCode = require("./transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs");
|
|
36
|
-
var import_utils = require("./utils.cjs");
|
|
37
|
-
const getRelativePath = (filePath) =>
|
|
38
|
-
(0, import_path.relative)(baseDir, filePath);
|
|
39
|
-
const getBundledFilePathFromIntlayerModule = (filePath) => {
|
|
40
|
-
const hash = (0, import_utils.getFileHash)(filePath);
|
|
41
|
-
return `${bundleDir}/${hash}${bundleFileExtension}`;
|
|
42
|
-
};
|
|
43
|
-
const { content } = (0, import_config.getConfiguration)();
|
|
44
|
-
const { bundleDir, baseDir, bundleFileExtension, watchedFilesPatternWithPath } =
|
|
45
|
-
content;
|
|
24
|
+
var import_chokidar = require("@intlayer/chokidar");
|
|
25
|
+
const persistent = process.env.NODE_ENV === "development";
|
|
46
26
|
class IntLayerPlugin {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
addedFiles;
|
|
50
|
-
constructor() {
|
|
51
|
-
this.managedFiles = /* @__PURE__ */ new Set();
|
|
52
|
-
this.updatedFiles = /* @__PURE__ */ new Set();
|
|
53
|
-
this.addedFiles = /* @__PURE__ */ new Set();
|
|
54
|
-
}
|
|
55
|
-
// function to initialize the dictionaries
|
|
56
|
-
async initDictionaries() {
|
|
57
|
-
const outputFiles = [...this.managedFiles].map((file) =>
|
|
58
|
-
(0, import_path.resolve)(bundleDir, file)
|
|
59
|
-
);
|
|
60
|
-
const dictionaries =
|
|
61
|
-
(await (0, import_transpileBundledCode.transpileBundledCode)(
|
|
62
|
-
outputFiles
|
|
63
|
-
)) ?? [];
|
|
64
|
-
console.info(
|
|
65
|
-
`Dictionaries:
|
|
66
|
-
${dictionaries.map(getRelativePath).join("\n")}`
|
|
67
|
-
);
|
|
68
|
-
console.info("Building TypeScript types...");
|
|
69
|
-
(0, import_createType.createTypes)(dictionaries);
|
|
70
|
-
console.info("Building type index...");
|
|
71
|
-
(0, import_createModuleAugmentation.createModuleAugmentation)();
|
|
72
|
-
console.info("Building main...");
|
|
73
|
-
(0, import_createDictionaryList.createDictionaryList)();
|
|
74
|
-
}
|
|
75
|
-
// function to process when intlayer module files content are changed
|
|
76
|
-
async processFilesChanges() {
|
|
77
|
-
const dictionaries =
|
|
78
|
-
(await (0, import_transpileBundledCode.transpileBundledCode)([
|
|
79
|
-
...this.updatedFiles,
|
|
80
|
-
])) ?? [];
|
|
81
|
-
console.info(
|
|
82
|
-
`Updated dictionaries:
|
|
83
|
-
${dictionaries.map(getRelativePath).join("\n")}`
|
|
84
|
-
);
|
|
85
|
-
console.info("Updating TypeScript types...");
|
|
86
|
-
(0, import_createType.createTypes)(dictionaries);
|
|
87
|
-
this.updatedFiles.clear();
|
|
88
|
-
}
|
|
89
|
-
// function to process when new intlayer module is detected
|
|
90
|
-
async processNewFiles() {
|
|
91
|
-
const dictionaries =
|
|
92
|
-
(await (0, import_transpileBundledCode.transpileBundledCode)([
|
|
93
|
-
...this.addedFiles,
|
|
94
|
-
])) ?? [];
|
|
95
|
-
console.info(
|
|
96
|
-
`New dictionaries:
|
|
97
|
-
${dictionaries.map(getRelativePath).join("\n")}`
|
|
98
|
-
);
|
|
99
|
-
console.info("Building TypeScript types...");
|
|
100
|
-
(0, import_createType.createTypes)(dictionaries);
|
|
101
|
-
console.info("Building type index...");
|
|
102
|
-
(0, import_createModuleAugmentation.createModuleAugmentation)();
|
|
103
|
-
console.info("Building main...");
|
|
104
|
-
(0, import_createDictionaryList.createDictionaryList)();
|
|
105
|
-
this.managedFiles = /* @__PURE__ */ new Set([
|
|
106
|
-
...this.managedFiles,
|
|
107
|
-
...this.addedFiles,
|
|
108
|
-
]);
|
|
109
|
-
this.addedFiles.clear();
|
|
110
|
-
}
|
|
111
|
-
async detectFileAddedOrRemoved() {
|
|
112
|
-
const filesFound = [];
|
|
113
|
-
for (const pattern of watchedFilesPatternWithPath) {
|
|
114
|
-
(0, import_glob.sync)(pattern).map((file) => filesFound.push(file));
|
|
115
|
-
}
|
|
116
|
-
const newFiles = new Set(
|
|
117
|
-
filesFound.filter((x) => !this.managedFiles.has(x))
|
|
118
|
-
);
|
|
119
|
-
const removedFiles = new Set(
|
|
120
|
-
[...this.managedFiles].filter((x) => !filesFound.includes(x))
|
|
121
|
-
);
|
|
122
|
-
if (
|
|
123
|
-
// Check if there is new files
|
|
124
|
-
newFiles.size > 0
|
|
125
|
-
) {
|
|
126
|
-
console.info("New files:", [...newFiles]);
|
|
127
|
-
this.addedFiles = newFiles;
|
|
128
|
-
await this.processNewFiles();
|
|
129
|
-
}
|
|
130
|
-
if (
|
|
131
|
-
// Check if there is removed files
|
|
132
|
-
removedFiles.size > 0
|
|
133
|
-
) {
|
|
134
|
-
console.info("Removed files:", [...removedFiles]);
|
|
135
|
-
this.managedFiles = new Set(
|
|
136
|
-
[...this.managedFiles].filter((x) => !removedFiles.has(x))
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
if (this.updatedFiles.size > 0) {
|
|
140
|
-
await this.processFilesChanges();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
apply(compiler) {
|
|
144
|
-
compiler.hooks.entryOption.tap("EntryOptionPlugin", (context, entry) => {
|
|
145
|
-
if (typeof entry === "function") {
|
|
146
|
-
new import_webpack.DynamicEntryPlugin(context, entry).apply(compiler);
|
|
147
|
-
}
|
|
148
|
-
return true;
|
|
149
|
-
});
|
|
150
|
-
compiler.hooks.afterEmit.tapAsync(
|
|
151
|
-
"IntLayerPlugin - Process dictionaries",
|
|
152
|
-
async (compilation, callback) => {
|
|
153
|
-
const currentEmitFiles = new Set(Object.keys(compilation.assets));
|
|
154
|
-
if (
|
|
155
|
-
// Check if this first load
|
|
156
|
-
!this.managedFiles.size
|
|
157
|
-
) {
|
|
158
|
-
this.managedFiles = currentEmitFiles;
|
|
159
|
-
await this.initDictionaries();
|
|
160
|
-
}
|
|
161
|
-
await this.detectFileAddedOrRemoved();
|
|
162
|
-
callback();
|
|
163
|
-
}
|
|
164
|
-
);
|
|
165
|
-
compiler.hooks.watchRun.tap(
|
|
166
|
-
"IntLayerPlugin - Change detection",
|
|
167
|
-
(compilation) => {
|
|
168
|
-
if (compilation.modifiedFiles) {
|
|
169
|
-
const updatedFiles = Array.from(compilation.modifiedFiles);
|
|
170
|
-
const outputFileNames = updatedFiles.map(
|
|
171
|
-
getBundledFilePathFromIntlayerModule
|
|
172
|
-
);
|
|
173
|
-
this.updatedFiles = new Set(outputFileNames);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
);
|
|
27
|
+
apply() {
|
|
28
|
+
(0, import_chokidar.watch)({ persistent });
|
|
177
29
|
}
|
|
178
30
|
}
|
|
179
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
180
|
-
0 &&
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
//# sourceMappingURL=webpack-plugin.cjs.map
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
IntLayerPlugin
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=webpack-plugin.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import { watch } from '@intlayer/chokidar';\n\n// Watch mode or on time build\nconst persistent = process.env.NODE_ENV === 'development';\n\nexport class IntLayerPlugin {\n apply(): void {\n watch({ persistent });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAsB;AAGtB,MAAM,aAAa,QAAQ,IAAI,aAAa;AAErC,MAAM,eAAe;AAAA,EAC1B,QAAc;AACZ,+BAAM,EAAE,WAAW,CAAC;AAAA,EACtB;AACF;","names":[]}
|
|
@@ -8,40 +8,31 @@ 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 webpack_config_exports = {};
|
|
24
20
|
__export(webpack_config_exports, {
|
|
25
21
|
default: () => webpack_config_default,
|
|
26
22
|
devServerConfig: () => devServerConfig,
|
|
27
|
-
webpackConfig: () => webpackConfig
|
|
23
|
+
webpackConfig: () => webpackConfig
|
|
28
24
|
});
|
|
29
25
|
module.exports = __toCommonJS(webpack_config_exports);
|
|
30
26
|
var import_path = require("path");
|
|
31
27
|
var import_config = require("@intlayer/config");
|
|
32
|
-
var
|
|
33
|
-
var import_utils = require(
|
|
34
|
-
var import_webpack_plugin = require(
|
|
28
|
+
var import_getEntries = require('./getEntries.cjs');
|
|
29
|
+
var import_utils = require('./utils.cjs');
|
|
30
|
+
var import_webpack_plugin = require('./webpack-plugin.cjs');
|
|
35
31
|
const { content } = (0, import_config.getConfiguration)({
|
|
36
|
-
verbose:
|
|
32
|
+
verbose: false
|
|
37
33
|
});
|
|
38
|
-
const {
|
|
39
|
-
|
|
40
|
-
(0, import_glob.sync)(watchedFilesPatternWithPath).reduce((obj, el) => {
|
|
41
|
-
const hash = (0, import_utils.getFileHash)(el);
|
|
42
|
-
obj[hash] = el;
|
|
43
|
-
return obj;
|
|
44
|
-
}, {});
|
|
34
|
+
const { fileExtensions } = content;
|
|
35
|
+
(0, import_utils.defineDirname)();
|
|
45
36
|
const devServerConfig = {
|
|
46
37
|
// Enable hot module replacement
|
|
47
38
|
hot: true,
|
|
@@ -59,12 +50,10 @@ const devServerConfig = {
|
|
|
59
50
|
// watchedFilesPatternWithPath,
|
|
60
51
|
devMiddleware: {
|
|
61
52
|
// Enable write to disk to reuse the output
|
|
62
|
-
writeToDisk: true
|
|
53
|
+
writeToDisk: true
|
|
63
54
|
},
|
|
64
55
|
// Content base
|
|
65
|
-
static: {
|
|
66
|
-
directory: bundleDir,
|
|
67
|
-
},
|
|
56
|
+
static: {}
|
|
68
57
|
};
|
|
69
58
|
const webpackConfig = {
|
|
70
59
|
// Define the environment mode (development or production)
|
|
@@ -73,17 +62,16 @@ const webpackConfig = {
|
|
|
73
62
|
// Entry point of the application
|
|
74
63
|
target: "node",
|
|
75
64
|
// Specifies the target environment
|
|
76
|
-
entry:
|
|
65
|
+
entry: import_getEntries.getEntries,
|
|
77
66
|
output: {
|
|
78
67
|
clean: true,
|
|
79
68
|
// Clean the output directory before emit
|
|
80
69
|
library: "IntlLayerContent",
|
|
81
70
|
libraryTarget: "umd",
|
|
82
|
-
filename: `[name]
|
|
83
|
-
path: bundleDir,
|
|
71
|
+
filename: `[name].bundle.js`
|
|
84
72
|
},
|
|
85
73
|
cache: false,
|
|
86
|
-
|
|
74
|
+
devtool: "source-map",
|
|
87
75
|
// stats: {
|
|
88
76
|
// preset: 'errors-only',
|
|
89
77
|
// warnings: false,
|
|
@@ -94,16 +82,11 @@ const webpackConfig = {
|
|
|
94
82
|
extensions: [".ts", ".js", ".json", ".wasm", ".ts", ".tsx", ".mjs", ".cjs"],
|
|
95
83
|
modules: [
|
|
96
84
|
// To find the loader module
|
|
97
|
-
(0, import_path.join)(__dirname, "..", "node_modules"),
|
|
85
|
+
(0, import_path.join)(globalThis.__dirname, "..", "node_modules"),
|
|
98
86
|
// In the project node_modules
|
|
99
87
|
(0, import_path.join)(process.cwd(), "node_modules"),
|
|
100
88
|
// In the project node_modules
|
|
101
|
-
(0, import_path.join)(
|
|
102
|
-
process.cwd(),
|
|
103
|
-
"node_modules",
|
|
104
|
-
"intlayer-cli",
|
|
105
|
-
"node_modules"
|
|
106
|
-
),
|
|
89
|
+
(0, import_path.join)(process.cwd(), "node_modules", "intlayer-cli", "node_modules"),
|
|
107
90
|
// Or via another project by importing intlayer
|
|
108
91
|
(0, import_path.join)(
|
|
109
92
|
process.cwd(),
|
|
@@ -112,9 +95,9 @@ const webpackConfig = {
|
|
|
112
95
|
"node_modules",
|
|
113
96
|
"@intlayer/webpack",
|
|
114
97
|
"node_modules"
|
|
115
|
-
)
|
|
98
|
+
)
|
|
116
99
|
// Or via another project by importing intlayer
|
|
117
|
-
]
|
|
100
|
+
]
|
|
118
101
|
},
|
|
119
102
|
resolveLoader: {
|
|
120
103
|
// Configure how Webpack finds `loader` modules.
|
|
@@ -122,12 +105,7 @@ const webpackConfig = {
|
|
|
122
105
|
// To find the loader module
|
|
123
106
|
(0, import_path.join)(process.cwd(), "node_modules"),
|
|
124
107
|
// In the project node_modules
|
|
125
|
-
(0, import_path.join)(
|
|
126
|
-
process.cwd(),
|
|
127
|
-
"node_modules",
|
|
128
|
-
"@intlayer/webpack",
|
|
129
|
-
"node_modules"
|
|
130
|
-
),
|
|
108
|
+
(0, import_path.join)(process.cwd(), "node_modules", "@intlayer/webpack", "node_modules"),
|
|
131
109
|
// Or via another project by importing @intlayer/webpack
|
|
132
110
|
(0, import_path.join)(
|
|
133
111
|
process.cwd(),
|
|
@@ -136,45 +114,57 @@ const webpackConfig = {
|
|
|
136
114
|
"node_modules",
|
|
137
115
|
"@intlayer/webpack",
|
|
138
116
|
"node_modules"
|
|
139
|
-
)
|
|
117
|
+
)
|
|
140
118
|
// Or via another project by importing intlayer
|
|
141
|
-
]
|
|
142
|
-
// roots: [
|
|
143
|
-
// join(process.cwd()), // Project context
|
|
144
|
-
// join(process.cwd(), '@intlayer/webpack'), // Or via CLI in another project
|
|
145
|
-
// join(process.cwd(), 'intlayer', '@intlayer/webpack'), // Or via CLI in another project
|
|
146
|
-
// ],
|
|
119
|
+
]
|
|
147
120
|
},
|
|
148
121
|
module: {
|
|
149
122
|
rules: [
|
|
123
|
+
{
|
|
124
|
+
// Rule for .content.ts files
|
|
125
|
+
test: new RegExp(`(${fileExtensions.join("|")})$`),
|
|
126
|
+
use: [
|
|
127
|
+
{
|
|
128
|
+
// Transpile with esbuild-loader
|
|
129
|
+
loader: "esbuild-loader",
|
|
130
|
+
options: {
|
|
131
|
+
// JavaScript version to compile to
|
|
132
|
+
target: "es2015"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// {
|
|
136
|
+
// // Custom loader to process the transpiled code
|
|
137
|
+
// loader: resolve('./intlayer-loader'),
|
|
138
|
+
// },
|
|
139
|
+
]
|
|
140
|
+
},
|
|
150
141
|
{
|
|
151
142
|
test: /\.node$/,
|
|
152
|
-
loader: "node-loader"
|
|
143
|
+
loader: "node-loader"
|
|
153
144
|
},
|
|
154
145
|
// Use esbuild to compile JavaScript & TypeScript
|
|
155
146
|
{
|
|
156
147
|
// Match `.js`, `.jsx`, `.ts` or `.tsx` files
|
|
157
|
-
test: /\.
|
|
148
|
+
test: /\.(jsx|js|ts|tsx|mjs|cjs)?$/,
|
|
158
149
|
loader: "esbuild-loader",
|
|
159
150
|
options: {
|
|
160
151
|
// JavaScript version to compile to
|
|
161
|
-
target: "es2015"
|
|
162
|
-
}
|
|
163
|
-
}
|
|
152
|
+
target: "es2015"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
164
155
|
// JSON files are supported natively by Webpack 5, no specific loader required
|
|
165
|
-
]
|
|
156
|
+
]
|
|
166
157
|
},
|
|
167
158
|
devServer: devServerConfig,
|
|
168
159
|
plugins: [
|
|
169
|
-
new import_webpack_plugin.IntLayerPlugin()
|
|
160
|
+
new import_webpack_plugin.IntLayerPlugin()
|
|
170
161
|
// new HotModuleReplacementPlugin()
|
|
171
|
-
]
|
|
162
|
+
]
|
|
172
163
|
};
|
|
173
164
|
var webpack_config_default = webpackConfig;
|
|
174
165
|
// Annotate the CommonJS export names for ESM import in node:
|
|
175
|
-
0 &&
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
//# sourceMappingURL=webpack.config.cjs.map
|
|
166
|
+
0 && (module.exports = {
|
|
167
|
+
devServerConfig,
|
|
168
|
+
webpackConfig
|
|
169
|
+
});
|
|
170
|
+
//# sourceMappingURL=webpack.config.cjs.map
|