@vocab/webpack 1.2.12 → 1.2.13-fix-messageformat-import-20250923014407
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/chunk-nOFOJqeH.js +30 -0
- package/dist/chunk-name-CBgqhApm.js +14 -0
- package/dist/chunk-name-CBgqhApm.js.map +1 -0
- package/dist/chunk-name-D6UZ3rB7.mjs +8 -0
- package/dist/chunk-name-D6UZ3rB7.mjs.map +1 -0
- package/dist/chunk-name.d.mts +5 -0
- package/dist/chunk-name.d.ts +5 -0
- package/dist/chunk-name.js +3 -0
- package/dist/chunk-name.mjs +3 -0
- package/dist/index.d.mts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +30 -0
- package/dist/index.mjs.map +1 -0
- package/dist/loader.d.mts +9 -0
- package/dist/loader.d.ts +8 -0
- package/dist/loader.js +99 -0
- package/dist/loader.js.map +1 -0
- package/dist/loader.mjs +94 -0
- package/dist/loader.mjs.map +1 -0
- package/dist/logger-CoUhqRrx.mjs +14 -0
- package/dist/logger-CoUhqRrx.mjs.map +1 -0
- package/dist/logger-vmXVx1Ky.js +16 -0
- package/dist/logger-vmXVx1Ky.js.map +1 -0
- package/dist/web.d.mts +8 -0
- package/dist/web.d.ts +8 -0
- package/dist/web.js +31 -0
- package/dist/web.js.map +1 -0
- package/dist/web.mjs +22 -0
- package/dist/web.mjs.map +1 -0
- package/package.json +17 -27
- package/README.md +0 -827
- package/chunk-name/dist/vocab-webpack-chunk-name.cjs.d.ts +0 -2
- package/chunk-name/dist/vocab-webpack-chunk-name.cjs.dev.js +0 -9
- package/chunk-name/dist/vocab-webpack-chunk-name.cjs.js +0 -7
- package/chunk-name/dist/vocab-webpack-chunk-name.cjs.prod.js +0 -9
- package/chunk-name/dist/vocab-webpack-chunk-name.esm.js +0 -5
- package/chunk-name/package.json +0 -4
- package/dist/declarations/src/chunk-name.d.ts +0 -1
- package/dist/declarations/src/index.d.ts +0 -12
- package/dist/declarations/src/loader.d.ts +0 -5
- package/dist/declarations/src/web.d.ts +0 -3
- package/dist/logger-018d2c78.cjs.prod.js +0 -12
- package/dist/logger-c5869e3f.esm.js +0 -6
- package/dist/logger-ebb09632.cjs.dev.js +0 -12
- package/dist/vocab-webpack.cjs.d.ts +0 -2
- package/dist/vocab-webpack.cjs.dev.js +0 -43
- package/dist/vocab-webpack.cjs.js +0 -7
- package/dist/vocab-webpack.cjs.prod.js +0 -43
- package/dist/vocab-webpack.esm.js +0 -38
- package/loader/dist/vocab-webpack-loader.cjs.d.ts +0 -3
- package/loader/dist/vocab-webpack-loader.cjs.dev.js +0 -137
- package/loader/dist/vocab-webpack-loader.cjs.js +0 -7
- package/loader/dist/vocab-webpack-loader.cjs.prod.js +0 -137
- package/loader/dist/vocab-webpack-loader.esm.js +0 -109
- package/loader/package.json +0 -4
- package/web/dist/vocab-webpack-web.cjs.d.ts +0 -2
- package/web/dist/vocab-webpack-web.cjs.dev.js +0 -34
- package/web/dist/vocab-webpack-web.cjs.js +0 -7
- package/web/dist/vocab-webpack-web.cjs.prod.js +0 -34
- package/web/dist/vocab-webpack-web.esm.js +0 -26
- package/web/package.json +0 -4
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(exports, '__toESM', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return __toESM;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/chunk-name.ts
|
|
3
|
+
function getChunkName(lang) {
|
|
4
|
+
return `${lang}-translations`;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
Object.defineProperty(exports, 'getChunkName', {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return getChunkName;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=chunk-name-CBgqhApm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-name-CBgqhApm.js","names":[],"sources":["../src/chunk-name.ts"],"sourcesContent":["export function getChunkName(lang: string) {\n return `${lang}-translations`;\n}\n"],"mappings":";;AAAA,SAAgB,aAAa,MAAc;AACzC,QAAO,GAAG,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-name-D6UZ3rB7.mjs","names":[],"sources":["../src/chunk-name.ts"],"sourcesContent":["export function getChunkName(lang: string) {\n return `${lang}-translations`;\n}\n"],"mappings":";AAAA,SAAgB,aAAa,MAAc;AACzC,QAAO,GAAG,KAAK"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UserConfig } from "@vocab/core";
|
|
2
|
+
import { Compiler } from "webpack";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
interface UserOptions extends Partial<UserConfig> {
|
|
6
|
+
configFile?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const compiledVocabFileFilter: RegExp;
|
|
9
|
+
declare class VocabWebpackPlugin {
|
|
10
|
+
options: UserConfig;
|
|
11
|
+
constructor({
|
|
12
|
+
configFile,
|
|
13
|
+
...rest
|
|
14
|
+
}?: UserOptions);
|
|
15
|
+
apply(compiler: Compiler): void;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { VocabWebpackPlugin, compiledVocabFileFilter };
|
|
19
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UserConfig } from "@vocab/core";
|
|
2
|
+
import { Compiler } from "webpack";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
interface UserOptions extends Partial<UserConfig> {
|
|
6
|
+
configFile?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const compiledVocabFileFilter: RegExp;
|
|
9
|
+
declare class VocabWebpackPlugin {
|
|
10
|
+
options: UserConfig;
|
|
11
|
+
constructor({
|
|
12
|
+
configFile,
|
|
13
|
+
...rest
|
|
14
|
+
}?: UserOptions);
|
|
15
|
+
apply(compiler: Compiler): void;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { VocabWebpackPlugin, compiledVocabFileFilter };
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
+
const require_logger = require('./logger-vmXVx1Ky.js');
|
|
3
|
+
let __vocab_core = require("@vocab/core");
|
|
4
|
+
__vocab_core = require_chunk.__toESM(__vocab_core);
|
|
5
|
+
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
const compiledVocabFileFilter = /\.vocab[\\/]index\.(?:ts|js|cjs|mjs)$/;
|
|
8
|
+
var VocabWebpackPlugin = class {
|
|
9
|
+
options;
|
|
10
|
+
constructor({ configFile,...rest } = {}) {
|
|
11
|
+
require_logger.trace(`Creating Vocab plugin${configFile ? ` with config file ${configFile}` : ""}`);
|
|
12
|
+
this.options = {
|
|
13
|
+
...(0, __vocab_core.resolveConfigSync)(configFile),
|
|
14
|
+
...rest
|
|
15
|
+
};
|
|
16
|
+
(0, __vocab_core.validateConfig)(this.options);
|
|
17
|
+
}
|
|
18
|
+
apply(compiler) {
|
|
19
|
+
require_logger.trace(`Applying plugin: ${compiler.options.name} (${compiler.options.target})`);
|
|
20
|
+
if (!compiler.options.module) compiler.options.module = { rules: [] };
|
|
21
|
+
if (!compiler.options.module.rules) compiler.options.module.rules = [];
|
|
22
|
+
compiler.options.module.rules.splice(0, 0, {
|
|
23
|
+
test: compiledVocabFileFilter,
|
|
24
|
+
loader: require.resolve("@vocab/webpack/loader"),
|
|
25
|
+
options: this.options
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.VocabWebpackPlugin = VocabWebpackPlugin;
|
|
32
|
+
exports.compiledVocabFileFilter = compiledVocabFileFilter;
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n type UserConfig,\n resolveConfigSync,\n validateConfig,\n} from '@vocab/core';\nimport type { Compiler } from 'webpack';\nimport { trace } from './logger';\n\ninterface UserOptions extends Partial<UserConfig> {\n configFile?: string;\n}\n\nexport const compiledVocabFileFilter = /\\.vocab[\\\\/]index\\.(?:ts|js|cjs|mjs)$/;\n\nexport class VocabWebpackPlugin {\n options: UserConfig;\n\n constructor({ configFile, ...rest }: UserOptions = {}) {\n trace(\n `Creating Vocab plugin${\n configFile ? ` with config file ${configFile}` : ''\n }`,\n );\n this.options = {\n ...resolveConfigSync(configFile),\n ...rest,\n } as UserConfig;\n\n validateConfig(this.options);\n }\n\n apply(compiler: Compiler) {\n trace(\n `Applying plugin: ${compiler.options.name} (${compiler.options.target})`,\n );\n if (!compiler.options.module) {\n // @ts-expect-error Support for older versions of webpack that may not have module defined at this stage\n compiler.options.module = { rules: [] };\n }\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n compiler.options.module.rules.splice(0, 0, {\n test: compiledVocabFileFilter,\n loader: require.resolve('@vocab/webpack/loader'),\n options: this.options,\n });\n }\n}\n"],"mappings":";;;;;;AAYA,MAAa,0BAA0B;AAEvC,IAAa,qBAAb,MAAgC;CAC9B;CAEA,YAAY,EAAE,WAAY,GAAG,SAAsB,EAAE,EAAE;AACrD,uBACE,wBACE,aAAa,qBAAqB,eAAe,KAEpD;AACD,OAAK,UAAU;GACb,uCAAqB,WAAW;GAChC,GAAG;GACJ;AAED,mCAAe,KAAK,QAAQ;;CAG9B,MAAM,UAAoB;AACxB,uBACE,oBAAoB,SAAS,QAAQ,KAAK,IAAI,SAAS,QAAQ,OAAO,GACvE;AACD,MAAI,CAAC,SAAS,QAAQ,OAEpB,UAAS,QAAQ,SAAS,EAAE,OAAO,EAAE,EAAE;AAEzC,MAAI,CAAC,SAAS,QAAQ,OAAO,MAC3B,UAAS,QAAQ,OAAO,QAAQ,EAAE;AAEpC,WAAS,QAAQ,OAAO,MAAM,OAAO,GAAG,GAAG;GACzC,MAAM;GACN,QAAQ,QAAQ,QAAQ,wBAAwB;GAChD,SAAS,KAAK;GACf,CAAC"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __require, trace } from "./logger-CoUhqRrx.mjs";
|
|
2
|
+
import { resolveConfigSync, validateConfig } from "@vocab/core";
|
|
3
|
+
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
const compiledVocabFileFilter = /\.vocab[\\/]index\.(?:ts|js|cjs|mjs)$/;
|
|
6
|
+
var VocabWebpackPlugin = class {
|
|
7
|
+
options;
|
|
8
|
+
constructor({ configFile,...rest } = {}) {
|
|
9
|
+
trace(`Creating Vocab plugin${configFile ? ` with config file ${configFile}` : ""}`);
|
|
10
|
+
this.options = {
|
|
11
|
+
...resolveConfigSync(configFile),
|
|
12
|
+
...rest
|
|
13
|
+
};
|
|
14
|
+
validateConfig(this.options);
|
|
15
|
+
}
|
|
16
|
+
apply(compiler) {
|
|
17
|
+
trace(`Applying plugin: ${compiler.options.name} (${compiler.options.target})`);
|
|
18
|
+
if (!compiler.options.module) compiler.options.module = { rules: [] };
|
|
19
|
+
if (!compiler.options.module.rules) compiler.options.module.rules = [];
|
|
20
|
+
compiler.options.module.rules.splice(0, 0, {
|
|
21
|
+
test: compiledVocabFileFilter,
|
|
22
|
+
loader: __require.resolve("@vocab/webpack/loader"),
|
|
23
|
+
options: this.options
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { VocabWebpackPlugin, compiledVocabFileFilter };
|
|
30
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n type UserConfig,\n resolveConfigSync,\n validateConfig,\n} from '@vocab/core';\nimport type { Compiler } from 'webpack';\nimport { trace } from './logger';\n\ninterface UserOptions extends Partial<UserConfig> {\n configFile?: string;\n}\n\nexport const compiledVocabFileFilter = /\\.vocab[\\\\/]index\\.(?:ts|js|cjs|mjs)$/;\n\nexport class VocabWebpackPlugin {\n options: UserConfig;\n\n constructor({ configFile, ...rest }: UserOptions = {}) {\n trace(\n `Creating Vocab plugin${\n configFile ? ` with config file ${configFile}` : ''\n }`,\n );\n this.options = {\n ...resolveConfigSync(configFile),\n ...rest,\n } as UserConfig;\n\n validateConfig(this.options);\n }\n\n apply(compiler: Compiler) {\n trace(\n `Applying plugin: ${compiler.options.name} (${compiler.options.target})`,\n );\n if (!compiler.options.module) {\n // @ts-expect-error Support for older versions of webpack that may not have module defined at this stage\n compiler.options.module = { rules: [] };\n }\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n compiler.options.module.rules.splice(0, 0, {\n test: compiledVocabFileFilter,\n loader: require.resolve('@vocab/webpack/loader'),\n options: this.options,\n });\n }\n}\n"],"mappings":";;;;AAYA,MAAa,0BAA0B;AAEvC,IAAa,qBAAb,MAAgC;CAC9B;CAEA,YAAY,EAAE,WAAY,GAAG,SAAsB,EAAE,EAAE;AACrD,QACE,wBACE,aAAa,qBAAqB,eAAe,KAEpD;AACD,OAAK,UAAU;GACb,GAAG,kBAAkB,WAAW;GAChC,GAAG;GACJ;AAED,iBAAe,KAAK,QAAQ;;CAG9B,MAAM,UAAoB;AACxB,QACE,oBAAoB,SAAS,QAAQ,KAAK,IAAI,SAAS,QAAQ,OAAO,GACvE;AACD,MAAI,CAAC,SAAS,QAAQ,OAEpB,UAAS,QAAQ,SAAS,EAAE,OAAO,EAAE,EAAE;AAEzC,MAAI,CAAC,SAAS,QAAQ,OAAO,MAC3B,UAAS,QAAQ,OAAO,QAAQ,EAAE;AAEpC,WAAS,QAAQ,OAAO,MAAM,OAAO,GAAG,GAAG;GACzC,MAAM;GACN,kBAAgB,QAAQ,wBAAwB;GAChD,SAAS,KAAK;GACf,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UserConfig } from "@vocab/core";
|
|
2
|
+
import { LoaderContext } from "webpack";
|
|
3
|
+
|
|
4
|
+
//#region src/loader.d.ts
|
|
5
|
+
type LoaderContext$1 = LoaderContext<UserConfig>;
|
|
6
|
+
declare function vocabLoader(this: LoaderContext$1, source: string): Promise<void>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { vocabLoader as default };
|
|
9
|
+
//# sourceMappingURL=loader.d.mts.map
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UserConfig } from "@vocab/core";
|
|
2
|
+
import { LoaderContext } from "webpack";
|
|
3
|
+
|
|
4
|
+
//#region src/loader.d.ts
|
|
5
|
+
type LoaderContext$1 = LoaderContext<UserConfig>;
|
|
6
|
+
declare function vocabLoader(this: LoaderContext$1, source: string): Promise<void>;
|
|
7
|
+
export = vocabLoader;
|
|
8
|
+
//# sourceMappingURL=loader.d.ts.map
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
+
const require_chunk_name = require('./chunk-name-CBgqhApm.js');
|
|
3
|
+
const require_logger = require('./logger-vmXVx1Ky.js');
|
|
4
|
+
let __vocab_core = require("@vocab/core");
|
|
5
|
+
__vocab_core = require_chunk.__toESM(__vocab_core);
|
|
6
|
+
let path = require("path");
|
|
7
|
+
path = require_chunk.__toESM(path);
|
|
8
|
+
let cjs_module_lexer = require("cjs-module-lexer");
|
|
9
|
+
cjs_module_lexer = require_chunk.__toESM(cjs_module_lexer);
|
|
10
|
+
let es_module_lexer = require("es-module-lexer");
|
|
11
|
+
es_module_lexer = require_chunk.__toESM(es_module_lexer);
|
|
12
|
+
|
|
13
|
+
//#region src/loader.ts
|
|
14
|
+
const trace$1 = require_logger.trace.extend("loader");
|
|
15
|
+
const virtualResourceLoader = require.resolve("virtual-resource-loader");
|
|
16
|
+
function createIdentifier(lang, resourcePath, loadedTranslation) {
|
|
17
|
+
trace$1("Creating identifier for language", lang);
|
|
18
|
+
const languageTranslations = loadedTranslation.languages[lang] ?? {};
|
|
19
|
+
const langJson = {};
|
|
20
|
+
for (const key of loadedTranslation.keys) langJson[key] = languageTranslations[key].message;
|
|
21
|
+
const base64 = Buffer.from(JSON.stringify(langJson), "utf-8").toString("base64");
|
|
22
|
+
const unloader = `${virtualResourceLoader}?source=${encodeURIComponent(base64)}`;
|
|
23
|
+
return `./${path.default.basename(resourcePath, "translations.json")}-${lang}-virtual.json!=!${unloader}!`;
|
|
24
|
+
}
|
|
25
|
+
function stringifyRequest(request) {
|
|
26
|
+
return JSON.stringify(this.utils.contextify(this.context, request));
|
|
27
|
+
}
|
|
28
|
+
function renderLanguageLoaderAsync(resourcePath, loadedTranslation) {
|
|
29
|
+
return (lang) => {
|
|
30
|
+
const identifier = stringifyRequest.call(this, createIdentifier(lang, resourcePath, loadedTranslation));
|
|
31
|
+
return `
|
|
32
|
+
createLanguage(
|
|
33
|
+
require.resolveWeak(${identifier}),
|
|
34
|
+
() => import(
|
|
35
|
+
/* webpackChunkName: ${JSON.stringify(require_chunk_name.getChunkName(lang))} */
|
|
36
|
+
${identifier}
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
`.trim();
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function findExportNames(source, mode) {
|
|
43
|
+
if (mode === "esm") {
|
|
44
|
+
const [, exports$2] = es_module_lexer.parse(source);
|
|
45
|
+
return exports$2;
|
|
46
|
+
}
|
|
47
|
+
const { exports: exports$1 } = cjs_module_lexer.parse(source);
|
|
48
|
+
return exports$1;
|
|
49
|
+
}
|
|
50
|
+
async function vocabLoader(source) {
|
|
51
|
+
trace$1(`Using vocab loader for ${this.resourcePath}`);
|
|
52
|
+
const callback = this.async();
|
|
53
|
+
if (!callback) throw new Error(`Webpack didn't provide an async callback`);
|
|
54
|
+
const config = this.getOptions();
|
|
55
|
+
const devJsonFilePath = (0, __vocab_core.getDevLanguageFileFromTsFile)(this.resourcePath);
|
|
56
|
+
const loadedTranslation = (0, __vocab_core.loadTranslation)({
|
|
57
|
+
filePath: devJsonFilePath,
|
|
58
|
+
fallbacks: "all"
|
|
59
|
+
}, config);
|
|
60
|
+
const target = this.target;
|
|
61
|
+
if (target && target !== "web") {
|
|
62
|
+
trace$1(`Why are you using the loader on ${target}?`);
|
|
63
|
+
callback(/* @__PURE__ */ new Error("Called Vocab Loader with non-web target"));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const renderLanguageLoader = renderLanguageLoaderAsync.call(this, devJsonFilePath, loadedTranslation);
|
|
67
|
+
const translations = `
|
|
68
|
+
const translations = createTranslationFile({
|
|
69
|
+
${Object.keys(loadedTranslation.languages).map((lang) => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`).join(",\n")}
|
|
70
|
+
});
|
|
71
|
+
`;
|
|
72
|
+
let result;
|
|
73
|
+
await es_module_lexer.init;
|
|
74
|
+
const esmExports = findExportNames(source, "esm");
|
|
75
|
+
if (esmExports.length > 0) {
|
|
76
|
+
const exportName = esmExports[0];
|
|
77
|
+
trace$1(`Found ESM export '${exportName.n}' in ${this.resourcePath}`);
|
|
78
|
+
result = `
|
|
79
|
+
import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';
|
|
80
|
+
${translations}
|
|
81
|
+
export { translations as ${exportName.n} };
|
|
82
|
+
`;
|
|
83
|
+
} else {
|
|
84
|
+
await cjs_module_lexer.init();
|
|
85
|
+
const exportName = findExportNames(source, "cjs")[0];
|
|
86
|
+
trace$1(`Found CJS export '${exportName}' in ${this.resourcePath}`);
|
|
87
|
+
result = `
|
|
88
|
+
const { createLanguage, createTranslationFile } = require('@vocab/webpack/${target}');
|
|
89
|
+
${translations}
|
|
90
|
+
exports.${exportName} = translations;
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
trace$1("Created translation file", result);
|
|
94
|
+
callback(null, result);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
module.exports = vocabLoader;
|
|
99
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","names":["trace","_trace","langJson: TranslationMessagesByKey","getChunkName","exports","esModuleLexer","cjsModuleLexer"],"sources":["../src/loader.ts"],"sourcesContent":["import path from 'path';\nimport {\n type LoadedTranslation,\n type UserConfig,\n type TranslationMessagesByKey,\n getDevLanguageFileFromTsFile,\n loadTranslation,\n} from '@vocab/core';\nimport * as cjsModuleLexer from 'cjs-module-lexer';\nimport * as esModuleLexer from 'es-module-lexer';\nimport type { LoaderContext as WebpackLoaderContext } from 'webpack';\n\nimport { getChunkName } from './chunk-name';\nimport { trace as _trace } from './logger';\n\ntype LoaderContext = WebpackLoaderContext<UserConfig>;\n\nconst trace = _trace.extend('loader');\n\n// Resolve virtual-resource-loader dependency from current package\nconst virtualResourceLoader = require.resolve('virtual-resource-loader');\n\nfunction createIdentifier(\n lang: string,\n resourcePath: string,\n loadedTranslation: LoadedTranslation,\n) {\n trace('Creating identifier for language', lang);\n const languageTranslations = loadedTranslation.languages[lang] ?? {};\n\n const langJson: TranslationMessagesByKey = {};\n\n for (const key of loadedTranslation.keys) {\n langJson[key] = languageTranslations[key].message;\n }\n\n const base64 = Buffer.from(JSON.stringify(langJson), 'utf-8').toString(\n 'base64',\n );\n\n const unloader = `${virtualResourceLoader}?source=${encodeURIComponent(\n base64,\n )}`;\n const fileIdent = path.basename(resourcePath, 'translations.json');\n\n return `./${fileIdent}-${lang}-virtual.json!=!${unloader}!`;\n}\n\n// reimplement `stringifyRequest` from loader-utils 2.x\n// https://github.com/webpack/loader-utils/blob/master/CHANGELOG.md#300-2021-10-20\nfunction stringifyRequest(this: LoaderContext, request: string) {\n return JSON.stringify(this.utils.contextify(this.context, request));\n}\n\nfunction renderLanguageLoaderAsync(\n this: LoaderContext,\n resourcePath: string,\n loadedTranslation: LoadedTranslation,\n) {\n return (lang: string) => {\n const identifier = stringifyRequest.call(\n this,\n createIdentifier(lang, resourcePath, loadedTranslation),\n );\n\n return /* ts */ `\n createLanguage(\n require.resolveWeak(${identifier}),\n () => import(\n /* webpackChunkName: ${JSON.stringify(getChunkName(lang))} */\n ${identifier}\n )\n )\n `.trim();\n };\n}\n\nfunction findExportNames(source: string, mode: 'cjs'): string[];\nfunction findExportNames(\n source: string,\n mode: 'esm',\n): esModuleLexer.ExportSpecifier[];\nfunction findExportNames(source: string, mode: 'cjs' | 'esm') {\n if (mode === 'esm') {\n const [, exports] = esModuleLexer.parse(source);\n return exports;\n }\n const { exports } = cjsModuleLexer.parse(source);\n return exports;\n}\n\nexport default async function vocabLoader(this: LoaderContext, source: string) {\n trace(`Using vocab loader for ${this.resourcePath}`);\n const callback = this.async();\n\n if (!callback) {\n throw new Error(`Webpack didn't provide an async callback`);\n }\n\n const config = this.getOptions();\n\n const devJsonFilePath = getDevLanguageFileFromTsFile(this.resourcePath);\n\n const loadedTranslation = loadTranslation(\n { filePath: devJsonFilePath, fallbacks: 'all' },\n config,\n );\n\n const target = this.target;\n if (target && target !== 'web') {\n trace(`Why are you using the loader on ${target}?`);\n callback(new Error('Called Vocab Loader with non-web target'));\n return;\n }\n\n const renderLanguageLoader = renderLanguageLoaderAsync.call(\n this,\n devJsonFilePath,\n loadedTranslation,\n );\n\n const translations = /* ts */ `\n const translations = createTranslationFile({\n ${Object.keys(loadedTranslation.languages)\n .map((lang) => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`)\n .join(',\\n')}\n });\n `;\n let result;\n\n // this is necessary for the Web Assembly boot\n await esModuleLexer.init;\n const esmExports = findExportNames(source, 'esm');\n if (esmExports.length > 0) {\n const exportName = esmExports[0];\n trace(`Found ESM export '${exportName.n}' in ${this.resourcePath}`);\n\n result = /* ts */ `\n import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';\n ${translations}\n export { translations as ${exportName.n} };\n `;\n } else {\n // init needs to be called and waited upon\n await cjsModuleLexer.init();\n\n const exportName = findExportNames(source, 'cjs')[0];\n trace(`Found CJS export '${exportName}' in ${this.resourcePath}`);\n\n result = /* ts */ `\n const { createLanguage, createTranslationFile } = require('@vocab/webpack/${target}');\n ${translations}\n exports.${exportName} = translations;\n `;\n }\n\n trace('Created translation file', result);\n\n callback(null, result);\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,MAAMA,UAAQC,qBAAO,OAAO,SAAS;AAGrC,MAAM,wBAAwB,QAAQ,QAAQ,0BAA0B;AAExE,SAAS,iBACP,MACA,cACA,mBACA;AACA,SAAM,oCAAoC,KAAK;CAC/C,MAAM,uBAAuB,kBAAkB,UAAU,SAAS,EAAE;CAEpE,MAAMC,WAAqC,EAAE;AAE7C,MAAK,MAAM,OAAO,kBAAkB,KAClC,UAAS,OAAO,qBAAqB,KAAK;CAG5C,MAAM,SAAS,OAAO,KAAK,KAAK,UAAU,SAAS,EAAE,QAAQ,CAAC,SAC5D,SACD;CAED,MAAM,WAAW,GAAG,sBAAsB,UAAU,mBAClD,OACD;AAGD,QAAO,KAFW,aAAK,SAAS,cAAc,oBAAoB,CAE5C,GAAG,KAAK,kBAAkB,SAAS;;AAK3D,SAAS,iBAAsC,SAAiB;AAC9D,QAAO,KAAK,UAAU,KAAK,MAAM,WAAW,KAAK,SAAS,QAAQ,CAAC;;AAGrE,SAAS,0BAEP,cACA,mBACA;AACA,SAAQ,SAAiB;EACvB,MAAM,aAAa,iBAAiB,KAClC,MACA,iBAAiB,MAAM,cAAc,kBAAkB,CACxD;AAED,SAAgB;;8BAEU,WAAW;;iCAER,KAAK,UAAUC,gCAAa,KAAK,CAAC,CAAC;YACxD,WAAW;;;MAGjB,MAAM;;;AASZ,SAAS,gBAAgB,QAAgB,MAAqB;AAC5D,KAAI,SAAS,OAAO;EAClB,MAAM,GAAGC,aAAWC,gBAAc,MAAM,OAAO;AAC/C,SAAOD;;CAET,MAAM,EAAE,uBAAYE,iBAAe,MAAM,OAAO;AAChD,QAAOF;;AAGT,eAA8B,YAAiC,QAAgB;AAC7E,SAAM,0BAA0B,KAAK,eAAe;CACpD,MAAM,WAAW,KAAK,OAAO;AAE7B,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,2CAA2C;CAG7D,MAAM,SAAS,KAAK,YAAY;CAEhC,MAAM,iEAA+C,KAAK,aAAa;CAEvE,MAAM,sDACJ;EAAE,UAAU;EAAiB,WAAW;EAAO,EAC/C,OACD;CAED,MAAM,SAAS,KAAK;AACpB,KAAI,UAAU,WAAW,OAAO;AAC9B,UAAM,mCAAmC,OAAO,GAAG;AACnD,2BAAS,IAAI,MAAM,0CAA0C,CAAC;AAC9D;;CAGF,MAAM,uBAAuB,0BAA0B,KACrD,MACA,iBACA,kBACD;CAED,MAAM,eAAwB;;QAExB,OAAO,KAAK,kBAAkB,UAAU,CACvC,KAAK,SAAS,GAAG,KAAK,UAAU,KAAK,CAAC,IAAI,qBAAqB,KAAK,GAAG,CACvE,KAAK,MAAM,CAAC;;;CAGnB,IAAI;AAGJ,OAAMC,gBAAc;CACpB,MAAM,aAAa,gBAAgB,QAAQ,MAAM;AACjD,KAAI,WAAW,SAAS,GAAG;EACzB,MAAM,aAAa,WAAW;AAC9B,UAAM,qBAAqB,WAAW,EAAE,OAAO,KAAK,eAAe;AAEnE,WAAkB;8EACwD,OAAO;QAC7E,aAAa;iCACY,WAAW,EAAE;;QAErC;AAEL,QAAMC,iBAAe,MAAM;EAE3B,MAAM,aAAa,gBAAgB,QAAQ,MAAM,CAAC;AAClD,UAAM,qBAAqB,WAAW,OAAO,KAAK,eAAe;AAEjE,WAAkB;kFAC4D,OAAO;QACjF,aAAa;gBACL,WAAW;;;AAIzB,SAAM,4BAA4B,OAAO;AAEzC,UAAS,MAAM,OAAO"}
|
package/dist/loader.mjs
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { __require, trace } from "./logger-CoUhqRrx.mjs";
|
|
2
|
+
import { getChunkName } from "./chunk-name-D6UZ3rB7.mjs";
|
|
3
|
+
import { getDevLanguageFileFromTsFile, loadTranslation } from "@vocab/core";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import * as cjsModuleLexer from "cjs-module-lexer";
|
|
6
|
+
import * as esModuleLexer from "es-module-lexer";
|
|
7
|
+
|
|
8
|
+
//#region src/loader.ts
|
|
9
|
+
const trace$1 = trace.extend("loader");
|
|
10
|
+
const virtualResourceLoader = __require.resolve("virtual-resource-loader");
|
|
11
|
+
function createIdentifier(lang, resourcePath, loadedTranslation) {
|
|
12
|
+
trace$1("Creating identifier for language", lang);
|
|
13
|
+
const languageTranslations = loadedTranslation.languages[lang] ?? {};
|
|
14
|
+
const langJson = {};
|
|
15
|
+
for (const key of loadedTranslation.keys) langJson[key] = languageTranslations[key].message;
|
|
16
|
+
const base64 = Buffer.from(JSON.stringify(langJson), "utf-8").toString("base64");
|
|
17
|
+
const unloader = `${virtualResourceLoader}?source=${encodeURIComponent(base64)}`;
|
|
18
|
+
return `./${path.basename(resourcePath, "translations.json")}-${lang}-virtual.json!=!${unloader}!`;
|
|
19
|
+
}
|
|
20
|
+
function stringifyRequest(request) {
|
|
21
|
+
return JSON.stringify(this.utils.contextify(this.context, request));
|
|
22
|
+
}
|
|
23
|
+
function renderLanguageLoaderAsync(resourcePath, loadedTranslation) {
|
|
24
|
+
return (lang) => {
|
|
25
|
+
const identifier = stringifyRequest.call(this, createIdentifier(lang, resourcePath, loadedTranslation));
|
|
26
|
+
return `
|
|
27
|
+
createLanguage(
|
|
28
|
+
require.resolveWeak(${identifier}),
|
|
29
|
+
() => import(
|
|
30
|
+
/* webpackChunkName: ${JSON.stringify(getChunkName(lang))} */
|
|
31
|
+
${identifier}
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
`.trim();
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function findExportNames(source, mode) {
|
|
38
|
+
if (mode === "esm") {
|
|
39
|
+
const [, exports$1] = esModuleLexer.parse(source);
|
|
40
|
+
return exports$1;
|
|
41
|
+
}
|
|
42
|
+
const { exports } = cjsModuleLexer.parse(source);
|
|
43
|
+
return exports;
|
|
44
|
+
}
|
|
45
|
+
async function vocabLoader(source) {
|
|
46
|
+
trace$1(`Using vocab loader for ${this.resourcePath}`);
|
|
47
|
+
const callback = this.async();
|
|
48
|
+
if (!callback) throw new Error(`Webpack didn't provide an async callback`);
|
|
49
|
+
const config = this.getOptions();
|
|
50
|
+
const devJsonFilePath = getDevLanguageFileFromTsFile(this.resourcePath);
|
|
51
|
+
const loadedTranslation = loadTranslation({
|
|
52
|
+
filePath: devJsonFilePath,
|
|
53
|
+
fallbacks: "all"
|
|
54
|
+
}, config);
|
|
55
|
+
const target = this.target;
|
|
56
|
+
if (target && target !== "web") {
|
|
57
|
+
trace$1(`Why are you using the loader on ${target}?`);
|
|
58
|
+
callback(/* @__PURE__ */ new Error("Called Vocab Loader with non-web target"));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const renderLanguageLoader = renderLanguageLoaderAsync.call(this, devJsonFilePath, loadedTranslation);
|
|
62
|
+
const translations = `
|
|
63
|
+
const translations = createTranslationFile({
|
|
64
|
+
${Object.keys(loadedTranslation.languages).map((lang) => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`).join(",\n")}
|
|
65
|
+
});
|
|
66
|
+
`;
|
|
67
|
+
let result;
|
|
68
|
+
await esModuleLexer.init;
|
|
69
|
+
const esmExports = findExportNames(source, "esm");
|
|
70
|
+
if (esmExports.length > 0) {
|
|
71
|
+
const exportName = esmExports[0];
|
|
72
|
+
trace$1(`Found ESM export '${exportName.n}' in ${this.resourcePath}`);
|
|
73
|
+
result = `
|
|
74
|
+
import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';
|
|
75
|
+
${translations}
|
|
76
|
+
export { translations as ${exportName.n} };
|
|
77
|
+
`;
|
|
78
|
+
} else {
|
|
79
|
+
await cjsModuleLexer.init();
|
|
80
|
+
const exportName = findExportNames(source, "cjs")[0];
|
|
81
|
+
trace$1(`Found CJS export '${exportName}' in ${this.resourcePath}`);
|
|
82
|
+
result = `
|
|
83
|
+
const { createLanguage, createTranslationFile } = require('@vocab/webpack/${target}');
|
|
84
|
+
${translations}
|
|
85
|
+
exports.${exportName} = translations;
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
trace$1("Created translation file", result);
|
|
89
|
+
callback(null, result);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
export { vocabLoader as default };
|
|
94
|
+
//# sourceMappingURL=loader.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.mjs","names":["trace","_trace","langJson: TranslationMessagesByKey","exports"],"sources":["../src/loader.ts"],"sourcesContent":["import path from 'path';\nimport {\n type LoadedTranslation,\n type UserConfig,\n type TranslationMessagesByKey,\n getDevLanguageFileFromTsFile,\n loadTranslation,\n} from '@vocab/core';\nimport * as cjsModuleLexer from 'cjs-module-lexer';\nimport * as esModuleLexer from 'es-module-lexer';\nimport type { LoaderContext as WebpackLoaderContext } from 'webpack';\n\nimport { getChunkName } from './chunk-name';\nimport { trace as _trace } from './logger';\n\ntype LoaderContext = WebpackLoaderContext<UserConfig>;\n\nconst trace = _trace.extend('loader');\n\n// Resolve virtual-resource-loader dependency from current package\nconst virtualResourceLoader = require.resolve('virtual-resource-loader');\n\nfunction createIdentifier(\n lang: string,\n resourcePath: string,\n loadedTranslation: LoadedTranslation,\n) {\n trace('Creating identifier for language', lang);\n const languageTranslations = loadedTranslation.languages[lang] ?? {};\n\n const langJson: TranslationMessagesByKey = {};\n\n for (const key of loadedTranslation.keys) {\n langJson[key] = languageTranslations[key].message;\n }\n\n const base64 = Buffer.from(JSON.stringify(langJson), 'utf-8').toString(\n 'base64',\n );\n\n const unloader = `${virtualResourceLoader}?source=${encodeURIComponent(\n base64,\n )}`;\n const fileIdent = path.basename(resourcePath, 'translations.json');\n\n return `./${fileIdent}-${lang}-virtual.json!=!${unloader}!`;\n}\n\n// reimplement `stringifyRequest` from loader-utils 2.x\n// https://github.com/webpack/loader-utils/blob/master/CHANGELOG.md#300-2021-10-20\nfunction stringifyRequest(this: LoaderContext, request: string) {\n return JSON.stringify(this.utils.contextify(this.context, request));\n}\n\nfunction renderLanguageLoaderAsync(\n this: LoaderContext,\n resourcePath: string,\n loadedTranslation: LoadedTranslation,\n) {\n return (lang: string) => {\n const identifier = stringifyRequest.call(\n this,\n createIdentifier(lang, resourcePath, loadedTranslation),\n );\n\n return /* ts */ `\n createLanguage(\n require.resolveWeak(${identifier}),\n () => import(\n /* webpackChunkName: ${JSON.stringify(getChunkName(lang))} */\n ${identifier}\n )\n )\n `.trim();\n };\n}\n\nfunction findExportNames(source: string, mode: 'cjs'): string[];\nfunction findExportNames(\n source: string,\n mode: 'esm',\n): esModuleLexer.ExportSpecifier[];\nfunction findExportNames(source: string, mode: 'cjs' | 'esm') {\n if (mode === 'esm') {\n const [, exports] = esModuleLexer.parse(source);\n return exports;\n }\n const { exports } = cjsModuleLexer.parse(source);\n return exports;\n}\n\nexport default async function vocabLoader(this: LoaderContext, source: string) {\n trace(`Using vocab loader for ${this.resourcePath}`);\n const callback = this.async();\n\n if (!callback) {\n throw new Error(`Webpack didn't provide an async callback`);\n }\n\n const config = this.getOptions();\n\n const devJsonFilePath = getDevLanguageFileFromTsFile(this.resourcePath);\n\n const loadedTranslation = loadTranslation(\n { filePath: devJsonFilePath, fallbacks: 'all' },\n config,\n );\n\n const target = this.target;\n if (target && target !== 'web') {\n trace(`Why are you using the loader on ${target}?`);\n callback(new Error('Called Vocab Loader with non-web target'));\n return;\n }\n\n const renderLanguageLoader = renderLanguageLoaderAsync.call(\n this,\n devJsonFilePath,\n loadedTranslation,\n );\n\n const translations = /* ts */ `\n const translations = createTranslationFile({\n ${Object.keys(loadedTranslation.languages)\n .map((lang) => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`)\n .join(',\\n')}\n });\n `;\n let result;\n\n // this is necessary for the Web Assembly boot\n await esModuleLexer.init;\n const esmExports = findExportNames(source, 'esm');\n if (esmExports.length > 0) {\n const exportName = esmExports[0];\n trace(`Found ESM export '${exportName.n}' in ${this.resourcePath}`);\n\n result = /* ts */ `\n import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';\n ${translations}\n export { translations as ${exportName.n} };\n `;\n } else {\n // init needs to be called and waited upon\n await cjsModuleLexer.init();\n\n const exportName = findExportNames(source, 'cjs')[0];\n trace(`Found CJS export '${exportName}' in ${this.resourcePath}`);\n\n result = /* ts */ `\n const { createLanguage, createTranslationFile } = require('@vocab/webpack/${target}');\n ${translations}\n exports.${exportName} = translations;\n `;\n }\n\n trace('Created translation file', result);\n\n callback(null, result);\n}\n"],"mappings":";;;;;;;;AAiBA,MAAMA,UAAQC,MAAO,OAAO,SAAS;AAGrC,MAAM,kCAAgC,QAAQ,0BAA0B;AAExE,SAAS,iBACP,MACA,cACA,mBACA;AACA,SAAM,oCAAoC,KAAK;CAC/C,MAAM,uBAAuB,kBAAkB,UAAU,SAAS,EAAE;CAEpE,MAAMC,WAAqC,EAAE;AAE7C,MAAK,MAAM,OAAO,kBAAkB,KAClC,UAAS,OAAO,qBAAqB,KAAK;CAG5C,MAAM,SAAS,OAAO,KAAK,KAAK,UAAU,SAAS,EAAE,QAAQ,CAAC,SAC5D,SACD;CAED,MAAM,WAAW,GAAG,sBAAsB,UAAU,mBAClD,OACD;AAGD,QAAO,KAFW,KAAK,SAAS,cAAc,oBAAoB,CAE5C,GAAG,KAAK,kBAAkB,SAAS;;AAK3D,SAAS,iBAAsC,SAAiB;AAC9D,QAAO,KAAK,UAAU,KAAK,MAAM,WAAW,KAAK,SAAS,QAAQ,CAAC;;AAGrE,SAAS,0BAEP,cACA,mBACA;AACA,SAAQ,SAAiB;EACvB,MAAM,aAAa,iBAAiB,KAClC,MACA,iBAAiB,MAAM,cAAc,kBAAkB,CACxD;AAED,SAAgB;;8BAEU,WAAW;;iCAER,KAAK,UAAU,aAAa,KAAK,CAAC,CAAC;YACxD,WAAW;;;MAGjB,MAAM;;;AASZ,SAAS,gBAAgB,QAAgB,MAAqB;AAC5D,KAAI,SAAS,OAAO;EAClB,MAAM,GAAGC,aAAW,cAAc,MAAM,OAAO;AAC/C,SAAOA;;CAET,MAAM,EAAE,YAAY,eAAe,MAAM,OAAO;AAChD,QAAO;;AAGT,eAA8B,YAAiC,QAAgB;AAC7E,SAAM,0BAA0B,KAAK,eAAe;CACpD,MAAM,WAAW,KAAK,OAAO;AAE7B,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,2CAA2C;CAG7D,MAAM,SAAS,KAAK,YAAY;CAEhC,MAAM,kBAAkB,6BAA6B,KAAK,aAAa;CAEvE,MAAM,oBAAoB,gBACxB;EAAE,UAAU;EAAiB,WAAW;EAAO,EAC/C,OACD;CAED,MAAM,SAAS,KAAK;AACpB,KAAI,UAAU,WAAW,OAAO;AAC9B,UAAM,mCAAmC,OAAO,GAAG;AACnD,2BAAS,IAAI,MAAM,0CAA0C,CAAC;AAC9D;;CAGF,MAAM,uBAAuB,0BAA0B,KACrD,MACA,iBACA,kBACD;CAED,MAAM,eAAwB;;QAExB,OAAO,KAAK,kBAAkB,UAAU,CACvC,KAAK,SAAS,GAAG,KAAK,UAAU,KAAK,CAAC,IAAI,qBAAqB,KAAK,GAAG,CACvE,KAAK,MAAM,CAAC;;;CAGnB,IAAI;AAGJ,OAAM,cAAc;CACpB,MAAM,aAAa,gBAAgB,QAAQ,MAAM;AACjD,KAAI,WAAW,SAAS,GAAG;EACzB,MAAM,aAAa,WAAW;AAC9B,UAAM,qBAAqB,WAAW,EAAE,OAAO,KAAK,eAAe;AAEnE,WAAkB;8EACwD,OAAO;QAC7E,aAAa;iCACY,WAAW,EAAE;;QAErC;AAEL,QAAM,eAAe,MAAM;EAE3B,MAAM,aAAa,gBAAgB,QAAQ,MAAM,CAAC;AAClD,UAAM,qBAAqB,WAAW,OAAO,KAAK,eAAe;AAEjE,WAAkB;kFAC4D,OAAO;QACjF,aAAa;gBACL,WAAW;;;AAIzB,SAAM,4BAA4B,OAAO;AAEzC,UAAS,MAAM,OAAO"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import "picocolors";
|
|
3
|
+
import debug from "debug";
|
|
4
|
+
|
|
5
|
+
//#region rolldown:runtime
|
|
6
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/logger.ts
|
|
10
|
+
const trace = debug(`vocab:webpack`);
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __require, trace };
|
|
14
|
+
//# sourceMappingURL=logger-CoUhqRrx.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-CoUhqRrx.mjs","names":[],"sources":["../src/logger.ts"],"sourcesContent":["import pc from 'picocolors';\nimport debug from 'debug';\n\nexport const trace = debug(`vocab:webpack`);\n\nexport const log = (...params: unknown[]) => {\n // eslint-disable-next-line no-console\n console.log(pc.yellow('Vocab'), ...params);\n};\n"],"mappings":";;;;;;;;;AAGA,MAAa,QAAQ,MAAM,gBAAgB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
+
require("picocolors");
|
|
3
|
+
let debug = require("debug");
|
|
4
|
+
debug = require_chunk.__toESM(debug);
|
|
5
|
+
|
|
6
|
+
//#region src/logger.ts
|
|
7
|
+
const trace = (0, debug.default)(`vocab:webpack`);
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
Object.defineProperty(exports, 'trace', {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return trace;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=logger-vmXVx1Ky.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-vmXVx1Ky.js","names":[],"sources":["../src/logger.ts"],"sourcesContent":["import pc from 'picocolors';\nimport debug from 'debug';\n\nexport const trace = debug(`vocab:webpack`);\n\nexport const log = (...params: unknown[]) => {\n // eslint-disable-next-line no-console\n console.log(pc.yellow('Vocab'), ...params);\n};\n"],"mappings":";;;;;;AAGA,MAAa,2BAAc,gBAAgB"}
|
package/dist/web.d.mts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TranslationModule } from "@vocab/core";
|
|
2
|
+
import { createTranslationFile } from "@vocab/core/translation-file";
|
|
3
|
+
|
|
4
|
+
//#region src/web.d.ts
|
|
5
|
+
declare const createLanguage: (moduleId: string, loadImport: () => Promise<any>) => TranslationModule<any>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createLanguage, createTranslationFile };
|
|
8
|
+
//# sourceMappingURL=web.d.mts.map
|
package/dist/web.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TranslationModule } from "@vocab/core";
|
|
2
|
+
import { createTranslationFile } from "@vocab/core/translation-file";
|
|
3
|
+
|
|
4
|
+
//#region src/web.d.ts
|
|
5
|
+
declare const createLanguage: (moduleId: string, loadImport: () => Promise<any>) => TranslationModule<any>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createLanguage, createTranslationFile };
|
|
8
|
+
//# sourceMappingURL=web.d.ts.map
|
package/dist/web.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
+
let __vocab_core_icu_handler = require("@vocab/core/icu-handler");
|
|
3
|
+
__vocab_core_icu_handler = require_chunk.__toESM(__vocab_core_icu_handler);
|
|
4
|
+
let __vocab_core_translation_file = require("@vocab/core/translation-file");
|
|
5
|
+
__vocab_core_translation_file = require_chunk.__toESM(__vocab_core_translation_file);
|
|
6
|
+
|
|
7
|
+
//#region src/web.ts
|
|
8
|
+
const createLanguage = (moduleId, loadImport) => {
|
|
9
|
+
let promiseValue;
|
|
10
|
+
return {
|
|
11
|
+
getValue: (locale) => {
|
|
12
|
+
if (!__webpack_modules__[moduleId]) return;
|
|
13
|
+
const m = __webpack_require__(moduleId);
|
|
14
|
+
return (0, __vocab_core_icu_handler.getParsedICUMessages)(m, locale);
|
|
15
|
+
},
|
|
16
|
+
load: () => {
|
|
17
|
+
if (!promiseValue) promiseValue = loadImport();
|
|
18
|
+
return promiseValue;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.createLanguage = createLanguage;
|
|
25
|
+
Object.defineProperty(exports, 'createTranslationFile', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return __vocab_core_translation_file.createTranslationFile;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=web.js.map
|
package/dist/web.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","names":["promiseValue: Promise<any>"],"sources":["../src/web.ts"],"sourcesContent":["import type { TranslationModule, TranslationMessagesByKey } from '@vocab/core';\nimport { getParsedICUMessages } from '@vocab/core/icu-handler';\n\nexport { createTranslationFile } from '@vocab/core/translation-file';\n\nexport const createLanguage = (\n moduleId: string,\n loadImport: () => Promise<any>,\n): TranslationModule<any> => {\n let promiseValue: Promise<any>;\n\n return {\n getValue: (locale) => {\n // @ts-expect-error Missing webpack types\n if (!__webpack_modules__[moduleId]) {\n return undefined;\n }\n\n // @ts-expect-error Missing webpack types\n const m = __webpack_require__(moduleId) as TranslationMessagesByKey;\n\n return getParsedICUMessages(m, locale);\n },\n load: () => {\n if (!promiseValue) {\n promiseValue = loadImport();\n }\n return promiseValue;\n },\n };\n};\n"],"mappings":";;;;;;;AAKA,MAAa,kBACX,UACA,eAC2B;CAC3B,IAAIA;AAEJ,QAAO;EACL,WAAW,WAAW;AAEpB,OAAI,CAAC,oBAAoB,UACvB;GAIF,MAAM,IAAI,oBAAoB,SAAS;AAEvC,6DAA4B,GAAG,OAAO;;EAExC,YAAY;AACV,OAAI,CAAC,aACH,gBAAe,YAAY;AAE7B,UAAO;;EAEV"}
|
package/dist/web.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getParsedICUMessages } from "@vocab/core/icu-handler";
|
|
2
|
+
import { createTranslationFile } from "@vocab/core/translation-file";
|
|
3
|
+
|
|
4
|
+
//#region src/web.ts
|
|
5
|
+
const createLanguage = (moduleId, loadImport) => {
|
|
6
|
+
let promiseValue;
|
|
7
|
+
return {
|
|
8
|
+
getValue: (locale) => {
|
|
9
|
+
if (!__webpack_modules__[moduleId]) return;
|
|
10
|
+
const m = __webpack_require__(moduleId);
|
|
11
|
+
return getParsedICUMessages(m, locale);
|
|
12
|
+
},
|
|
13
|
+
load: () => {
|
|
14
|
+
if (!promiseValue) promiseValue = loadImport();
|
|
15
|
+
return promiseValue;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { createLanguage, createTranslationFile };
|
|
22
|
+
//# sourceMappingURL=web.mjs.map
|
package/dist/web.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.mjs","names":["promiseValue: Promise<any>"],"sources":["../src/web.ts"],"sourcesContent":["import type { TranslationModule, TranslationMessagesByKey } from '@vocab/core';\nimport { getParsedICUMessages } from '@vocab/core/icu-handler';\n\nexport { createTranslationFile } from '@vocab/core/translation-file';\n\nexport const createLanguage = (\n moduleId: string,\n loadImport: () => Promise<any>,\n): TranslationModule<any> => {\n let promiseValue: Promise<any>;\n\n return {\n getValue: (locale) => {\n // @ts-expect-error Missing webpack types\n if (!__webpack_modules__[moduleId]) {\n return undefined;\n }\n\n // @ts-expect-error Missing webpack types\n const m = __webpack_require__(moduleId) as TranslationMessagesByKey;\n\n return getParsedICUMessages(m, locale);\n },\n load: () => {\n if (!promiseValue) {\n promiseValue = loadImport();\n }\n return promiseValue;\n },\n };\n};\n"],"mappings":";;;;AAKA,MAAa,kBACX,UACA,eAC2B;CAC3B,IAAIA;AAEJ,QAAO;EACL,WAAW,WAAW;AAEpB,OAAI,CAAC,oBAAoB,UACvB;GAIF,MAAM,IAAI,oBAAoB,SAAS;AAEvC,UAAO,qBAAqB,GAAG,OAAO;;EAExC,YAAY;AACV,OAAI,CAAC,aACH,gBAAe,YAAY;AAE7B,UAAO;;EAEV"}
|