@generaltranslation/compiler 1.3.31 → 1.3.33

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/config.d.ts CHANGED
@@ -1,34 +1,10 @@
1
1
  /**
2
2
  * Configuration types for the GT Babel plugin
3
3
  */
4
+ import type { GTConfig as SharedGTConfig } from 'generaltranslation/types';
4
5
  export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
5
- /**
6
- * The only relevant parts of the GT config that we are concerned with
7
- */
8
- export type GTConfig = {
9
- defaultLocale?: string;
10
- locales?: string[];
11
- projectId?: string;
12
- _versionId?: string;
13
- files?: {
14
- gt?: {
15
- output?: string;
16
- parsingFlags?: {
17
- enableAutoJsxInjection?: boolean;
18
- autoderive?: boolean | {
19
- jsx?: boolean;
20
- strings?: boolean;
21
- };
22
- legacyGtReactImportSource?: boolean;
23
- /** Dev hot reload: inject runtime translate calls and enable Suspense-based <T> */
24
- devHotReload?: boolean | {
25
- strings?: boolean;
26
- jsx?: boolean;
27
- };
28
- };
29
- };
30
- };
31
- };
6
+ /** A complete or partial gt.config.json accepted by compiler integrations. */
7
+ export type GTConfig = Partial<SharedGTConfig>;
32
8
  /**
33
9
  * Plugin configuration options (from babel config)
34
10
  */
