@generaltranslation/compiler 1.1.14 → 1.1.16

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.
Files changed (2) hide show
  1. package/README.md +16 -107
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,59 +1,20 @@
1
- # GT Compiler
1
+ <p align="center">
2
+ <a href="https://generaltranslation.com/docs">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://generaltranslation.com/gt-logo-dark.svg">
5
+ <source media="(prefers-color-scheme: light)" srcset="https://generaltranslation.com/gt-logo-light.svg">
6
+ <img alt="General Translation" src="https://generaltranslation.com/gt-logo-light.svg" width="100" height="100">
7
+ </picture>
8
+ </a>
9
+ </p>
2
10
 
3
- A universal plugin for compile-time optimization of GT translation components that works across webpack, Vite, Rollup, and other bundlers.
11
+ <p align="center">
12
+ <a href="https://generaltranslation.com/docs"><strong>Documentation</strong></a> · <a href="https://github.com/generaltranslation/gt/issues">Report Bug</a>
13
+ </p>
4
14
 
5
- ## What It Does
15
+ # @generaltranslation/compiler
6
16
 
7
- This plugin performs two main functions during the build process:
8
-
9
- ### 1. Dynamic Content Detection
10
-
11
- Detects and prevents invalid usage patterns in GT translation components:
12
-
13
- #### JSX Component Violations
14
-
15
- ```jsx
16
- // ❌ Unwrapped expressions
17
- <T>Hello {userName}!</T>
18
- <T>You have {count} {count === 1 ? 'item' : 'items'}</T>
19
- <T>{greeting} world</T>
20
-
21
- // ❌ Mixed content
22
- <T>Price: <span>{price}</span></T>
23
-
24
- // ✅ Correct usage
25
- <T>Hello <Var>{userName}</Var>!</T>
26
- <T>You have <Num>{count}</Num> <Plural n={count} one="item" other="items" />!</T>
27
- <T><Var>{greeting}</Var> world</T>
28
- ```
29
-
30
- #### Function Call Violations
31
-
32
- ```js
33
- // ❌ Template literals
34
- const msg = gt(`Hello ${name}!`);
35
- const error = gt(`Error: ${code} - ${message}`);
36
-
37
- // ❌ String concatenation
38
- const welcome = gt('Welcome ' + username);
39
- const path = gt('Go to ' + destination + ' page');
40
-
41
- // ❌ Dynamic expressions
42
- const dynamic = gt(isError ? errorMsg : successMsg);
43
-
44
- // ✅ Correct usage
45
- const msg = gt('Hello world!');
46
- const welcome = gt('Welcome to our app');
47
- const error = gt('Something went wrong', { $context: 'error' });
48
- ```
49
-
50
- ### 2. Compile-Time Hash Generation
51
-
52
- Pre-computes translation keys at build time for better performance:
53
-
54
- - Generates stable hashes for `<T>` components and `gt()` function calls
55
- - Injects hash attributes (`_hash`) into components
56
- - Creates content arrays for translation functions
17
+ Build plugin for compile-time optimization of GT translation components. Works with webpack, Vite, Rollup, and esbuild.
57
18
 
58
19
  ## Installation
59
20
 
@@ -63,67 +24,15 @@ npm install @generaltranslation/compiler
63
24
 
64
25
  ## Usage
65
26
 
66
- ### With Next.js (Automatic)
67
-
68
- If you're using `gt-next`, the plugin is automatically configured for you. No additional setup required!
69
-
70
- ### With Webpack (Manual)
71
-
72
- ```js
73
- // webpack.config.js
74
- const { webpack: gtCompiler } = require('@generaltranslation/compiler');
75
-
76
- module.exports = {
77
- plugins: [gtCompiler()],
78
- };
79
- ```
80
-
81
- ### With Vite
27
+ If you're using `gt-next`, the plugin is configured automatically. For manual setup:
82
28
 
83
29
  ```js
84
30
  // vite.config.js
85
- import { defineConfig } from 'vite';
86
31
  import { vite as gtCompiler } from '@generaltranslation/compiler';
87
32
 
88
- export default defineConfig({
89
- plugins: [gtCompiler()],
90
- });
91
- ```
92
-
93
- ### With Rollup
94
-
95
- ```js
96
- // rollup.config.js
97
- import { rollup as gtCompiler } from '@generaltranslation/compiler';
98
-
99
33
  export default {
100
34
  plugins: [gtCompiler()],
101
35
  };
102
36
  ```
103
37
 
104
- ### With esbuild
105
-
106
- ```js
107
- // esbuild.config.js
108
- const { build } = require('esbuild');
109
- const { esbuild: gtCompiler } = require('@generaltranslation/compiler');
110
-
111
- build({
112
- plugins: [gtCompiler()],
113
- });
114
- ```
115
-
116
- ## Configuration Options
117
-
118
- ```typescript
119
- interface GTCompilerOptions {
120
- /** Control warning output */
121
- logLevel?: 'silent' | 'error' | 'warn' | 'info' | 'debug';
122
-
123
- /** Enable hash generation at compile time */
124
- compileTimeHash?: boolean;
125
-
126
- /** Skip dynamic content validation */
127
- disableBuildChecks?: boolean;
128
- }
129
- ```
38
+ See the [full documentation](https://generaltranslation.com/docs) for guides and API reference.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@generaltranslation/compiler",
3
- "version": "1.1.14",
3
+ "version": "1.1.16",
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",
@@ -24,7 +24,7 @@
24
24
  "@babel/traverse": "^7.23.0",
25
25
  "@babel/types": "^7.23.0",
26
26
  "unplugin": "^2.3.10",
27
- "generaltranslation": "8.1.5"
27
+ "generaltranslation": "8.1.7"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/babel__core": "^7.20.0",