@fluentic/i18n-compiler 0.0.0-stage → 0.1.0-beta.3

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/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # @fluentic/i18n-compiler
2
+
3
+ ## 0.1.0-beta.3
4
+
5
+ ### Minor Changes
6
+
7
+ - Add shared file and package filtering across compiler adapters, including include/exclude globs and regular expressions, includePackages/excludePackages with exact nested package ownership, and a native Vite transform hook prefilter. Preserve includeDependencies support and reload shared filters when watched config changes.
8
+
9
+ ### Patch Changes
10
+
11
+ - @fluentic/i18n@0.1.0-beta.3
12
+
13
+ ## 0.1.0-beta.2
14
+
15
+ ### Patch Changes
16
+
17
+ - Preserve `t.jsx()` reactive element callbacks while extracting and compiling their nested message calls normally.
18
+ - Move all source transforms and Babel, Vite, Rollup, esbuild, webpack, and Next.js integrations into the standalone compiler package.
19
+ - Share compiled hash options consistently across CLI and bundler integrations.
20
+ - Generate package declarations directly with TypeScript 7.
21
+
22
+ ## 0.1.0-beta.1
23
+
24
+ ### Minor Changes
25
+
26
+ - Publish the build-time compiler and Babel, Vite, Rollup, esbuild, webpack, and Next.js integrations.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fluentic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,24 @@
1
- # Temporary Holding Version
1
+ # @fluentic/i18n-compiler
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Node build-time compiler and integrations for Fluentic i18n.
4
+
5
+ ```ts
6
+ import fluentic from '@fluentic/i18n-compiler/vite';
7
+
8
+ export default { plugins: [fluentic({ config: './i18n.config.ts' })] };
9
+ ```
10
+
11
+ The compiler always compiles matching source. Config location is never assumed. Both settings are optional: pass `{config: './any/path/i18n.config.ts'}` to reuse its `compiled.hashLength`, `{hashLength: 6}` to set the value directly, or neither to use the compiler default. A direct value overrides the selected config.
12
+
13
+ File filtering is shared across the adapters:
14
+
15
+ - `include` and `exclude` accept a glob, a regular expression, or an array of either. IDs are matched without query strings or hash fragments; glob paths normalize Windows separators.
16
+ - By default, script files (`js`, `jsx`, `ts`, `tsx`, and their `m`/`c` variants) are included and `node_modules` is excluded. Setting `include` replaces the default include and removes the implicit dependency exclusion. An explicit `exclude` replaces the default exclusion.
17
+ - `includePackages` accepts an exact npm package name or an array of names. Matching packages' script files bypass file-level `include` and `exclude` rules.
18
+ - `excludePackages` accepts the same form and always wins, including over `includePackages` and `includeDependencies`.
19
+ - Package matching uses the innermost `node_modules` owner, supports scoped packages and pnpm paths, and does not apply a parent's rule to nested dependencies. Linked workspace source outside `node_modules` uses the file rules.
20
+ - `includeDependencies: true` remains supported to remove the implicit dependency exclusion for all packages.
21
+
22
+ For example, `fluentic({ includePackages: ['@acme/ui'], excludePackages: ['legacy-ui'] })` compiles application scripts and source from `@acme/ui`, while always skipping `legacy-ui`. These options also work with the Next.js wrapper; use string globs for Next.js options so Turbopack can serialize them.
23
+
24
+ Vite exposes a native `transform.filter` to skip irrelevant modules before invoking JavaScript, and its handler checks the authoritative shared filter. When an external `config` is selected, the native filter stays broad so config reloads cannot leave stale exclusions. Custom integrations can import `createTransformFilter` and `createTransformHookFilter` from `@fluentic/i18n-compiler`; the shared filter caches decisions and exposes `clear()`.
@@ -0,0 +1,25 @@
1
+ import * as traverseModule from '@babel/traverse';
2
+ import type { Binding, NodePath } from '@babel/traverse';
3
+ import * as b from '@babel/types';
4
+ declare const traverse: typeof traverseModule.default;
5
+ export { traverse };
6
+ export declare const importMap: Record<string, string>;
7
+ export type Scope = {
8
+ context: string | null;
9
+ notes: string[];
10
+ meta?: unknown;
11
+ };
12
+ export type ExtractedMessage = Scope & {
13
+ id: string;
14
+ source: string;
15
+ };
16
+ export declare function parseSource(code: string, filename: string): import("@babel/parser").ParseResult<b.File>;
17
+ export declare function unwrap(path: NodePath): NodePath;
18
+ export declare function literal(path: NodePath, seen?: Set<Binding>): string | null;
19
+ export declare function memberName(path: NodePath): string | null;
20
+ export declare function analyzer(imports?: string[]): {
21
+ resolve: (path: NodePath, visiting?: Set<Binding>) => Scope | null;
22
+ scopedBindings: Set<Binding>;
23
+ scopeCalls: Set<NodePath<traverseModule.Node>>;
24
+ };
25
+ export declare function collectMessages(code: string, filename: string, imports?: string[]): ExtractedMessage[];
@@ -0,0 +1,9 @@
1
+ import { type PluginOptions } from './options';
2
+ /** Owns parsing even when a host (e.g. Metro) passes an already parsed AST. */
3
+ export default function fluenticBabel(_api: unknown, options?: PluginOptions): {
4
+ name: string;
5
+ parserOverride(code: string, parserOptions: {
6
+ sourceFilename?: string;
7
+ }): import("@babel/parser").ParseResult<import("@babel/types").File> | undefined;
8
+ pre(file: any): void;
9
+ };
package/dist/babel.mjs ADDED
@@ -0,0 +1,33 @@
1
+ import { l as traverse, t as compileProgram } from "./src-BBeF3k1d.mjs";
2
+ import { i as createTransformFilter } from "./filter-Bc7CtppJ.mjs";
3
+ import { t as loadOptions } from "./options-CHPeMkCj.mjs";
4
+ // src/babel.ts
5
+ /** Owns parsing even when a host (e.g. Metro) passes an already parsed AST. */
6
+ function fluenticBabel(_api, options = {}) {
7
+ const config = loadOptions(options);
8
+ const filter = createTransformFilter(config);
9
+ const handled = /* @__PURE__ */ new WeakSet();
10
+ const enabled = (code) => code.includes("@fluentic/i18n");
11
+ const compile = (code, filename) => {
12
+ const { ast } = compileProgram(code, filename, config);
13
+ traverse.cache.clear();
14
+ handled.add(ast.program);
15
+ return ast;
16
+ };
17
+ return {
18
+ name: "fluentic-i18n",
19
+ parserOverride(code, parserOptions) {
20
+ if (!enabled(code) || !filter(parserOptions.sourceFilename ?? "source.tsx")) return void 0;
21
+ return compile(code, parserOptions.sourceFilename ?? "source.tsx");
22
+ },
23
+ pre(file) {
24
+ if (!enabled(file.code) || !filter(file.opts.filename ?? "source.tsx") || handled.has(file.path.node)) return;
25
+ const ast = compile(file.code, file.opts.filename ?? "source.tsx");
26
+ file.path.replaceWith(ast.program);
27
+ file.scope.crawl();
28
+ }
29
+ };
30
+ }
31
+ export { fluenticBabel as default };
32
+
33
+ //# sourceMappingURL=babel.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel.mjs","names":[],"sources":["../src/babel.ts"],"sourcesContent":["import { traverse } from './analyze';\nimport { createTransformFilter } from './filter';\nimport { compileProgram } from './index';\nimport { loadOptions, type PluginOptions } from './options';\n/** Owns parsing even when a host (e.g. Metro) passes an already parsed AST. */\nexport default function fluenticBabel(_api: unknown, options: PluginOptions = {}) {\n const config = loadOptions(options);\n const filter = createTransformFilter(config);\n const handled = new WeakSet<object>();\n const enabled = (code: string) => code.includes('@fluentic/i18n');\n\n const compile = (code: string, filename: string) => {\n const { ast } = compileProgram(code, filename, config);\n // Standalone paths have a default Hub. Babel must create its own paths for presets.\n traverse.cache.clear();\n handled.add(ast.program);\n\n return ast;\n };\n\n return {\n name: 'fluentic-i18n',\n parserOverride(code: string, parserOptions: { sourceFilename?: string; }) {\n if (!enabled(code) || !filter(parserOptions.sourceFilename ?? 'source.tsx')) return undefined;\n\n return compile(code, parserOptions.sourceFilename ?? 'source.tsx');\n },\n pre(file: any) {\n if (!enabled(file.code) || !filter(file.opts.filename ?? 'source.tsx') || handled.has(file.path.node)) return;\n\n const ast = compile(file.code, file.opts.filename ?? 'source.tsx');\n file.path.replaceWith(ast.program);\n file.scope.crawl();\n },\n };\n}\n"],"mappings":";;;;;AAKA,SAAwB,cAAc,MAAe,UAAyB,CAAC,GAAG;CAChF,MAAM,SAAS,YAAY,OAAO;CAClC,MAAM,SAAS,sBAAsB,MAAM;CAC3C,MAAM,0BAAU,IAAI,QAAgB;CACpC,MAAM,WAAW,SAAiB,KAAK,SAAS,gBAAgB;CAEhE,MAAM,WAAW,MAAc,aAAqB;EAClD,MAAM,EAAE,QAAQ,eAAe,MAAM,UAAU,MAAM;EAErD,SAAS,MAAM,MAAM;EACrB,QAAQ,IAAI,IAAI,OAAO;EAEvB,OAAO;CACT;CAEA,OAAO;EACL,MAAM;EACN,eAAe,MAAc,eAA6C;GACxE,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,OAAO,cAAc,kBAAkB,YAAY,GAAG,OAAO,KAAA;GAEpF,OAAO,QAAQ,MAAM,cAAc,kBAAkB,YAAY;EACnE;EACA,IAAI,MAAW;GACb,IAAI,CAAC,QAAQ,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,YAAY,YAAY,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,GAAG;GAEvG,MAAM,MAAM,QAAQ,KAAK,MAAM,KAAK,KAAK,YAAY,YAAY;GACjE,KAAK,KAAK,YAAY,IAAI,OAAO;GACjC,KAAK,MAAM,MAAM;EACnB;CACF;AACF"}
@@ -0,0 +1,5 @@
1
+ import { type PluginOptions } from './options';
2
+ export default function fluentic(options?: PluginOptions): {
3
+ name: string;
4
+ setup(build: any): void;
5
+ };
@@ -0,0 +1,35 @@
1
+ import { n as transform } from "./src-BBeF3k1d.mjs";
2
+ import { i as createTransformFilter, n as DEFAULT_TRANSFORM_INCLUDE } from "./filter-Bc7CtppJ.mjs";
3
+ import { t as loadOptions } from "./options-CHPeMkCj.mjs";
4
+ import { readFile } from "node:fs/promises";
5
+ // src/esbuild.ts
6
+ function fluentic(options = {}) {
7
+ return {
8
+ name: "fluentic-i18n",
9
+ setup(build) {
10
+ let config = loadOptions(options, build.initialOptions.absWorkingDir);
11
+ let filter = createTransformFilter(config);
12
+ build.onStart(() => {
13
+ config = loadOptions(options, build.initialOptions.absWorkingDir);
14
+ filter = createTransformFilter(config);
15
+ });
16
+ build.onLoad({ filter: options.config || options.include ? /.*/ : DEFAULT_TRANSFORM_INCLUDE }, async ({ path }) => {
17
+ if (!filter(path)) return;
18
+ const result = transform(await readFile(path, "utf8"), {
19
+ ...config,
20
+ filename: path
21
+ });
22
+ if (!result) return;
23
+ const loader = /\.tsx$/.test(path) ? "tsx" : /\.[cm]?ts$/.test(path) ? "ts" : /\.jsx$/.test(path) ? "jsx" : "js";
24
+ return {
25
+ contents: result.code + "\n//# sourceMappingURL=data:application/json;base64," + Buffer.from(JSON.stringify(result.map)).toString("base64"),
26
+ loader,
27
+ watchFiles: [path, ...config.configFile ? [config.configFile] : []]
28
+ };
29
+ });
30
+ }
31
+ };
32
+ }
33
+ export { fluentic as default };
34
+
35
+ //# sourceMappingURL=esbuild.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esbuild.mjs","names":[],"sources":["../src/esbuild.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { createTransformFilter, DEFAULT_TRANSFORM_INCLUDE } from './filter';\nimport { transform } from './index';\nimport { loadOptions, type PluginOptions } from './options';\n\nexport default function fluentic(options: PluginOptions = {}) {\n return {\n name: 'fluentic-i18n',\n setup(build: any) {\n let config = loadOptions(options, build.initialOptions.absWorkingDir);\n let filter = createTransformFilter(config);\n build.onStart(() => {\n config = loadOptions(options, build.initialOptions.absWorkingDir);\n filter = createTransformFilter(config);\n });\n build.onLoad(\n { filter: options.config || options.include ? /.*/ : DEFAULT_TRANSFORM_INCLUDE },\n async ({ path }: { path: string; }) => {\n if (!filter(path)) return;\n\n const result = transform(await readFile(path, 'utf8'), { ...config, filename: path });\n\n if (!result) return;\n\n const loader = /\\.tsx$/.test(path)\n ? 'tsx'\n : /\\.[cm]?ts$/.test(path)\n ? 'ts'\n : /\\.jsx$/.test(path)\n ? 'jsx'\n : 'js';\n\n return {\n contents: result.code + '\\n//# sourceMappingURL=data:application/json;base64,' +\n Buffer.from(JSON.stringify(result.map)).toString('base64'),\n loader,\n watchFiles: [path, ...(config.configFile ? [config.configFile] : [])],\n };\n },\n );\n },\n };\n}\n"],"mappings":";;;;;AAKA,SAAwB,SAAS,UAAyB,CAAC,GAAG;CAC5D,OAAO;EACL,MAAM;EACN,MAAM,OAAY;GAChB,IAAI,SAAS,YAAY,SAAS,MAAM,eAAe,aAAa;GACpE,IAAI,SAAS,sBAAsB,MAAM;GACzC,MAAM,cAAc;IAClB,SAAS,YAAY,SAAS,MAAM,eAAe,aAAa;IAChE,SAAS,sBAAsB,MAAM;GACvC,CAAC;GACD,MAAM,OACJ,EAAE,QAAQ,QAAQ,UAAU,QAAQ,UAAU,OAAO,0BAA0B,GAC/E,OAAO,EAAE,WAA8B;IACrC,IAAI,CAAC,OAAO,IAAI,GAAG;IAEnB,MAAM,SAAS,UAAU,MAAM,SAAS,MAAM,MAAM,GAAG;KAAE,GAAG;KAAQ,UAAU;IAAK,CAAC;IAEpF,IAAI,CAAC,QAAQ;IAEb,MAAM,SAAS,SAAS,KAAK,IAAI,IAC7B,QACA,aAAa,KAAK,IAAI,IACtB,OACA,SAAS,KAAK,IAAI,IAClB,QACA;IAEJ,OAAO;KACL,UAAU,OAAO,OAAO,yDACtB,OAAO,KAAK,KAAK,UAAU,OAAO,GAAG,CAAC,CAAC,CAAC,SAAS,QAAQ;KAC3D;KACA,YAAY,CAAC,MAAM,GAAI,OAAO,aAAa,CAAC,OAAO,UAAU,IAAI,CAAC,CAAE;IACtE;GACF,CACF;EACF;CACF;AACF"}
@@ -0,0 +1,73 @@
1
+ import picomatch from "picomatch";
2
+ // src/filter.ts
3
+ const normalizePath = (path) => path.replace(/\\/g, "/");
4
+ const DEFAULT_TRANSFORM_INCLUDE_PATTERN = "\\.[cm]?[jt]sx?$";
5
+ const DEFAULT_TRANSFORM_INCLUDE = new RegExp(DEFAULT_TRANSFORM_INCLUDE_PATTERN);
6
+ const DEFAULT_TRANSFORM_EXCLUDE = /node_modules/;
7
+ function normalizeModuleId(id) {
8
+ return id.split("?")[0]?.split("#")[0] ?? id;
9
+ }
10
+ function createTransformFilter(options = {}) {
11
+ const includes = normalizeMatchers(options.include);
12
+ const includePackages = createPackagePattern(options.includePackages);
13
+ const excludePackages = createPackagePattern(options.excludePackages);
14
+ const excludes = normalizeMatchers(options.exclude ?? (options.include || options.includeDependencies ? void 0 : DEFAULT_TRANSFORM_EXCLUDE));
15
+ const cache = /* @__PURE__ */ new Map();
16
+ const filter = ((id) => {
17
+ const filePath = normalizeModuleId(id);
18
+ const cached = cache.get(filePath);
19
+ if (cached !== void 0) return cached;
20
+ const packagePath = normalizePath(filePath);
21
+ const result = excludePackages?.test(packagePath) ? false : includePackages?.test(packagePath) ? DEFAULT_TRANSFORM_INCLUDE.test(filePath) : shouldTransform(filePath, includes, excludes);
22
+ cache.set(filePath, result);
23
+ return result;
24
+ });
25
+ filter.clear = () => {
26
+ cache.clear();
27
+ };
28
+ return filter;
29
+ }
30
+ function normalizeMatchers(patterns) {
31
+ if (!patterns) return [];
32
+ return (Array.isArray(patterns) ? patterns : [patterns]).map(createMatcher);
33
+ }
34
+ function createMatcher(pattern) {
35
+ if (pattern instanceof RegExp) return (id) => {
36
+ pattern.lastIndex = 0;
37
+ return pattern.test(id);
38
+ };
39
+ const matcher = picomatch(normalizePath(pattern), { dot: true });
40
+ return (id) => matcher(normalizePath(id));
41
+ }
42
+ function shouldTransform(id, includes, excludes) {
43
+ for (const exclude of excludes) if (exclude(id)) return false;
44
+ if (!includes.length) return DEFAULT_TRANSFORM_INCLUDE.test(id);
45
+ for (const include of includes) if (include(id)) return true;
46
+ return false;
47
+ }
48
+ /** A conservative native prefilter; the shared JS filter remains authoritative. */
49
+ function createTransformHookFilter(options = {}) {
50
+ const includePackages = createPackagePattern(options.includePackages);
51
+ const excludePackages = createPackagePattern(options.excludePackages);
52
+ const exclude = [];
53
+ if (excludePackages) exclude.push(excludePackages);
54
+ if (!options.include && !options.includeDependencies && options.exclude === void 0) exclude.push(new RegExp(`^${includePackages ? `(?!${includePackages.source})` : ""}[^?#]*node_modules`));
55
+ return { id: {
56
+ include: options.include ? void 0 : /^[^?#]*\.[cm]?[jt]sx?(?:[?#][\s\S]*)?$/,
57
+ exclude
58
+ } };
59
+ }
60
+ function createPackagePattern(packages) {
61
+ const names = typeof packages === "string" ? [packages] : packages ?? [];
62
+ if (!names.length) return void 0;
63
+ for (const name of names) if (!/^(?:@[a-zA-Z0-9_][a-zA-Z0-9._-]*\/)?[a-zA-Z0-9_][a-zA-Z0-9._-]*$/.test(name)) throw new Error(`[i18n] Invalid package name in includePackages/excludePackages: ${JSON.stringify(name)}`);
64
+ const separator = "[/\\\\]";
65
+ const alternatives = names.map((name) => name.split("/").map(escapeRegExp).join(separator)).join("|");
66
+ return new RegExp(`^(?:[^?#]*${separator})?node_modules${separator}(?:${alternatives})(?![^?#]*${separator}node_modules${separator})(?:${separator}[^?#]*)?(?:[?#][\\s\\S]*)?$`);
67
+ }
68
+ function escapeRegExp(value) {
69
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
70
+ }
71
+ export { createTransformHookFilter as a, createTransformFilter as i, DEFAULT_TRANSFORM_INCLUDE as n, normalizeModuleId as o, DEFAULT_TRANSFORM_INCLUDE_PATTERN as r, DEFAULT_TRANSFORM_EXCLUDE as t };
72
+
73
+ //# sourceMappingURL=filter-Bc7CtppJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-Bc7CtppJ.mjs","names":[],"sources":["../src/filter.ts"],"sourcesContent":["import picomatch from 'picomatch';\nconst normalizePath = (path: string) => path.replace(/\\\\/g, '/');\n\nexport const DEFAULT_TRANSFORM_INCLUDE_PATTERN = '\\\\.[cm]?[jt]sx?$';\n\nexport const DEFAULT_TRANSFORM_INCLUDE = new RegExp(DEFAULT_TRANSFORM_INCLUDE_PATTERN);\n\nexport const DEFAULT_TRANSFORM_EXCLUDE = /node_modules/;\n\nexport type FilterPattern = string | RegExp | Array<string | RegExp>;\n\nexport type TransformFilterOptions = {\n /** File globs or regular expressions matched against IDs without query/hash suffixes. */\n include?: FilterPattern;\n exclude?: FilterPattern;\n /** Backwards-compatible opt-in to all dependencies; explicit exclude still wins. */\n includeDependencies?: boolean;\n /** Exact npm package names whose script files override file include/exclude rules. */\n includePackages?: string | string[];\n /** Exact npm package names excluded before all other filter rules. */\n excludePackages?: string | string[];\n};\n\nexport type TransformFilter = {\n (id: string): boolean;\n clear(): void;\n};\n\nexport function normalizeModuleId(id: string) {\n return id.split('?')[0]?.split('#')[0] ?? id;\n}\n\nexport function createTransformFilter(options: TransformFilterOptions = {}): TransformFilter {\n const includes = normalizeMatchers(options.include);\n const includePackages = createPackagePattern(options.includePackages);\n const excludePackages = createPackagePattern(options.excludePackages);\n\n const excludes = normalizeMatchers(\n options.exclude ?? (options.include || options.includeDependencies ? undefined : DEFAULT_TRANSFORM_EXCLUDE),\n );\n\n const cache = new Map<string, boolean>();\n\n const filter = ((id: string) => {\n const filePath = normalizeModuleId(id);\n const cached = cache.get(filePath);\n\n if (cached !== undefined) return cached;\n\n const packagePath = normalizePath(filePath);\n const result = excludePackages?.test(packagePath)\n ? false\n : includePackages?.test(packagePath)\n ? DEFAULT_TRANSFORM_INCLUDE.test(filePath)\n : shouldTransform(filePath, includes, excludes);\n\n cache.set(filePath, result);\n\n return result;\n }) as TransformFilter;\n\n filter.clear = () => {\n cache.clear();\n };\n\n return filter;\n}\n\ntype FilterMatcher = (id: string) => boolean;\n\nfunction normalizeMatchers(patterns?: FilterPattern) {\n if (!patterns) return [];\n\n const items = Array.isArray(patterns) ? patterns : [patterns];\n\n return items.map(createMatcher);\n}\n\nfunction createMatcher(pattern: string | RegExp): FilterMatcher {\n if (pattern instanceof RegExp) {\n return (id) => {\n pattern.lastIndex = 0;\n return pattern.test(id);\n };\n }\n\n const matcher = picomatch(normalizePath(pattern), {\n dot: true,\n });\n\n return (id) => matcher(normalizePath(id));\n}\n\nfunction shouldTransform(\n id: string,\n includes: FilterMatcher[],\n excludes: FilterMatcher[],\n): boolean {\n for (const exclude of excludes) {\n if (exclude(id)) return false;\n }\n\n if (!includes.length) {\n return DEFAULT_TRANSFORM_INCLUDE.test(id);\n }\n\n for (const include of includes) {\n if (include(id)) return true;\n }\n\n return false;\n}\n\n/** A conservative native prefilter; the shared JS filter remains authoritative. */\nexport function createTransformHookFilter(options: TransformFilterOptions = {}) {\n const includePackages = createPackagePattern(options.includePackages);\n const excludePackages = createPackagePattern(options.excludePackages);\n const exclude: RegExp[] = [];\n if (excludePackages) exclude.push(excludePackages);\n\n if (!options.include && !options.includeDependencies && options.exclude === undefined) {\n // Package inclusions override the default node_modules exclusion.\n exclude.push(\n new RegExp(\n `^${includePackages ? `(?!${includePackages.source})` : ''}[^?#]*node_modules`,\n ),\n );\n }\n\n return {\n id: {\n // Custom globs/regexes run against normalized IDs in the shared filter.\n // Keeping the native check broad avoids changing their matching semantics.\n include: options.include ? undefined : /^[^?#]*\\.[cm]?[jt]sx?(?:[?#][\\s\\S]*)?$/,\n exclude,\n },\n };\n}\n\nfunction createPackagePattern(packages?: string | string[]): RegExp | undefined {\n const names = typeof packages === 'string' ? [packages] : packages ?? [];\n if (!names.length) return undefined;\n\n for (const name of names) {\n if (!/^(?:@[a-zA-Z0-9_][a-zA-Z0-9._-]*\\/)?[a-zA-Z0-9_][a-zA-Z0-9._-]*$/.test(name)) {\n throw new Error(\n `[i18n] Invalid package name in includePackages/excludePackages: ${JSON.stringify(name)}`,\n );\n }\n }\n\n const separator = '[/\\\\\\\\]';\n const alternatives = names.map((name) => name.split('/').map(escapeRegExp).join(separator)).join('|');\n // Match the innermost node_modules owner, including pnpm's nested layout.\n // A package's nested dependencies must not inherit its include/exclude rule.\n return new RegExp(\n `^(?:[^?#]*${separator})?node_modules${separator}(?:${alternatives})` +\n `(?![^?#]*${separator}node_modules${separator})` +\n `(?:${separator}[^?#]*)?(?:[?#][\\\\s\\\\S]*)?$`,\n );\n}\n\nfunction escapeRegExp(value: string) {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n"],"mappings":"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"}
@@ -0,0 +1,28 @@
1
+ export declare const DEFAULT_TRANSFORM_INCLUDE_PATTERN = "\\.[cm]?[jt]sx?$";
2
+ export declare const DEFAULT_TRANSFORM_INCLUDE: RegExp;
3
+ export declare const DEFAULT_TRANSFORM_EXCLUDE: RegExp;
4
+ export type FilterPattern = string | RegExp | Array<string | RegExp>;
5
+ export type TransformFilterOptions = {
6
+ /** File globs or regular expressions matched against IDs without query/hash suffixes. */
7
+ include?: FilterPattern;
8
+ exclude?: FilterPattern;
9
+ /** Backwards-compatible opt-in to all dependencies; explicit exclude still wins. */
10
+ includeDependencies?: boolean;
11
+ /** Exact npm package names whose script files override file include/exclude rules. */
12
+ includePackages?: string | string[];
13
+ /** Exact npm package names excluded before all other filter rules. */
14
+ excludePackages?: string | string[];
15
+ };
16
+ export type TransformFilter = {
17
+ (id: string): boolean;
18
+ clear(): void;
19
+ };
20
+ export declare function normalizeModuleId(id: string): string;
21
+ export declare function createTransformFilter(options?: TransformFilterOptions): TransformFilter;
22
+ /** A conservative native prefilter; the shared JS filter remains authoritative. */
23
+ export declare function createTransformHookFilter(options?: TransformFilterOptions): {
24
+ id: {
25
+ include: RegExp | undefined;
26
+ exclude: RegExp[];
27
+ };
28
+ };
@@ -0,0 +1,31 @@
1
+ import * as b from '@babel/types';
2
+ import { type ExtractedMessage } from './analyze';
3
+ export { collectMessages } from './analyze';
4
+ export * from './filter';
5
+ export * from './message';
6
+ export type { PluginOptions } from './options';
7
+ export type CompiledOptions = {
8
+ hashLength?: number;
9
+ };
10
+ export type CompilerOptions = CompiledOptions & {
11
+ filename?: string;
12
+ bindReactText?: boolean;
13
+ };
14
+ export declare function compileProgram(code: string, filename: string, options?: CompilerOptions): {
15
+ ast: import("@babel/parser").ParseResult<b.File>;
16
+ messages: ExtractedMessage[];
17
+ changed: boolean;
18
+ };
19
+ export declare function transform(code: string, options?: CompilerOptions): {
20
+ code: string;
21
+ map: {
22
+ version: number;
23
+ sources: string[];
24
+ names: string[];
25
+ sourceRoot?: string | undefined;
26
+ sourcesContent?: string[] | undefined;
27
+ mappings: string;
28
+ file: string;
29
+ } | null;
30
+ messages: ExtractedMessage[];
31
+ } | null;
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { a as compileMessage, c as collectMessages, i as compileCatalog, n as transform, o as messageId, r as COMPACT_VERSION, s as messageIdentity, t as compileProgram } from "./src-BBeF3k1d.mjs";
2
+ import { a as createTransformHookFilter, i as createTransformFilter, n as DEFAULT_TRANSFORM_INCLUDE, o as normalizeModuleId, r as DEFAULT_TRANSFORM_INCLUDE_PATTERN, t as DEFAULT_TRANSFORM_EXCLUDE } from "./filter-Bc7CtppJ.mjs";
3
+ export { COMPACT_VERSION, DEFAULT_TRANSFORM_EXCLUDE, DEFAULT_TRANSFORM_INCLUDE, DEFAULT_TRANSFORM_INCLUDE_PATTERN, collectMessages, compileCatalog, compileMessage, compileProgram, createTransformFilter, createTransformHookFilter, messageId, messageIdentity, normalizeModuleId, transform };
@@ -0,0 +1,12 @@
1
+ import { type CompactMessage } from '@fluentic/i18n/compiler-support';
2
+ export { COMPACT_VERSION } from '@fluentic/i18n/compiler-support';
3
+ export declare function messageIdentity(context: string | null, source: string): string;
4
+ export declare function messageId(context: string | null, source: string, hashLength?: number): string;
5
+ export declare function compileMessage(source: string): CompactMessage;
6
+ export declare function compileCatalog(records: Array<{
7
+ source: string;
8
+ context: string | null;
9
+ translation: string;
10
+ }>, options?: {
11
+ hashLength?: number;
12
+ }): Array<[string, CompactMessage]>;
@@ -0,0 +1,6 @@
1
+ import type { PluginOptions } from './options';
2
+ export type NextPluginOptions = PluginOptions & {
3
+ requestConfig: string;
4
+ };
5
+ /** One Next integration; preserves the application's existing webpack hook/rules. */
6
+ export default function withFluentic(options: NextPluginOptions): (nextConfig?: any) => any;
@@ -0,0 +1,58 @@
1
+ import FluenticI18nPlugin from "./webpack.mjs";
2
+ import { createRequire } from "node:module";
3
+ import { relative, resolve } from "node:path";
4
+ // src/nextjs.ts
5
+ const require = createRequire(import.meta.url);
6
+ /** One Next integration; preserves the application's existing webpack hook/rules. */
7
+ function withFluentic(options) {
8
+ const request = resolve(options.requestConfig);
9
+ const loader = require.resolve("@fluentic/i18n-compiler/webpack-loader");
10
+ const { requestConfig: _requestConfig, ...pluginOptions } = options;
11
+ const compilerOptions = {
12
+ ...pluginOptions,
13
+ bindReactText: true,
14
+ ...options.config ? { config: resolve(options.config) } : {},
15
+ ...options.hashLength !== void 0 ? { hashLength: options.hashLength } : {}
16
+ };
17
+ return (nextConfig = {}) => ({
18
+ ...nextConfig,
19
+ turbopack: {
20
+ ...nextConfig.turbopack,
21
+ resolveAlias: {
22
+ ...nextConfig.turbopack?.resolveAlias,
23
+ "@fluentic/i18n-nextjs/request": "./" + relative(process.cwd(), request).replace(/\\/g, "/")
24
+ },
25
+ rules: {
26
+ ...nextConfig.turbopack?.rules,
27
+ ...Object.fromEntries([
28
+ "*.js",
29
+ "*.jsx",
30
+ "*.ts",
31
+ "*.tsx",
32
+ "*.mjs",
33
+ "*.mts",
34
+ "*.cjs",
35
+ "*.cts",
36
+ "*.mjsx",
37
+ "*.mtsx",
38
+ "*.cjsx",
39
+ "*.ctsx"
40
+ ].map((pattern) => [pattern, [...nextConfig.turbopack?.rules?.[pattern] ? [nextConfig.turbopack.rules[pattern]].flat() : [], { loaders: [{
41
+ loader,
42
+ options: compilerOptions
43
+ }] }]]))
44
+ }
45
+ },
46
+ webpack(config, context) {
47
+ config.resolve ??= {};
48
+ config.resolve.alias ??= {};
49
+ config.resolve.alias["@fluentic/i18n-nextjs/request$"] = request;
50
+ config.plugins ??= [];
51
+ config.plugins.push(new FluenticI18nPlugin(compilerOptions));
52
+ return nextConfig.webpack ? nextConfig.webpack(config, context) : config;
53
+ }
54
+ });
55
+ }
56
+ export { withFluentic as default };
57
+
58
+ //# sourceMappingURL=nextjs.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextjs.mjs","names":["FluenticPlugin"],"sources":["../src/nextjs.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { relative, resolve } from 'node:path';\nimport type { PluginOptions } from './options';\nimport FluenticPlugin from './webpack';\nconst require = createRequire(import.meta.url);\nexport type NextPluginOptions = PluginOptions & {\n requestConfig: string;\n};\n/** One Next integration; preserves the application's existing webpack hook/rules. */\nexport default function withFluentic(options: NextPluginOptions) {\n const request = resolve(options.requestConfig);\n const loader = require.resolve('@fluentic/i18n-compiler/webpack-loader');\n const { requestConfig: _requestConfig, ...pluginOptions } = options;\n const compilerOptions = {\n ...pluginOptions,\n bindReactText: true,\n ...(options.config ? { config: resolve(options.config) } : {}),\n ...(options.hashLength !== undefined ? { hashLength: options.hashLength } : {}),\n };\n return (nextConfig: any = {}) => ({\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n resolveAlias: {\n ...nextConfig.turbopack?.resolveAlias,\n '@fluentic/i18n-nextjs/request': './' + relative(process.cwd(), request).replace(/\\\\/g, '/'),\n },\n rules: {\n ...nextConfig.turbopack?.rules,\n ...Object.fromEntries(\n ['*.js', '*.jsx', '*.ts', '*.tsx', '*.mjs', '*.mts', '*.cjs', '*.cts', '*.mjsx', '*.mtsx', '*.cjsx', '*.ctsx']\n .map((pattern) => [pattern, [\n ...(nextConfig.turbopack?.rules?.[pattern] ? [nextConfig.turbopack.rules[pattern]].flat() : []),\n { loaders: [{ loader, options: compilerOptions }] },\n ]]),\n ),\n },\n },\n webpack(config: any, context: any) {\n config.resolve ??= {};\n config.resolve.alias ??= {};\n config.resolve.alias['@fluentic/i18n-nextjs/request$'] = request;\n config.plugins ??= [];\n config.plugins.push(new FluenticPlugin(compilerOptions));\n return nextConfig.webpack ? nextConfig.webpack(config, context) : config;\n },\n });\n}\n"],"mappings":";;;;AAIA,MAAM,UAAU,cAAc,YAAY,GAAG;;AAK7C,SAAwB,aAAa,SAA4B;CAC/D,MAAM,UAAU,QAAQ,QAAQ,aAAa;CAC7C,MAAM,SAAS,QAAQ,QAAQ,wCAAwC;CACvE,MAAM,EAAE,eAAe,gBAAgB,GAAG,kBAAkB;CAC5D,MAAM,kBAAkB;EACtB,GAAG;EACH,eAAe;EACf,GAAI,QAAQ,SAAS,EAAE,QAAQ,QAAQ,QAAQ,MAAM,EAAE,IAAI,CAAC;EAC5D,GAAI,QAAQ,eAAe,KAAA,IAAY,EAAE,YAAY,QAAQ,WAAW,IAAI,CAAC;CAC/E;CACA,QAAQ,aAAkB,CAAC,OAAO;EAChC,GAAG;EACH,WAAW;GACT,GAAG,WAAW;GACd,cAAc;IACZ,GAAG,WAAW,WAAW;IACzB,iCAAiC,OAAO,SAAS,QAAQ,IAAI,GAAG,OAAO,CAAC,CAAC,QAAQ,OAAO,GAAG;GAC7F;GACA,OAAO;IACL,GAAG,WAAW,WAAW;IACzB,GAAG,OAAO,YACR;KAAC;KAAQ;KAAS;KAAQ;KAAS;KAAS;KAAS;KAAS;KAAS;KAAU;KAAU;KAAU;IAAQ,CAAC,CAC3G,KAAK,YAAY,CAAC,SAAS,CAC1B,GAAI,WAAW,WAAW,QAAQ,WAAW,CAAC,WAAW,UAAU,MAAM,QAAQ,CAAC,CAAC,KAAK,IAAI,CAAC,GAC7F,EAAE,SAAS,CAAC;KAAE;KAAQ,SAAS;IAAgB,CAAC,EAAE,CACpD,CAAC,CAAC,CACN;GACF;EACF;EACA,QAAQ,QAAa,SAAc;GACjC,OAAO,YAAY,CAAC;GACpB,OAAO,QAAQ,UAAU,CAAC;GAC1B,OAAO,QAAQ,MAAM,oCAAoC;GACzD,OAAO,YAAY,CAAC;GACpB,OAAO,QAAQ,KAAK,IAAIA,mBAAe,eAAe,CAAC;GACvD,OAAO,WAAW,UAAU,WAAW,QAAQ,QAAQ,OAAO,IAAI;EACpE;CACF;AACF"}
@@ -0,0 +1,19 @@
1
+ import { createJiti } from "jiti";
2
+ import { resolve } from "node:path";
3
+ // src/options.ts
4
+ function loadOptions(options = {}, root = process.cwd()) {
5
+ if ("compiled" in options) throw new TypeError("[i18n] compiler plugins always compile; use hashLength instead of compiled");
6
+ const file = options.config ? resolve(root, options.config) : void 0;
7
+ const config = file ? createJiti(import.meta.url, { moduleCache: false })(file) : {};
8
+ const { compiled, ...configOptions } = config.default ?? config;
9
+ const sharedHashLength = typeof compiled === "object" ? compiled.hashLength : void 0;
10
+ return {
11
+ ...configOptions,
12
+ ...sharedHashLength === void 0 ? {} : { hashLength: sharedHashLength },
13
+ ...options,
14
+ configFile: file
15
+ };
16
+ }
17
+ export { loadOptions as t };
18
+
19
+ //# sourceMappingURL=options-CHPeMkCj.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options-CHPeMkCj.mjs","names":[],"sources":["../src/options.ts"],"sourcesContent":["import { createJiti } from 'jiti';\nimport { resolve } from 'node:path';\n\nimport type { TransformFilterOptions } from './filter';\nimport type { CompiledOptions } from './index';\n\nexport type { FilterPattern, TransformFilterOptions } from './filter';\n\nexport type PluginOptions = TransformFilterOptions & {\n /** Direct override; otherwise reuse compiled.hashLength from an explicitly selected config or the default. */\n hashLength?: number;\n /** Optional i18n config path, resolved from the plugin's working directory. */\n config?: string;\n /** Next.js client modules: bind synchronous text calls to the hydration boundary. */\n bindReactText?: boolean;\n};\n\nexport function loadOptions(\n options: PluginOptions = {},\n root = process.cwd(),\n): PluginOptions & { configFile?: string; } {\n if ('compiled' in options) {\n throw new TypeError('[i18n] compiler plugins always compile; use hashLength instead of compiled');\n }\n const file = options.config ? resolve(root, options.config) : undefined;\n\n const config = file\n ? createJiti(import.meta.url, { moduleCache: false })(file) as\n & { default?: PluginOptions & { compiled?: true | CompiledOptions; }; }\n & PluginOptions\n & { compiled?: true | CompiledOptions; }\n : {};\n const loaded = (config.default ?? config) as PluginOptions & { compiled?: true | CompiledOptions; };\n const { compiled, ...configOptions } = loaded;\n const sharedHashLength = typeof compiled === 'object' ? compiled.hashLength : undefined;\n\n return {\n ...configOptions,\n ...(sharedHashLength === undefined ? {} : { hashLength: sharedHashLength }),\n ...options,\n configFile: file,\n };\n}\n"],"mappings":";;;AAiBA,SAAgB,YACd,UAAyB,CAAC,GAC1B,OAAO,QAAQ,IAAI,GACuB;CAC1C,IAAI,cAAc,SAChB,MAAM,IAAI,UAAU,4EAA4E;CAElG,MAAM,OAAO,QAAQ,SAAS,QAAQ,MAAM,QAAQ,MAAM,IAAI,KAAA;CAE9D,MAAM,SAAS,OACX,WAAW,YAAY,KAAK,EAAE,aAAa,MAAM,CAAC,CAAC,CAAC,IAAI,IAIxD,CAAC;CAEL,MAAM,EAAE,UAAU,GAAG,kBADL,OAAO,WAAW;CAElC,MAAM,mBAAmB,OAAO,aAAa,WAAW,SAAS,aAAa,KAAA;CAE9E,OAAO;EACL,GAAG;EACH,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,iBAAiB;EACzE,GAAG;EACH,YAAY;CACd;AACF"}
@@ -0,0 +1,13 @@
1
+ import type { TransformFilterOptions } from './filter';
2
+ export type { FilterPattern, TransformFilterOptions } from './filter';
3
+ export type PluginOptions = TransformFilterOptions & {
4
+ /** Direct override; otherwise reuse compiled.hashLength from an explicitly selected config or the default. */
5
+ hashLength?: number;
6
+ /** Optional i18n config path, resolved from the plugin's working directory. */
7
+ config?: string;
8
+ /** Next.js client modules: bind synchronous text calls to the hydration boundary. */
9
+ bindReactText?: boolean;
10
+ };
11
+ export declare function loadOptions(options?: PluginOptions, root?: string): PluginOptions & {
12
+ configFile?: string;
13
+ };
@@ -0,0 +1,21 @@
1
+ import { type PluginOptions } from './options';
2
+ export default function fluentic(options?: PluginOptions): {
3
+ name: string;
4
+ buildStart(this: {
5
+ addWatchFile(file: string): void;
6
+ }): void;
7
+ watchChange(id: string): void;
8
+ transform(code: string, id: string): {
9
+ code: string;
10
+ map: {
11
+ version: number;
12
+ sources: string[];
13
+ names: string[];
14
+ sourceRoot?: string | undefined;
15
+ sourcesContent?: string[] | undefined;
16
+ mappings: string;
17
+ file: string;
18
+ } | null;
19
+ messages: import("./analyze").ExtractedMessage[];
20
+ } | null;
21
+ };
@@ -0,0 +1,30 @@
1
+ import { n as transform } from "./src-BBeF3k1d.mjs";
2
+ import { i as createTransformFilter, o as normalizeModuleId } from "./filter-Bc7CtppJ.mjs";
3
+ import { t as loadOptions } from "./options-CHPeMkCj.mjs";
4
+ // src/rollup.ts
5
+ function fluentic(options = {}) {
6
+ let config = loadOptions(options);
7
+ let filter = createTransformFilter(config);
8
+ return {
9
+ name: "fluentic-i18n",
10
+ buildStart() {
11
+ if (config.configFile) this.addWatchFile(config.configFile);
12
+ },
13
+ watchChange(id) {
14
+ if (id === config.configFile) {
15
+ config = loadOptions(options);
16
+ filter = createTransformFilter(config);
17
+ }
18
+ },
19
+ transform(code, id) {
20
+ if (!filter(id)) return null;
21
+ return transform(code, {
22
+ ...config,
23
+ filename: normalizeModuleId(id)
24
+ });
25
+ }
26
+ };
27
+ }
28
+ export { fluentic as default };
29
+
30
+ //# sourceMappingURL=rollup.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup.mjs","names":[],"sources":["../src/rollup.ts"],"sourcesContent":["import { createTransformFilter, normalizeModuleId } from './filter';\nimport { transform } from './index';\nimport { loadOptions, type PluginOptions } from './options';\n\nexport default function fluentic(options: PluginOptions = {}) {\n let config = loadOptions(options);\n let filter = createTransformFilter(config);\n\n return {\n name: 'fluentic-i18n',\n buildStart(this: { addWatchFile(file: string): void; }) {\n if (config.configFile) this.addWatchFile(config.configFile);\n },\n watchChange(id: string) {\n if (id === config.configFile) {\n config = loadOptions(options);\n filter = createTransformFilter(config);\n }\n },\n transform(code: string, id: string) {\n if (!filter(id)) return null;\n\n return transform(code, { ...config, filename: normalizeModuleId(id) });\n },\n };\n}\n"],"mappings":";;;;AAIA,SAAwB,SAAS,UAAyB,CAAC,GAAG;CAC5D,IAAI,SAAS,YAAY,OAAO;CAChC,IAAI,SAAS,sBAAsB,MAAM;CAEzC,OAAO;EACL,MAAM;EACN,aAAwD;GACtD,IAAI,OAAO,YAAY,KAAK,aAAa,OAAO,UAAU;EAC5D;EACA,YAAY,IAAY;GACtB,IAAI,OAAO,OAAO,YAAY;IAC5B,SAAS,YAAY,OAAO;IAC5B,SAAS,sBAAsB,MAAM;GACvC;EACF;EACA,UAAU,MAAc,IAAY;GAClC,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO;GAExB,OAAO,UAAU,MAAM;IAAE,GAAG;IAAQ,UAAU,kBAAkB,EAAE;GAAE,CAAC;EACvE;CACF;AACF"}