@@ -47,6 +23,8 @@ export interface PluginConfig {
47
23
  stringTranslationMacro?: string;
48
24
  /** Enable Auto Jsx Injection (e.g. <div>Hello</div> -> <div><T>Hello</T></div>) */
49
25
  enableAutoJsxInjection?: boolean;
26
+ /** Package source for components inserted by Auto JSX Injection */
27
+ autoJsxImportSource?: string;
50
28
  /** Automatically treat interpolated/concatenated values as derive() calls */
51
29
  autoderive?: boolean | {
52
30
  jsx?: boolean;
@@ -78,6 +56,8 @@ export interface PluginSettings {
78
56
  enableMacroImportInjection: boolean;
79
57
  /** Enable Auto Jsx Injection (e.g. <div>Hello</div> -> <div><T>Hello</T></div>) */
80
58
  enableAutoJsxInjection: boolean;
59
+ /** Package source for components inserted by Auto JSX Injection */
60
+ autoJsxImportSource?: string;
81
61
  /** Automatically treat interpolated/concatenated values as derive() calls */
82
62
  autoderive: {
83
63
  jsx: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE;QACN,EAAE,CAAC,EAAE;YACH,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,YAAY,CAAC,EAAE;gBACb,sBAAsB,CAAC,EAAE,OAAO,CAAC;gBACjC,UAAU,CAAC,EAAE,OAAO,GAAG;oBAAE,GAAG,CAAC,EAAE,OAAO,CAAC;oBAAC,OAAO,CAAC,EAAE,OAAO,CAAA;iBAAE,CAAC;gBAC5D,yBAAyB,CAAC,EAAE,OAAO,CAAC;gBACpC,mFAAmF;gBACnF,YAAY,CAAC,EAAE,OAAO,GAAG;oBAAE,OAAO,CAAC,EAAE,OAAO,CAAC;oBAAC,GAAG,CAAC,EAAE,OAAO,CAAA;iBAAE,CAAC;aAC/D,CAAC;SACH,CAAC;KACH,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,0DAA0D;IAC1D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gDAAgD;IAChD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IA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AAE,CAAC;CAClD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,GAAG;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GAChE;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAKpC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GAChE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE,CAKpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Configuration types for the GT Babel plugin\n */\n\nexport type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';\n\n/**\n * The only relevant parts of the GT config that we are concerned with\n */\nexport type GTConfig = {\n defaultLocale?: string;\n locales?: string[];\n projectId?: string;\n _versionId?: string;\n files?: {\n gt?: {\n output?: string;\n parsingFlags?: {\n enableAutoJsxInjection?: boolean;\n autoderive?: boolean | { jsx?: boolean; strings?: boolean };\n legacyGtReactImportSource?: boolean;\n /** Dev hot reload: inject runtime translate calls and enable Suspense-based <T> */\n devHotReload?: boolean | { strings?: boolean; jsx?: boolean };\n };\n };\n };\n};\n\n/**\n * Plugin configuration options (from babel config)\n */\nexport interface PluginConfig {\n /** Log level for the plugin */\n logLevel?: LogLevel;\n /** GT Configuration object — pass the parsed gt.config.json to sync settings */\n gtConfig?: GTConfig;\n /** Enable compile-time hash generation (default: true) */\n compileTimeHash?: boolean;\n /** Disable dynamic content validation checks */\n disableBuildChecks?: boolean;\n /** Enable macro transform (t`...`, t(`...`), t(\"a\" + b)) */\n enableMacroTransform?: boolean;\n /** Name of the string translation macro function */\n stringTranslationMacro?: string;\n /** Enable Auto Jsx Injection (e.g. <div>Hello</div> -> <div><T>Hello</T></div>) */\n enableAutoJsxInjection?: boolean;\n /** Automatically treat interpolated/concatenated values as derive() calls */\n autoderive?: boolean | { jsx?: boolean; strings?: boolean };\n /** Emit compiler-injected gt-react imports from gt-react/browser */\n legacyGtReactImportSource?: boolean;\n /** Debug: write a hash → jsxChildren manifest file on build */\n _debugHashManifest?: boolean;\n /** Dev hot reload: inject runtime translate calls and enable Suspense-based <T> */\n devHotReload?: boolean | { strings?: boolean; jsx?: boolean };\n}\n\n/**\n * Internal plugin settings (processed config)\n */\nexport interface PluginSettings {\n logLevel: LogLevel;\n compileTimeHash: boolean;\n disableBuildChecks: boolean;\n filename?: string;\n enableMacroTransform: boolean;\n stringTranslationMacro: string;\n enableTaggedTemplate: boolean;\n enableTemplateLiteralArg: boolean;\n enableConcatenationArg: boolean;\n enableMacroImportInjection: boolean;\n /** Enable Auto Jsx Injection (e.g. <div>Hello</div> -> <div><T>Hello</T></div>) */\n enableAutoJsxInjection: boolean;\n /** Automatically treat interpolated/concatenated values as derive() calls */\n autoderive: { jsx: boolean; strings: boolean };\n /** Emit compiler-injected gt-react imports from gt-react/browser */\n legacyGtReactImportSource: boolean;\n /** Debug: write a hash → jsxChildren manifest file on build */\n _debugHashManifest: boolean;\n /** Dev hot reload: inject runtime translate calls and enable Suspense-based <T> */\n devHotReload: { strings: boolean; jsx: boolean };\n}\n\n/**\n * Resolves the autoderive config value into separate jsx and strings flags.\n * - `true` enables both (backward compatible)\n * - `false` disables both (backward compatible)\n * - `{ jsx?: boolean; strings?: boolean }` enables selectively (missing keys default to false)\n */\nexport function resolveAutoderive(\n value: boolean | { jsx?: boolean; strings?: boolean } | undefined\n): { jsx: boolean; strings: boolean } {\n if (value === undefined || typeof value === 'boolean') {\n return { jsx: !!value, strings: !!value };\n }\n return { jsx: value.jsx ?? false, strings: value.strings ?? false };\n}\n\n/**\n * Resolves the devHotReload config value into separate strings and jsx flags.\n * - `true` enables strings only (JSX is handled at runtime via Suspense, no compiler injection needed)\n * - `false` disables both\n * - `{ strings?: boolean; jsx?: boolean }` enables selectively (missing keys default to false)\n */\nexport function resolveDevHotReload(\n value: boolean | { strings?: boolean; jsx?: boolean } | undefined\n): { strings: boolean; jsx: boolean } {\n if (value === undefined || typeof value === 'boolean') {\n return { strings: !!value, jsx: false };\n }\n return { strings: value.strings ?? false, jsx: value.jsx ?? false };\n}\n"],"mappings":";;;;;;;;AAwFA,SAAgB,kBACd,OACoC;AACpC,KAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAC1C,QAAO;EAAE,KAAK,CAAC,CAAC;EAAO,SAAS,CAAC,CAAC;EAAO;AAE3C,QAAO;EAAE,KAAK,MAAM,OAAO;EAAO,SAAS,MAAM,WAAW;EAAO;;;;;;;;AASrE,SAAgB,oBACd,OACoC;AACpC,KAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAC1C,QAAO;EAAE,SAAS,CAAC,CAAC;EAAO,KAAK;EAAO;AAEzC,QAAO;EAAE,SAAS,MAAM,WAAW;EAAO,KAAK,MAAM,OAAO;EAAO"}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Configuration types for the GT Babel plugin\n */\n\nimport type { GTConfig as SharedGTConfig } from 'generaltranslation/types';\n\nexport type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';\n\n/** A complete or partial gt.config.json accepted by compiler integrations. */\nexport type GTConfig = Partial<SharedGTConfig>;\n\n/**\n * Plugin configuration options (from babel config)\n */\nexport interface PluginConfig {\n /** Log level for the plugin */\n logLevel?: LogLevel;\n /** GT Configuration object — pass the parsed gt.config.json to sync settings */\n gtConfig?: GTConfig;\n /** Enable compile-time hash generation (default: true) */\n compileTimeHash?: boolean;\n /** Disable dynamic content validation checks */\n disableBuildChecks?: boolean;\n /** Enable macro transform (t`...`, t(`...`), t(\"a\" + b)) */\n enableMacroTransform?: boolean;\n /** Name of the string translation macro function */\n stringTranslationMacro?: string;\n /** Enable Auto Jsx Injection (e.g. <div>Hello</div> -> <div><T>Hello</T></div>) */\n enableAutoJsxInjection?: boolean;\n /** Package source for components inserted by Auto JSX Injection */\n autoJsxImportSource?: string;\n /** Automatically treat interpolated/concatenated values as derive() calls */\n autoderive?: boolean | { jsx?: boolean; strings?: boolean };\n /** Emit compiler-injected gt-react imports from gt-react/browser */\n legacyGtReactImportSource?: boolean;\n /** Debug: write a hash → jsxChildren manifest file on build */\n _debugHashManifest?: boolean;\n /** Dev hot reload: inject runtime translate calls and enable Suspense-based <T> */\n devHotReload?: boolean | { strings?: boolean; jsx?: boolean };\n}\n\n/**\n * Internal plugin settings (processed config)\n */\nexport interface PluginSettings {\n logLevel: LogLevel;\n compileTimeHash: boolean;\n disableBuildChecks: boolean;\n filename?: string;\n enableMacroTransform: boolean;\n stringTranslationMacro: string;\n enableTaggedTemplate: boolean;\n enableTemplateLiteralArg: boolean;\n enableConcatenationArg: boolean;\n enableMacroImportInjection: boolean;\n /** Enable Auto Jsx Injection (e.g. <div>Hello</div> -> <div><T>Hello</T></div>) */\n enableAutoJsxInjection: boolean;\n /** Package source for components inserted by Auto JSX Injection */\n autoJsxImportSource?: string;\n /** Automatically treat interpolated/concatenated values as derive() calls */\n autoderive: { jsx: boolean; strings: boolean };\n /** Emit compiler-injected gt-react imports from gt-react/browser */\n legacyGtReactImportSource: boolean;\n /** Debug: write a hash → jsxChildren manifest file on build */\n _debugHashManifest: boolean;\n /** Dev hot reload: inject runtime translate calls and enable Suspense-based <T> */\n devHotReload: { strings: boolean; jsx: boolean };\n}\n\n/**\n * Resolves the autoderive config value into separate jsx and strings flags.\n * - `true` enables both (backward compatible)\n * - `false` disables both (backward compatible)\n * - `{ jsx?: boolean; strings?: boolean }` enables selectively (missing keys default to false)\n */\nexport function resolveAutoderive(\n value: boolean | { jsx?: boolean; strings?: boolean } | undefined\n): { jsx: boolean; strings: boolean } {\n if (value === undefined || typeof value === 'boolean') {\n return { jsx: !!value, strings: !!value };\n }\n return { jsx: value.jsx ?? false, strings: value.strings ?? false };\n}\n\n/**\n * Resolves the devHotReload config value into separate strings and jsx flags.\n * - `true` enables strings only (JSX is handled at runtime via Suspense, no compiler injection needed)\n * - `false` disables both\n * - `{ strings?: boolean; jsx?: boolean }` enables selectively (missing keys default to false)\n */\nexport function resolveDevHotReload(\n value: boolean | { strings?: boolean; jsx?: boolean } | undefined\n): { strings: boolean; jsx: boolean } {\n if (value === undefined || typeof value === 'boolean') {\n return { strings: !!value, jsx: false };\n }\n return { strings: value.strings ?? false, jsx: value.jsx ?? false };\n}\n"],"mappings":";;;;;;;;AA2EA,SAAgB,kBACd,OACoC;AACpC,KAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAC1C,QAAO;EAAE,KAAK,CAAC,CAAC;EAAO,SAAS,CAAC,CAAC;EAAO;AAE3C,QAAO;EAAE,KAAK,MAAM,OAAO;EAAO,SAAS,MAAM,WAAW;EAAO;;;;;;;;AASrE,SAAgB,oBACd,OACoC;AACpC,KAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAC1C,QAAO;EAAE,SAAS,CAAC,CAAC;EAAO,KAAK;EAAO;AAEzC,QAAO;EAAE,SAAS,MAAM,WAAW;EAAO,KAAK,MAAM,OAAO;EAAO"}
package/dist/index.d.ts CHANGED
@@ -58,5 +58,6 @@ export default gtUnplugin;
58
58
  export declare const webpack: (options?: GTUnpluginOptions | undefined) => WebpackPluginInstance;
59
59
  export declare const vite: (options?: GTUnpluginOptions | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
60
60
  export declare const rollup: (options?: GTUnpluginOptions | undefined) => any;
61
+ export declare const rspack: (options?: GTUnpluginOptions | undefined) => RspackPluginInstance;
61
62
  export declare const esbuild: (options?: GTUnpluginOptions | undefined) => EsbuildPlugin;
62
63
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["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dist/index.js CHANGED
@@ -171,6 +171,7 @@ const gtUnplugin = (0, unplugin.createUnplugin)((options = {}) => {
171
171
  const webpack = gtUnplugin.webpack;
172
172
  const vite = gtUnplugin.vite;
173
173
  const rollup = gtUnplugin.rollup;
174
+ const rspack = gtUnplugin.rspack;
174
175
  const esbuild = gtUnplugin.esbuild;
175
176
  //#endregion
176
177
  exports.MISSING_GT_CONFIG_WARNING = MISSING_GT_CONFIG_WARNING;
@@ -178,6 +179,7 @@ exports.createInvalidGTConfigWarning = createInvalidGTConfigWarning;
178
179
  exports.default = gtUnplugin;
179
180
  exports.esbuild = esbuild;
180
181
  exports.rollup = rollup;
182
+ exports.rspack = rspack;
181
183
  exports.vite = vite;
182
184
  exports.webpack = webpack;
183
185
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["path","fs","initializeState","parser","jsxInsertionPass","macroExpansionPass","collectionPass","handleErrors","injectionPass","runtimeTranslatePass","InvalidLibraryUsageError"],"sources":["../src/index.ts"],"sourcesContent":["import { createUnplugin } from 'unplugin';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport * as parser from '@babel/parser';\nimport generate from '@babel/generator';\nimport traverse from '@babel/traverse';\n\n// Core modules\nimport { GTConfig, PluginConfig } from './config';\n\n// Import passes\nimport { collectionPass } from './passes/collectionPass';\nimport { injectionPass } from './passes/injectionPass';\nimport { macroExpansionPass } from './passes/macroExpansionPass';\nimport { handleErrors, InvalidLibraryUsageError } from './passes/handleErrors';\nimport { initializeState } from './state/utils/initializeState';\nimport { jsxInsertionPass } from './passes/jsxInsertionPass';\nimport { runtimeTranslatePass } from './passes/runtimeTranslatePass';\n\n/**\n * Architecture:\n *\n * Pass Pipeline:\n * - Pass 0: Macro expansion — transforms t`...` tagged templates and t(`...`) template/concatenation args\n * - Pass 1: Collection — collect + calculate all data, check for violations, register + track\n * - Pass 2: Injection — inject all data (hashes, messages, etc.)\n *\n * Babel functions:\n * - 1-to-1 relationship with processing functions\n * - Handle (1) enter/exit scope (2) invoking processing function\n * - ex) JSXElement()\n *\n * Processing functions:\n * - Are dependent on the pass, so they have three categories: (1) collection, (2) injection, (3) shared/general\n * - Invoke transformation functions and utility functions\n * - ex) processJSXElement()\n * - Has the following file structure:\n * + processing\n * | sharedProcessingFunction.ts\n * | + collection\n * | | collectionProcessingFunction.ts\n * | + injection\n * | | injectionProcessingFunction.ts\n *\n * Transformation functions:\n * - Are AGNOSTIC to pass number\n * - MUST be stateful in some way\n * - ex) trackImportDeclaration()\n *\n * Utility functions:\n * - Are AGNOSTIC to pass number\n * - Are stateless\n * - ex) extractIdentifiersFromLVal()\n *\n * State:\n * - Includes classes for tracking state\n *\n * Currently no support for:\n * - namespaces and and modules\n */\n\n/**\n * GT Universal Plugin Options\n */\nexport interface GTUnpluginOptions extends PluginConfig, GTConfig {}\n\nexport const MISSING_GT_CONFIG_WARNING =\n '[@generaltranslation/compiler] No gtConfig found. Auto JSX injection and parsingFlags features require a gt.config.json. See https://generaltranslation.com/en/docs/react/concepts/compiler.';\n\nexport const createInvalidGTConfigWarning = (\n configPath: string,\n error: unknown\n) =>\n `[@generaltranslation/compiler] Failed to load gt.config.json at ${configPath}. ` +\n `Auto JSX injection and parsingFlags features require a valid gt.config.json. ` +\n `${error instanceof Error ? error.message : String(error)}`;\n\nfunction shouldWarn(logLevel: PluginConfig['logLevel']): boolean {\n return logLevel !== 'silent' && logLevel !== 'error';\n}\n\ntype GTConfigLoadResult =\n | {\n gtConfig: NonNullable<PluginConfig['gtConfig']>;\n status: 'loaded';\n }\n | {\n status: 'missing';\n }\n | {\n configPath: string;\n error: unknown;\n status: 'invalid';\n };\n\nfunction loadGTConfigFromCwd(): GTConfigLoadResult {\n const configPath = path.join(process.cwd(), 'gt.config.json');\n if (!fs.existsSync(configPath)) {\n return { status: 'missing' };\n }\n\n try {\n return {\n gtConfig: JSON.parse(fs.readFileSync(configPath, 'utf-8')) as NonNullable<\n PluginConfig['gtConfig']\n >,\n status: 'loaded',\n };\n } catch (error) {\n return { configPath, error, status: 'invalid' };\n }\n}\n\nfunction hasInlineGTConfig(options: GTUnpluginOptions): boolean {\n return (\n options.defaultLocale !== undefined ||\n options.locales !== undefined ||\n options.projectId !== undefined ||\n options._versionId !== undefined ||\n options.files !== undefined\n );\n}\n\nfunction getInlineGTConfig(options: GTUnpluginOptions): GTConfig | undefined {\n if (!hasInlineGTConfig(options)) return undefined;\n\n return {\n ...(options.defaultLocale !== undefined\n ? { defaultLocale: options.defaultLocale }\n : {}),\n ...(options.locales !== undefined ? { locales: options.locales } : {}),\n ...(options.projectId !== undefined\n ? { projectId: options.projectId }\n : {}),\n ...(options._versionId !== undefined\n ? { _versionId: options._versionId }\n : {}),\n ...(options.files !== undefined ? { files: options.files } : {}),\n };\n}\n\nfunction mergeGTConfigs(base: GTConfig, override: GTConfig): GTConfig {\n const mergedConfig = { ...base, ...override };\n if (!base.files && !override.files) return mergedConfig;\n\n const files = { ...base.files, ...override.files };\n if (base.files?.gt || override.files?.gt) {\n const gt = { ...base.files?.gt, ...override.files?.gt };\n if (base.files?.gt?.parsingFlags || override.files?.gt?.parsingFlags) {\n gt.parsingFlags = {\n ...base.files?.gt?.parsingFlags,\n ...override.files?.gt?.parsingFlags,\n };\n }\n files.gt = gt;\n }\n\n return { ...mergedConfig, files };\n}\n\nfunction resolveGTConfig(options: GTUnpluginOptions): GTConfigLoadResult {\n if (options.gtConfig) {\n return { gtConfig: options.gtConfig, status: 'loaded' };\n }\n\n const inlineGTConfig = getInlineGTConfig(options);\n const diskGTConfig = loadGTConfigFromCwd();\n if (!inlineGTConfig) return diskGTConfig;\n\n return {\n gtConfig:\n diskGTConfig.status === 'loaded'\n ? mergeGTConfigs(diskGTConfig.gtConfig, inlineGTConfig)\n : inlineGTConfig,\n status: 'loaded',\n };\n}\n\n/**\n * GT Universal Plugin - Main entry point\n *\n * Universal plugin for compile-time optimization of GT translation components\n * that works across webpack, Vite, Rollup, and other bundlers.\n */\nconst gtUnplugin = createUnplugin<GTUnpluginOptions | undefined>(\n (options = {}) => {\n const gtConfigLoadResult = resolveGTConfig(options);\n const loadedGTConfig =\n gtConfigLoadResult.status === 'loaded'\n ? gtConfigLoadResult.gtConfig\n : undefined;\n const resolvedOptions: GTUnpluginOptions = {\n ...options,\n ...(loadedGTConfig ? { gtConfig: loadedGTConfig } : {}),\n };\n\n if (shouldWarn(options.logLevel)) {\n if (gtConfigLoadResult.status === 'missing') {\n console.warn(MISSING_GT_CONFIG_WARNING);\n } else if (gtConfigLoadResult.status === 'invalid') {\n console.warn(\n createInvalidGTConfigWarning(\n gtConfigLoadResult.configPath,\n gtConfigLoadResult.error\n )\n );\n }\n }\n\n // Debug manifest: accumulates hash → jsxChildren across all files\n const debugManifest = resolvedOptions._debugHashManifest\n ? new Map<string, unknown>()\n : undefined;\n\n return {\n name: '@generaltranslation/GT_PLUGIN',\n transformInclude(id: string) {\n // Only transform TSX and JSX files\n return (\n id.endsWith('.tsx') ||\n id.endsWith('.jsx') ||\n id.endsWith('.ts') ||\n id.endsWith('.js')\n );\n },\n transform(code: string, id: string) {\n // Initialize processing state\n const state = initializeState(resolvedOptions, id);\n if (debugManifest) state.debugManifest = debugManifest;\n try {\n // Skip transformation if not needed\n if (\n state.settings.disableBuildChecks &&\n !state.settings.compileTimeHash\n ) {\n return null;\n }\n\n // Parse the code into AST\n const ast = parser.parse(code, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript', 'decorators-legacy'],\n allowImportExportEverywhere: true,\n allowReturnOutsideFunction: true,\n });\n\n // Pass 1: Jsx insertion\n if (state.settings.enableAutoJsxInjection) {\n traverse(ast, jsxInsertionPass(state));\n }\n\n // Pass 2: Macro expansion\n if (state.settings.enableMacroTransform) {\n traverse(ast, macroExpansionPass(state));\n }\n\n // Pass 3: Collection\n traverse(ast, collectionPass(state));\n\n // Handle errors\n if (handleErrors(state)) {\n return null;\n }\n\n // Pass 4: Injection (hashes + useGT prefetch parameters), gated on\n // the compileTimeHash setting\n const hasCollectionContent = state.stringCollector.hasContent();\n const injectionRan =\n hasCollectionContent && state.settings.compileTimeHash;\n\n if (injectionRan) {\n traverse(ast, injectionPass(state));\n }\n\n // Pass 5: Runtime translate (dev hot reload)\n const devHotReloadActive =\n state.settings.devHotReload.strings ||\n state.settings.devHotReload.jsx;\n if (devHotReloadActive && hasCollectionContent) {\n traverse(ast, runtimeTranslatePass(state));\n }\n\n // Generate code if any pass modified the AST\n if (\n !injectionRan &&\n state.statistics.macroExpansionsCount === 0 &&\n state.statistics.jsxInsertionsCount === 0 &&\n state.statistics.runtimeTranslateCount === 0\n ) {\n return null;\n }\n\n return generate(ast, {\n retainLines: true,\n compact: false,\n });\n } catch (error) {\n // If the error is an instance of InvalidLibraryUsageError, throw it\n if (error instanceof InvalidLibraryUsageError) {\n throw error;\n }\n\n // Otherwise, log the error\n state.logger.logError(`Error processing ${id}: ${error}`);\n return null;\n }\n },\n buildEnd() {\n if (debugManifest && debugManifest.size > 0) {\n const fs = require('fs');\n const path = require('path');\n const outPath = path.resolve(\n process.cwd(),\n '_gt_debug_hash_manifest.json'\n );\n const manifest = Object.fromEntries(debugManifest);\n fs.writeFileSync(outPath, JSON.stringify(manifest, null, 2));\n // eslint-disable-next-line no-console\n console.log(\n `[gt-compiler] Debug hash manifest written to ${outPath} (${debugManifest.size} entries)`\n );\n }\n },\n };\n }\n);\n\n// Export the unplugin with different bundler integrations\nexport default gtUnplugin;\nexport const webpack = gtUnplugin.webpack;\nexport const vite = gtUnplugin.vite;\nexport const rollup = gtUnplugin.rollup;\nexport const esbuild = gtUnplugin.esbuild;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAa,4BACX;AAEF,MAAa,gCACX,YACA,UAEA,mEAAmE,WAAW,iFAE3E,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAE3D,SAAS,WAAW,UAA6C;AAC/D,QAAO,aAAa,YAAY,aAAa;;AAiB/C,SAAS,sBAA0C;CACjD,MAAM,aAAaA,UAA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,aAAa,WAC5B,MAAM,SAAS,aAAa,QACJ,qBACxB,EAAA,GAAA,gBAAA,SAAS,KAAKC,oCAAAA,qBAAqB,MAAM,CAAC;AAI5C,QACE,CAAC,gBACD,MAAM,WAAW,yBAAyB,KAC1C,MAAM,WAAW,uBAAuB,KACxC,MAAM,WAAW,0BAA0B,EAE3C,QAAO;AAGT,YAAA,GAAA,iBAAA,SAAgB,KAAK;KACnB,aAAa;KACb,SAAS;KACV,CAAC;YACK,OAAO;AAEd,QAAI,iBAAiBC,4BAAAA,yBACnB,OAAM;AAIR,UAAM,OAAO,SAAS,oBAAoB,GAAG,IAAI,QAAQ;AACzD,WAAO;;;EAGX,WAAW;AACT,OAAI,iBAAiB,cAAc,OAAO,GAAG;IAC3C,MAAM,KAAK,QAAQ,KAAK;IAExB,MAAM,UADO,QAAQ,OACD,CAAC,QACnB,QAAQ,KAAK,EACb,+BACD;IACD,MAAM,WAAW,OAAO,YAAY,cAAc;AAClD,OAAG,cAAc,SAAS,KAAK,UAAU,UAAU,MAAM,EAAE,CAAC;AAE5D,YAAQ,IACN,gDAAgD,QAAQ,IAAI,cAAc,KAAK,WAChF;;;EAGN;EAEJ;AAID,MAAa,UAAU,WAAW;AAClC,MAAa,OAAO,WAAW;AAC/B,MAAa,SAAS,WAAW;AACjC,MAAa,UAAU,WAAW"}
1
+ {"version":3,"file":"index.js","names":["path","fs","initializeState","parser","jsxInsertionPass","macroExpansionPass","collectionPass","handleErrors","injectionPass","runtimeTranslatePass","InvalidLibraryUsageError"],"sources":["../src/index.ts"],"sourcesContent":["import { createUnplugin } from 'unplugin';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport * as parser from '@babel/parser';\nimport generate from '@babel/generator';\nimport traverse from '@babel/traverse';\n\n// Core modules\nimport { GTConfig, PluginConfig } from './config';\n\n// Import passes\nimport { collectionPass } from './passes/collectionPass';\nimport { injectionPass } from './passes/injectionPass';\nimport { macroExpansionPass } from './passes/macroExpansionPass';\nimport { handleErrors, InvalidLibraryUsageError } from './passes/handleErrors';\nimport { initializeState } from './state/utils/initializeState';\nimport { jsxInsertionPass } from './passes/jsxInsertionPass';\nimport { runtimeTranslatePass } from './passes/runtimeTranslatePass';\n\n/**\n * Architecture:\n *\n * Pass Pipeline:\n * - Pass 0: Macro expansion — transforms t`...` tagged templates and t(`...`) template/concatenation args\n * - Pass 1: Collection — collect + calculate all data, check for violations, register + track\n * - Pass 2: Injection — inject all data (hashes, messages, etc.)\n *\n * Babel functions:\n * - 1-to-1 relationship with processing functions\n * - Handle (1) enter/exit scope (2) invoking processing function\n * - ex) JSXElement()\n *\n * Processing functions:\n * - Are dependent on the pass, so they have three categories: (1) collection, (2) injection, (3) shared/general\n * - Invoke transformation functions and utility functions\n * - ex) processJSXElement()\n * - Has the following file structure:\n * + processing\n * | sharedProcessingFunction.ts\n * | + collection\n * | | collectionProcessingFunction.ts\n * | + injection\n * | | injectionProcessingFunction.ts\n *\n * Transformation functions:\n * - Are AGNOSTIC to pass number\n * - MUST be stateful in some way\n * - ex) trackImportDeclaration()\n *\n * Utility functions:\n * - Are AGNOSTIC to pass number\n * - Are stateless\n * - ex) extractIdentifiersFromLVal()\n *\n * State:\n * - Includes classes for tracking state\n *\n * Currently no support for:\n * - namespaces and and modules\n */\n\n/**\n * GT Universal Plugin Options\n */\nexport interface GTUnpluginOptions extends PluginConfig, GTConfig {}\n\nexport const MISSING_GT_CONFIG_WARNING =\n '[@generaltranslation/compiler] No gtConfig found. Auto JSX injection and parsingFlags features require a gt.config.json. See https://generaltranslation.com/en/docs/react/concepts/compiler.';\n\nexport const createInvalidGTConfigWarning = (\n configPath: string,\n error: unknown\n) =>\n `[@generaltranslation/compiler] Failed to load gt.config.json at ${configPath}. ` +\n `Auto JSX injection and parsingFlags features require a valid gt.config.json. ` +\n `${error instanceof Error ? error.message : String(error)}`;\n\nfunction shouldWarn(logLevel: PluginConfig['logLevel']): boolean {\n return logLevel !== 'silent' && logLevel !== 'error';\n}\n\ntype GTConfigLoadResult =\n | {\n gtConfig: NonNullable<PluginConfig['gtConfig']>;\n status: 'loaded';\n }\n | {\n status: 'missing';\n }\n | {\n configPath: string;\n error: unknown;\n status: 'invalid';\n };\n\nfunction loadGTConfigFromCwd(): GTConfigLoadResult {\n const configPath = path.join(process.cwd(), 'gt.config.json');\n if (!fs.existsSync(configPath)) {\n return { status: 'missing' };\n }\n\n try {\n return {\n gtConfig: JSON.parse(fs.readFileSync(configPath, 'utf-8')) as NonNullable<\n PluginConfig['gtConfig']\n >,\n status: 'loaded',\n };\n } catch (error) {\n return { configPath, error, status: 'invalid' };\n }\n}\n\nfunction hasInlineGTConfig(options: GTUnpluginOptions): boolean {\n return (\n options.defaultLocale !== undefined ||\n options.locales !== undefined ||\n options.projectId !== undefined ||\n options._versionId !== undefined ||\n options.files !== undefined\n );\n}\n\nfunction getInlineGTConfig(options: GTUnpluginOptions): GTConfig | undefined {\n if (!hasInlineGTConfig(options)) return undefined;\n\n return {\n ...(options.defaultLocale !== undefined\n ? { defaultLocale: options.defaultLocale }\n : {}),\n ...(options.locales !== undefined ? { locales: options.locales } : {}),\n ...(options.projectId !== undefined\n ? { projectId: options.projectId }\n : {}),\n ...(options._versionId !== undefined\n ? { _versionId: options._versionId }\n : {}),\n ...(options.files !== undefined ? { files: options.files } : {}),\n };\n}\n\nfunction mergeGTConfigs(base: GTConfig, override: GTConfig): GTConfig {\n const mergedConfig = { ...base, ...override };\n if (!base.files && !override.files) return mergedConfig;\n\n const files = { ...base.files, ...override.files };\n if (base.files?.gt || override.files?.gt) {\n const gt = { ...base.files?.gt, ...override.files?.gt };\n if (base.files?.gt?.parsingFlags || override.files?.gt?.parsingFlags) {\n gt.parsingFlags = {\n ...base.files?.gt?.parsingFlags,\n ...override.files?.gt?.parsingFlags,\n };\n }\n files.gt = gt;\n }\n\n return { ...mergedConfig, files };\n}\n\nfunction resolveGTConfig(options: GTUnpluginOptions): GTConfigLoadResult {\n if (options.gtConfig) {\n return { gtConfig: options.gtConfig, status: 'loaded' };\n }\n\n const inlineGTConfig = getInlineGTConfig(options);\n const diskGTConfig = loadGTConfigFromCwd();\n if (!inlineGTConfig) return diskGTConfig;\n\n return {\n gtConfig:\n diskGTConfig.status === 'loaded'\n ? mergeGTConfigs(diskGTConfig.gtConfig, inlineGTConfig)\n : inlineGTConfig,\n status: 'loaded',\n };\n}\n\n/**\n * GT Universal Plugin - Main entry point\n *\n * Universal plugin for compile-time optimization of GT translation components\n * that works across webpack, Vite, Rollup, and other bundlers.\n */\nconst gtUnplugin = createUnplugin<GTUnpluginOptions | undefined>(\n (options = {}) => {\n const gtConfigLoadResult = resolveGTConfig(options);\n const loadedGTConfig =\n gtConfigLoadResult.status === 'loaded'\n ? gtConfigLoadResult.gtConfig\n : undefined;\n const resolvedOptions: GTUnpluginOptions = {\n ...options,\n ...(loadedGTConfig ? { gtConfig: loadedGTConfig } : {}),\n };\n\n if (shouldWarn(options.logLevel)) {\n if (gtConfigLoadResult.status === 'missing') {\n console.warn(MISSING_GT_CONFIG_WARNING);\n } else if (gtConfigLoadResult.status === 'invalid') {\n console.warn(\n createInvalidGTConfigWarning(\n gtConfigLoadResult.configPath,\n gtConfigLoadResult.error\n )\n );\n }\n }\n\n // Debug manifest: accumulates hash → jsxChildren across all files\n const debugManifest = resolvedOptions._debugHashManifest\n ? new Map<string, unknown>()\n : undefined;\n\n return {\n name: '@generaltranslation/GT_PLUGIN',\n transformInclude(id: string) {\n // Only transform TSX and JSX files\n return (\n id.endsWith('.tsx') ||\n id.endsWith('.jsx') ||\n id.endsWith('.ts') ||\n id.endsWith('.js')\n );\n },\n transform(code: string, id: string) {\n // Initialize processing state\n const state = initializeState(resolvedOptions, id);\n if (debugManifest) state.debugManifest = debugManifest;\n try {\n // Skip transformation if not needed\n if (\n state.settings.disableBuildChecks &&\n !state.settings.compileTimeHash\n ) {\n return null;\n }\n\n // Parse the code into AST\n const ast = parser.parse(code, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript', 'decorators-legacy'],\n allowImportExportEverywhere: true,\n allowReturnOutsideFunction: true,\n });\n\n // Pass 1: Jsx insertion\n if (state.settings.enableAutoJsxInjection) {\n traverse(ast, jsxInsertionPass(state));\n }\n\n // Pass 2: Macro expansion\n if (state.settings.enableMacroTransform) {\n traverse(ast, macroExpansionPass(state));\n }\n\n // Pass 3: Collection\n traverse(ast, collectionPass(state));\n\n // Handle errors\n if (handleErrors(state)) {\n return null;\n }\n\n // Pass 4: Injection (hashes + useGT prefetch parameters), gated on\n // the compileTimeHash setting\n const hasCollectionContent = state.stringCollector.hasContent();\n const injectionRan =\n hasCollectionContent && state.settings.compileTimeHash;\n\n if (injectionRan) {\n traverse(ast, injectionPass(state));\n }\n\n // Pass 5: Runtime translate (dev hot reload)\n const devHotReloadActive =\n state.settings.devHotReload.strings ||\n state.settings.devHotReload.jsx;\n if (devHotReloadActive && hasCollectionContent) {\n traverse(ast, runtimeTranslatePass(state));\n }\n\n // Generate code if any pass modified the AST\n if (\n !injectionRan &&\n state.statistics.macroExpansionsCount === 0 &&\n state.statistics.jsxInsertionsCount === 0 &&\n state.statistics.runtimeTranslateCount === 0\n ) {\n return null;\n }\n\n return generate(ast, {\n retainLines: true,\n compact: false,\n });\n } catch (error) {\n // If the error is an instance of InvalidLibraryUsageError, throw it\n if (error instanceof InvalidLibraryUsageError) {\n throw error;\n }\n\n // Otherwise, log the error\n state.logger.logError(`Error processing ${id}: ${error}`);\n return null;\n }\n },\n buildEnd() {\n if (debugManifest && debugManifest.size > 0) {\n const fs = require('fs');\n const path = require('path');\n const outPath = path.resolve(\n process.cwd(),\n '_gt_debug_hash_manifest.json'\n );\n const manifest = Object.fromEntries(debugManifest);\n fs.writeFileSync(outPath, JSON.stringify(manifest, null, 2));\n // eslint-disable-next-line no-console\n console.log(\n `[gt-compiler] Debug hash manifest written to ${outPath} (${debugManifest.size} entries)`\n );\n }\n },\n };\n }\n);\n\n// Export the unplugin with different bundler integrations\nexport default gtUnplugin;\nexport const webpack = gtUnplugin.webpack;\nexport const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sxInsertionPass.d.ts","sourceRoot":"","sources":["../../src/passes/jsxInsertionPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAQhD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CAuBvE"}
1
+ {"version":3,"file":"jsxInsertionPass.d.ts","sourceRoot":"","sources":["../../src/passes/jsxInsertionPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAQhD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CA2BvE"}
@@ -21,7 +21,7 @@ function jsxInsertionPass(state) {
21
21
  alreadyImported = true;
22
22
  };
23
23
  return {
24
- ImportDeclaration: require_processing_jsx_insertion_processImportDeclaration.processImportDeclaration(onImportFound, calleeInfo),
24
+ ImportDeclaration: require_processing_jsx_insertion_processImportDeclaration.processImportDeclaration(onImportFound, calleeInfo, state.settings.autoJsxImportSource),
25
25
  CallExpression: require_processing_jsx_insertion_processCallExpression.processCallExpression(state, calleeInfo),
26
26
  Program: require_processing_jsx_insertion_processProgram.processProgram({
27
27
  state,
@@ -1 +1 @@
1
- {"version":3,"file":"jsxInsertionPass.js","names":["processImportDeclaration","processCallExpression","processProgram"],"sources":["../../src/passes/jsxInsertionPass.ts"],"sourcesContent":["import { TraverseOptions } from '@babel/traverse';\nimport { TransformState } from '../state/types';\nimport { processCallExpression } from '../processing/jsx-insertion/processCallExpression';\nimport {\n processImportDeclaration,\n JsxCalleeInfo,\n} from '../processing/jsx-insertion/processImportDeclaration';\nimport { processProgram } from '../processing/jsx-insertion/processProgram';\n\n/**\n * The purpose of this pass is to insert the translation component (GtInternalTranslateJsx)\n * and variable component (GtInternalVar) automatically into the Jsx tree.\n * This is specifically for browser builds only.\n *\n * <div>Hello</div> -> <div><GtInternalTranslateJsx>Hello</GtInternalTranslateJsx></div>\n */\nexport function jsxInsertionPass(state: TransformState): TraverseOptions {\n let alreadyImported = false;\n const countBefore = state.statistics.jsxInsertionsCount;\n\n const calleeInfo: JsxCalleeInfo = {\n singleCallee: null,\n multiCallee: null,\n };\n\n const onImportFound = () => {\n alreadyImported = true;\n };\n\n return {\n ImportDeclaration: processImportDeclaration(onImportFound, calleeInfo),\n CallExpression: processCallExpression(state, calleeInfo),\n Program: processProgram({\n state,\n countBefore,\n isAlreadyImported: () => alreadyImported,\n calleeInfo,\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAgB,iBAAiB,OAAwC;CACvE,IAAI,kBAAkB;CACtB,MAAM,cAAc,MAAM,WAAW;CAErC,MAAM,aAA4B;EAChC,cAAc;EACd,aAAa;EACd;CAED,MAAM,sBAAsB;AAC1B,oBAAkB;;AAGpB,QAAO;EACL,mBAAmBA,0DAAAA,yBAAyB,eAAe,WAAW;EACtE,gBAAgBC,uDAAAA,sBAAsB,OAAO,WAAW;EACxD,SAASC,gDAAAA,eAAe;GACtB;GACA;GACA,yBAAyB;GACzB;GACD,CAAC;EACH"}
1
+ {"version":3,"file":"jsxInsertionPass.js","names":["processImportDeclaration","processCallExpression","processProgram"],"sources":["../../src/passes/jsxInsertionPass.ts"],"sourcesContent":["import { TraverseOptions } from '@babel/traverse';\nimport { TransformState } from '../state/types';\nimport { processCallExpression } from '../processing/jsx-insertion/processCallExpression';\nimport {\n processImportDeclaration,\n JsxCalleeInfo,\n} from '../processing/jsx-insertion/processImportDeclaration';\nimport { processProgram } from '../processing/jsx-insertion/processProgram';\n\n/**\n * The purpose of this pass is to insert the translation component (GtInternalTranslateJsx)\n * and variable component (GtInternalVar) automatically into the Jsx tree.\n * This is specifically for browser builds only.\n *\n * <div>Hello</div> -> <div><GtInternalTranslateJsx>Hello</GtInternalTranslateJsx></div>\n */\nexport function jsxInsertionPass(state: TransformState): TraverseOptions {\n let alreadyImported = false;\n const countBefore = state.statistics.jsxInsertionsCount;\n\n const calleeInfo: JsxCalleeInfo = {\n singleCallee: null,\n multiCallee: null,\n };\n\n const onImportFound = () => {\n alreadyImported = true;\n };\n\n return {\n ImportDeclaration: processImportDeclaration(\n onImportFound,\n calleeInfo,\n state.settings.autoJsxImportSource\n ),\n CallExpression: processCallExpression(state, calleeInfo),\n Program: processProgram({\n state,\n countBefore,\n isAlreadyImported: () => alreadyImported,\n calleeInfo,\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAgB,iBAAiB,OAAwC;CACvE,IAAI,kBAAkB;CACtB,MAAM,cAAc,MAAM,WAAW;CAErC,MAAM,aAA4B;EAChC,cAAc;EACd,aAAa;EACd;CAED,MAAM,sBAAsB;AAC1B,oBAAkB;;AAGpB,QAAO;EACL,mBAAmBA,0DAAAA,yBACjB,eACA,YACA,MAAM,SAAS,oBAChB;EACD,gBAAgBC,uDAAAA,sBAAsB,OAAO,WAAW;EACxD,SAASC,gDAAAA,eAAe;GACtB;GACA;GACA,yBAAyB;GACzB;GACD,CAAC;EACH"}
@@ -16,5 +16,5 @@ export interface JsxCalleeInfo {
16
16
  * - Checks if GtInternalTranslateJsx is already imported from a GT source.
17
17
  * - Collects React jsx callee info (jsx vs jsxs vs jsxDEV, including aliases).
18
18
  */
19
- export declare function processImportDeclaration(onGtImportFound: () => void, calleeInfo: JsxCalleeInfo): VisitNode<t.Node, t.ImportDeclaration>;
19
+ export declare function processImportDeclaration(onGtImportFound: () => void, calleeInfo: JsxCalleeInfo, autoJsxImportSource?: string): VisitNode<t.Node, t.ImportDeclaration>;
20
20
  //# sourceMappingURL=processImportDeclaration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"processImportDeclaration.d.ts","sourceRoot":"","sources":["../../../src/processing/jsx-insertion/processImportDeclaration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAMlC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kEAAkE;IAClE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,MAAM,IAAI,EAC3B,UAAU,EAAE,aAAa,GACxB,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,iBAAiB,CAAC,CA0CxC"}
1
+ {"version":3,"file":"processImportDeclaration.d.ts","sourceRoot":"","sources":["../../../src/processing/jsx-insertion/processImportDeclaration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAMlC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kEAAkE;IAClE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,MAAM,IAAI,EAC3B,UAAU,EAAE,aAAa,EACzB,mBAAmB,CAAC,EAAE,MAAM,GAC3B,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,iBAAiB,CAAC,CA0CxC"}
@@ -12,11 +12,11 @@ _babel_types = require_runtime.__toESM(_babel_types);
12
12
  * - Checks if GtInternalTranslateJsx is already imported from a GT source.
13
13
  * - Collects React jsx callee info (jsx vs jsxs vs jsxDEV, including aliases).
14
14
  */
15
- function processImportDeclaration(onGtImportFound, calleeInfo) {
15
+ function processImportDeclaration(onGtImportFound, calleeInfo, autoJsxImportSource) {
16
16
  const targetName = "GtInternalTranslateJsx";
17
17
  return (path) => {
18
18
  const source = path.node.source.value;
19
- if (require_utils_constants_gt_helpers.isGTImportSource(source)) {
19
+ if (require_utils_constants_gt_helpers.isGTImportSource(source) || source === autoJsxImportSource) {
20
20
  for (const specifier of path.node.specifiers) if (_babel_types.isImportSpecifier(specifier) && _babel_types.isIdentifier(specifier.imported) && specifier.imported.name === targetName) {
21
21
  onGtImportFound();
22
22
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"processImportDeclaration.js","names":["isGTImportSource","t","isReactImportSource"],"sources":["../../../src/processing/jsx-insertion/processImportDeclaration.ts"],"sourcesContent":["import { VisitNode } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { isGTImportSource } from '../../utils/constants/gt/helpers';\nimport { isReactImportSource } from '../../utils/constants/react/helpers';\nimport { GT_COMPONENT_TYPES } from '../../utils/constants/gt/constants';\nimport { REACT_FUNTIONS } from '../../utils/constants/react/constants';\n\n/**\n * Info about the jsx callee names used in the file.\n * Populated during import analysis so processCallExpression\n * knows which callee to use for jsx (single child) vs jsxs (array children).\n */\nexport interface JsxCalleeInfo {\n /** Local name for single-child calls (jsx or _jsx or _jsxDEV) */\n singleCallee: string | null;\n /** Local name for multi-child calls (jsxs or _jsxs or _jsxDEV) */\n multiCallee: string | null;\n}\n\n/**\n * Process import declarations during jsx insertion.\n * - Checks if GtInternalTranslateJsx is already imported from a GT source.\n * - Collects React jsx callee info (jsx vs jsxs vs jsxDEV, including aliases).\n */\nexport function processImportDeclaration(\n onGtImportFound: () => void,\n calleeInfo: JsxCalleeInfo\n): VisitNode<t.Node, t.ImportDeclaration> {\n const targetName = GT_COMPONENT_TYPES.GtInternalTranslateJsx;\n\n return (path) => {\n const source = path.node.source.value;\n\n // Check for existing GT import\n if (isGTImportSource(source)) {\n for (const specifier of path.node.specifiers) {\n if (\n t.isImportSpecifier(specifier) &&\n t.isIdentifier(specifier.imported) &&\n specifier.imported.name === targetName\n ) {\n onGtImportFound();\n return;\n }\n }\n }\n\n // Collect React jsx callee names\n if (isReactImportSource(source)) {\n for (const specifier of path.node.specifiers) {\n if (!t.isImportSpecifier(specifier)) continue;\n const imported = specifier.imported;\n const originalName = t.isIdentifier(imported)\n ? imported.name\n : imported.value;\n const localName = specifier.local.name;\n\n if (originalName === REACT_FUNTIONS.jsxDEV) {\n // Dev mode: jsxDEV handles both single and multi children\n calleeInfo.singleCallee = localName;\n calleeInfo.multiCallee = localName;\n } else if (originalName === REACT_FUNTIONS.jsx) {\n calleeInfo.singleCallee = localName;\n } else if (originalName === REACT_FUNTIONS.jsxs) {\n calleeInfo.multiCallee = localName;\n }\n }\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,yBACd,iBACA,YACwC;CACxC,MAAM,aAAA;AAEN,SAAQ,SAAS;EACf,MAAM,SAAS,KAAK,KAAK,OAAO;AAGhC,MAAIA,mCAAAA,iBAAiB,OAAO;QACrB,MAAM,aAAa,KAAK,KAAK,WAChC,KACEC,aAAE,kBAAkB,UAAU,IAC9BA,aAAE,aAAa,UAAU,SAAS,IAClC,UAAU,SAAS,SAAS,YAC5B;AACA,qBAAiB;AACjB;;;AAMN,MAAIC,sCAAAA,oBAAoB,OAAO,CAC7B,MAAK,MAAM,aAAa,KAAK,KAAK,YAAY;AAC5C,OAAI,CAACD,aAAE,kBAAkB,UAAU,CAAE;GACrC,MAAM,WAAW,UAAU;GAC3B,MAAM,eAAeA,aAAE,aAAa,SAAS,GACzC,SAAS,OACT,SAAS;GACb,MAAM,YAAY,UAAU,MAAM;AAElC,OAAI,iBAAA,UAAwC;AAE1C,eAAW,eAAe;AAC1B,eAAW,cAAc;cAChB,iBAAA,MACT,YAAW,eAAe;YACjB,iBAAA,OACT,YAAW,cAAc"}
1
+ {"version":3,"file":"processImportDeclaration.js","names":["isGTImportSource","t","isReactImportSource"],"sources":["../../../src/processing/jsx-insertion/processImportDeclaration.ts"],"sourcesContent":["import { VisitNode } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { isGTImportSource } from '../../utils/constants/gt/helpers';\nimport { isReactImportSource } from '../../utils/constants/react/helpers';\nimport { GT_COMPONENT_TYPES } from '../../utils/constants/gt/constants';\nimport { REACT_FUNTIONS } from '../../utils/constants/react/constants';\n\n/**\n * Info about the jsx callee names used in the file.\n * Populated during import analysis so processCallExpression\n * knows which callee to use for jsx (single child) vs jsxs (array children).\n */\nexport interface JsxCalleeInfo {\n /** Local name for single-child calls (jsx or _jsx or _jsxDEV) */\n singleCallee: string | null;\n /** Local name for multi-child calls (jsxs or _jsxs or _jsxDEV) */\n multiCallee: string | null;\n}\n\n/**\n * Process import declarations during jsx insertion.\n * - Checks if GtInternalTranslateJsx is already imported from a GT source.\n * - Collects React jsx callee info (jsx vs jsxs vs jsxDEV, including aliases).\n */\nexport function processImportDeclaration(\n onGtImportFound: () => void,\n calleeInfo: JsxCalleeInfo,\n autoJsxImportSource?: string\n): VisitNode<t.Node, t.ImportDeclaration> {\n const targetName = GT_COMPONENT_TYPES.GtInternalTranslateJsx;\n\n return (path) => {\n const source = path.node.source.value;\n\n // Check for existing GT import\n if (isGTImportSource(source) || source === autoJsxImportSource) {\n for (const specifier of path.node.specifiers) {\n if (\n t.isImportSpecifier(specifier) &&\n t.isIdentifier(specifier.imported) &&\n specifier.imported.name === targetName\n ) {\n onGtImportFound();\n return;\n }\n }\n }\n\n // Collect React jsx callee names\n if (isReactImportSource(source)) {\n for (const specifier of path.node.specifiers) {\n if (!t.isImportSpecifier(specifier)) continue;\n const imported = specifier.imported;\n const originalName = t.isIdentifier(imported)\n ? imported.name\n : imported.value;\n const localName = specifier.local.name;\n\n if (originalName === REACT_FUNTIONS.jsxDEV) {\n // Dev mode: jsxDEV handles both single and multi children\n calleeInfo.singleCallee = localName;\n calleeInfo.multiCallee = localName;\n } else if (originalName === REACT_FUNTIONS.jsx) {\n calleeInfo.singleCallee = localName;\n } else if (originalName === REACT_FUNTIONS.jsxs) {\n calleeInfo.multiCallee = localName;\n }\n }\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,yBACd,iBACA,YACA,qBACwC;CACxC,MAAM,aAAA;AAEN,SAAQ,SAAS;EACf,MAAM,SAAS,KAAK,KAAK,OAAO;AAGhC,MAAIA,mCAAAA,iBAAiB,OAAO,IAAI,WAAW;QACpC,MAAM,aAAa,KAAK,KAAK,WAChC,KACEC,aAAE,kBAAkB,UAAU,IAC9BA,aAAE,aAAa,UAAU,SAAS,IAClC,UAAU,SAAS,SAAS,YAC5B;AACA,qBAAiB;AACjB;;;AAMN,MAAIC,sCAAAA,oBAAoB,OAAO,CAC7B,MAAK,MAAM,aAAa,KAAK,KAAK,YAAY;AAC5C,OAAI,CAACD,aAAE,kBAAkB,UAAU,CAAE;GACrC,MAAM,WAAW,UAAU;GAC3B,MAAM,eAAeA,aAAE,aAAa,SAAS,GACzC,SAAS,OACT,SAAS;GACb,MAAM,YAAY,UAAU,MAAM;AAElC,OAAI,iBAAA,UAAwC;AAE1C,eAAW,eAAe;AAC1B,eAAW,cAAc;cAChB,iBAAA,MACT,YAAW,eAAe;YACjB,iBAAA,OACT,YAAW,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"processProgram.d.ts","sourceRoot":"","sources":["../../../src/processing/jsx-insertion/processProgram.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI3D;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,WAAW,EACX,iBAAiB,EACjB,UAAU,GACX,EAAE;IACD,KAAK,EAAE,cAAc,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,OAAO,CAAC;IACjC,UAAU,EAAE,aAAa,CAAC;CAC3B,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CA8B/B"}
1
+ {"version":3,"file":"processProgram.d.ts","sourceRoot":"","sources":["../../../src/processing/jsx-insertion/processProgram.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI3D;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,WAAW,EACX,iBAAiB,EACjB,UAAU,GACX,EAAE;IACD,KAAK,EAAE,cAAc,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,OAAO,CAAC;IACjC,UAAU,EAAE,aAAa,CAAC;CAC3B,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CA+B/B"}
@@ -15,7 +15,7 @@ _babel_types = require_runtime.__toESM(_babel_types);
15
15
  function processProgram({ state, countBefore, isAlreadyImported, calleeInfo }) {
16
16
  return { exit(path) {
17
17
  if (!(state.statistics.jsxInsertionsCount > countBefore)) return;
18
- if (!isAlreadyImported()) require_transform_jsx_insertion_injectJsxInsertionImport.injectJsxInsertionImport(path, state.settings.legacyGtReactImportSource);
18
+ if (!isAlreadyImported()) require_transform_jsx_insertion_injectJsxInsertionImport.injectJsxInsertionImport(path, state.settings.autoJsxImportSource, state.settings.legacyGtReactImportSource);
19
19
  if (!calleeInfo.singleCallee && calleeInfo.multiCallee) {
20
20
  const jsxImport = _babel_types.importDeclaration([_babel_types.importSpecifier(_babel_types.identifier("jsx"), _babel_types.identifier("jsx"))], _babel_types.stringLiteral("react/jsx-runtime"));
21
21
  path.unshiftContainer("body", jsxImport);
@@ -1 +1 @@
1
- {"version":3,"file":"processProgram.js","names":["t"],"sources":["../../../src/processing/jsx-insertion/processProgram.ts"],"sourcesContent":["import { TransformState } from '../../state/types';\nimport { VisitNode } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { injectJsxInsertionImport } from '../../transform/jsx-insertion/injectJsxInsertionImport';\nimport { JsxCalleeInfo } from './processImportDeclaration';\nimport { REACT_FUNTIONS } from '../../utils/constants/react/constants';\nimport { REACT_IMPORT_SOURCES } from '../../utils/constants/react/constants';\n\n/**\n * Process program:\n * - on exit, injects GtInternalTranslateJsx/GtInternalVar import if needed\n * - also injects `jsx` from React runtime if only `jsxs` was imported\n * (Vite production builds only import what's needed — if a file has only\n * multi-child elements, `jsx` is never imported, but our _Var wrappers need it)\n */\nexport function processProgram({\n state,\n countBefore,\n isAlreadyImported,\n calleeInfo,\n}: {\n state: TransformState;\n countBefore: number;\n isAlreadyImported: () => boolean;\n calleeInfo: JsxCalleeInfo;\n}): VisitNode<t.Node, t.Program> {\n return {\n exit(path) {\n const didInsert = state.statistics.jsxInsertionsCount > countBefore;\n if (!didInsert) return;\n\n if (!isAlreadyImported()) {\n injectJsxInsertionImport(\n path,\n state.settings.legacyGtReactImportSource\n );\n }\n\n // If only jsxs was imported (no jsx), inject jsx import.\n // _Var wrappers always use singleCallee which defaults to 'jsx'.\n if (!calleeInfo.singleCallee && calleeInfo.multiCallee) {\n const jsxImport = t.importDeclaration(\n [\n t.importSpecifier(\n t.identifier(REACT_FUNTIONS.jsx),\n t.identifier(REACT_FUNTIONS.jsx)\n ),\n ],\n t.stringLiteral(REACT_IMPORT_SOURCES.JSX_RUNTIME)\n );\n path.unshiftContainer('body', jsxImport);\n calleeInfo.singleCallee = REACT_FUNTIONS.jsx;\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,eAAe,EAC7B,OACA,aACA,mBACA,cAM+B;AAC/B,QAAO,EACL,KAAK,MAAM;AAET,MAAI,EADc,MAAM,WAAW,qBAAqB,aACxC;AAEhB,MAAI,CAAC,mBAAmB,CACtB,0DAAA,yBACE,MACA,MAAM,SAAS,0BAChB;AAKH,MAAI,CAAC,WAAW,gBAAgB,WAAW,aAAa;GACtD,MAAM,YAAYA,aAAE,kBAClB,CACEA,aAAE,gBACAA,aAAE,WAAA,MAA8B,EAChCA,aAAE,WAAA,MAA8B,CACjC,CACF,EACDA,aAAE,cAAA,oBAA+C,CAClD;AACD,QAAK,iBAAiB,QAAQ,UAAU;AACxC,cAAW,eAAA;;IAGhB"}
1
+ {"version":3,"file":"processProgram.js","names":["t"],"sources":["../../../src/processing/jsx-insertion/processProgram.ts"],"sourcesContent":["import { TransformState } from '../../state/types';\nimport { VisitNode } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { injectJsxInsertionImport } from '../../transform/jsx-insertion/injectJsxInsertionImport';\nimport { JsxCalleeInfo } from './processImportDeclaration';\nimport { REACT_FUNTIONS } from '../../utils/constants/react/constants';\nimport { REACT_IMPORT_SOURCES } from '../../utils/constants/react/constants';\n\n/**\n * Process program:\n * - on exit, injects GtInternalTranslateJsx/GtInternalVar import if needed\n * - also injects `jsx` from React runtime if only `jsxs` was imported\n * (Vite production builds only import what's needed — if a file has only\n * multi-child elements, `jsx` is never imported, but our _Var wrappers need it)\n */\nexport function processProgram({\n state,\n countBefore,\n isAlreadyImported,\n calleeInfo,\n}: {\n state: TransformState;\n countBefore: number;\n isAlreadyImported: () => boolean;\n calleeInfo: JsxCalleeInfo;\n}): VisitNode<t.Node, t.Program> {\n return {\n exit(path) {\n const didInsert = state.statistics.jsxInsertionsCount > countBefore;\n if (!didInsert) return;\n\n if (!isAlreadyImported()) {\n injectJsxInsertionImport(\n path,\n state.settings.autoJsxImportSource,\n state.settings.legacyGtReactImportSource\n );\n }\n\n // If only jsxs was imported (no jsx), inject jsx import.\n // _Var wrappers always use singleCallee which defaults to 'jsx'.\n if (!calleeInfo.singleCallee && calleeInfo.multiCallee) {\n const jsxImport = t.importDeclaration(\n [\n t.importSpecifier(\n t.identifier(REACT_FUNTIONS.jsx),\n t.identifier(REACT_FUNTIONS.jsx)\n ),\n ],\n t.stringLiteral(REACT_IMPORT_SOURCES.JSX_RUNTIME)\n );\n path.unshiftContainer('body', jsxImport);\n calleeInfo.singleCallee = REACT_FUNTIONS.jsx;\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,eAAe,EAC7B,OACA,aACA,mBACA,cAM+B;AAC/B,QAAO,EACL,KAAK,MAAM;AAET,MAAI,EADc,MAAM,WAAW,qBAAqB,aACxC;AAEhB,MAAI,CAAC,mBAAmB,CACtB,0DAAA,yBACE,MACA,MAAM,SAAS,qBACf,MAAM,SAAS,0BAChB;AAKH,MAAI,CAAC,WAAW,gBAAgB,WAAW,aAAa;GACtD,MAAM,YAAYA,aAAE,kBAClB,CACEA,aAAE,gBACAA,aAAE,WAAA,MAA8B,EAChCA,aAAE,WAAA,MAA8B,CACjC,CACF,EACDA,aAAE,cAAA,oBAA+C,CAClD;AACD,QAAK,iBAAiB,QAAQ,UAAU;AACxC,cAAW,eAAA;;IAGhB"}
@@ -4,5 +4,5 @@ import { NodePath } from '@babel/traverse';
4
4
  * Inject `import { GtInternalTranslateJsx, GtInternalVar } from 'gt-react'`
5
5
  * as the first statement in the program.
6
6
  */
7
- export declare function injectJsxInsertionImport(path: NodePath<t.Program>, legacyGtReactImportSource: boolean): void;
7
+ export declare function injectJsxInsertionImport(path: NodePath<t.Program>, autoJsxImportSource: string | undefined, legacyGtReactImportSource: boolean): void;
8
8
  //# sourceMappingURL=injectJsxInsertionImport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"injectJsxInsertionImport.d.ts","sourceRoot":"","sources":["../../../src/transform/jsx-insertion/injectJsxInsertionImport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,EACzB,yBAAyB,EAAE,OAAO,GACjC,IAAI,CAaN"}
1
+ {"version":3,"file":"injectJsxInsertionImport.d.ts","sourceRoot":"","sources":["../../../src/transform/jsx-insertion/injectJsxInsertionImport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,EACzB,mBAAmB,EAAE,MAAM,GAAG,SAAS,EACvC,yBAAyB,EAAE,OAAO,GACjC,IAAI,CAeN"}
@@ -9,10 +9,10 @@ _babel_types = require_runtime.__toESM(_babel_types);
9
9
  * Inject `import { GtInternalTranslateJsx, GtInternalVar } from 'gt-react'`
10
10
  * as the first statement in the program.
11
11
  */
12
- function injectJsxInsertionImport(path, legacyGtReactImportSource) {
12
+ function injectJsxInsertionImport(path, autoJsxImportSource, legacyGtReactImportSource) {
13
13
  const tName = "GtInternalTranslateJsx";
14
14
  const varName = "GtInternalVar";
15
- const importDecl = _babel_types.importDeclaration([_babel_types.importSpecifier(_babel_types.identifier(tName), _babel_types.identifier(tName)), _babel_types.importSpecifier(_babel_types.identifier(varName), _babel_types.identifier(varName))], _babel_types.stringLiteral(require_utils_constants_gt_helpers.getGtReactImportSource(legacyGtReactImportSource)));
15
+ const importDecl = _babel_types.importDeclaration([_babel_types.importSpecifier(_babel_types.identifier(tName), _babel_types.identifier(tName)), _babel_types.importSpecifier(_babel_types.identifier(varName), _babel_types.identifier(varName))], _babel_types.stringLiteral(autoJsxImportSource ?? require_utils_constants_gt_helpers.getGtReactImportSource(legacyGtReactImportSource)));
16
16
  path.unshiftContainer("body", importDecl);
17
17
  }
18
18
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"injectJsxInsertionImport.js","names":["t","getGtReactImportSource"],"sources":["../../../src/transform/jsx-insertion/injectJsxInsertionImport.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport { NodePath } from '@babel/traverse';\nimport { GT_COMPONENT_TYPES } from '../../utils/constants/gt/constants';\nimport { getGtReactImportSource } from '../../utils/constants/gt/helpers';\n\n/**\n * Inject `import { GtInternalTranslateJsx, GtInternalVar } from 'gt-react'`\n * as the first statement in the program.\n */\nexport function injectJsxInsertionImport(\n path: NodePath<t.Program>,\n legacyGtReactImportSource: boolean\n): void {\n const tName = GT_COMPONENT_TYPES.GtInternalTranslateJsx;\n const varName = GT_COMPONENT_TYPES.GtInternalVar;\n\n const importDecl = t.importDeclaration(\n [\n t.importSpecifier(t.identifier(tName), t.identifier(tName)),\n t.importSpecifier(t.identifier(varName), t.identifier(varName)),\n ],\n t.stringLiteral(getGtReactImportSource(legacyGtReactImportSource))\n );\n\n path.unshiftContainer('body', importDecl);\n}\n"],"mappings":";;;;;;;;;;;AASA,SAAgB,yBACd,MACA,2BACM;CACN,MAAM,QAAA;CACN,MAAM,UAAA;CAEN,MAAM,aAAaA,aAAE,kBACnB,CACEA,aAAE,gBAAgBA,aAAE,WAAW,MAAM,EAAEA,aAAE,WAAW,MAAM,CAAC,EAC3DA,aAAE,gBAAgBA,aAAE,WAAW,QAAQ,EAAEA,aAAE,WAAW,QAAQ,CAAC,CAChE,EACDA,aAAE,cAAcC,mCAAAA,uBAAuB,0BAA0B,CAAC,CACnE;AAED,MAAK,iBAAiB,QAAQ,WAAW"}
1
+ {"version":3,"file":"injectJsxInsertionImport.js","names":["t","getGtReactImportSource"],"sources":["../../../src/transform/jsx-insertion/injectJsxInsertionImport.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport { NodePath } from '@babel/traverse';\nimport { GT_COMPONENT_TYPES } from '../../utils/constants/gt/constants';\nimport { getGtReactImportSource } from '../../utils/constants/gt/helpers';\n\n/**\n * Inject `import { GtInternalTranslateJsx, GtInternalVar } from 'gt-react'`\n * as the first statement in the program.\n */\nexport function injectJsxInsertionImport(\n path: NodePath<t.Program>,\n autoJsxImportSource: string | undefined,\n legacyGtReactImportSource: boolean\n): void {\n const tName = GT_COMPONENT_TYPES.GtInternalTranslateJsx;\n const varName = GT_COMPONENT_TYPES.GtInternalVar;\n\n const importDecl = t.importDeclaration(\n [\n t.importSpecifier(t.identifier(tName), t.identifier(tName)),\n t.importSpecifier(t.identifier(varName), t.identifier(varName)),\n ],\n t.stringLiteral(\n autoJsxImportSource ?? getGtReactImportSource(legacyGtReactImportSource)\n )\n );\n\n path.unshiftContainer('body', importDecl);\n}\n"],"mappings":";;;;;;;;;;;AASA,SAAgB,yBACd,MACA,qBACA,2BACM;CACN,MAAM,QAAA;CACN,MAAM,UAAA;CAEN,MAAM,aAAaA,aAAE,kBACnB,CACEA,aAAE,gBAAgBA,aAAE,WAAW,MAAM,EAAEA,aAAE,WAAW,MAAM,CAAC,EAC3DA,aAAE,gBAAgBA,aAAE,WAAW,QAAQ,EAAEA,aAAE,WAAW,QAAQ,CAAC,CAChE,EACDA,aAAE,cACA,uBAAuBC,mCAAAA,uBAAuB,0BAA0B,CACzE,CACF;AAED,MAAK,iBAAiB,QAAQ,WAAW"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@generaltranslation/compiler",
3
- "version": "1.3.31",
3
+ "version": "1.3.33",
4
4
  "description": "Universal plugin for compile-time optimization of GT translation components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,6 +14,7 @@
14
14
  "webpack",
15
15
  "vite",
16
16
  "rollup",
17
+ "rspack",
17
18
  "gt-next",
18
19
  "translation",
19
20
  "i18n"
@@ -24,8 +25,8 @@
24
25
  "@babel/traverse": "^7.23.0",
25
26
  "@babel/types": "^7.23.0",
26
27
  "unplugin": "^2.3.10",
27
- "@generaltranslation/format": "0.1.2",
28
- "generaltranslation": "9.0.2"
28
+ "@generaltranslation/format": "0.1.3",
29
+ "generaltranslation": "9.0.4"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@types/babel__core": "^7.20.0",