@intlayer/vue-compiler 7.3.2-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +275 -0
- package/dist/cjs/VueIntlayerCompiler.cjs +245 -0
- package/dist/cjs/VueIntlayerCompiler.cjs.map +1 -0
- package/dist/cjs/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/cjs/index.cjs +12 -0
- package/dist/cjs/vue-intlayer-extract.cjs +174 -0
- package/dist/cjs/vue-intlayer-extract.cjs.map +1 -0
- package/dist/esm/VueIntlayerCompiler.mjs +241 -0
- package/dist/esm/VueIntlayerCompiler.mjs.map +1 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/vue-intlayer-extract.mjs +168 -0
- package/dist/esm/vue-intlayer-extract.mjs.map +1 -0
- package/dist/types/VueIntlayerCompiler.d.ts +101 -0
- package/dist/types/VueIntlayerCompiler.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/vue-intlayer-extract.d.ts +99 -0
- package/dist/types/vue-intlayer-extract.d.ts.map +1 -0
- package/package.json +123 -0
package/README.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://intlayer.org" rel="">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.png" width="60%" alt="Intlayer Logo" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">
|
|
8
|
+
<strong> Intlayer : an Open-source, per-component i18n toolkit with AI-powered translation & CMS.</strong>
|
|
9
|
+
</h1>
|
|
10
|
+
|
|
11
|
+
<br />
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">Docs</a> •
|
|
15
|
+
<a href="https://intlayer.org/doc/environment/nextjs" rel="">Next.js</a> •
|
|
16
|
+
<a href="https://intlayer.org/doc/environment/vite-and-react" rel="">React + Vite</a> •
|
|
17
|
+
<a href="https://intlayer.org/doc/concept/cms" rel="">CMS</a> •
|
|
18
|
+
<a href="https://discord.gg/7uxamYVeCk" rel="noopener noreferrer nofollow">Discord</a>
|
|
19
|
+
</p>
|
|
20
|
+
<p align="center" style="margin-top:15px;">
|
|
21
|
+
<a href="https://www.npmjs.com/package/intlayer" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/v/intlayer?style=for-the-badge&labelColor=FFFFFF&color=000000&logoColor=FFFFFF" alt="npm version" height="24"/></a>
|
|
22
|
+
<a href="https://github.com/aymericzip/intlayer/stargazers" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/stars/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logo=github&logoColor=FFD700" alt="GitHub Stars" height="24"/></a>
|
|
23
|
+
<a href="https://www.npmjs.org/package/intlayer" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/dm/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="monthly downloads" height="24"/></a>
|
|
24
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/LICENSE" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/license/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="license"/></a>
|
|
25
|
+
<a href="https://github.com/aymericzip/intlayer/commits/main" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/last-commit/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="last commit"/>
|
|
26
|
+
</a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">
|
|
32
|
+
<img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
|
|
33
|
+
</a>
|
|
34
|
+
|
|
35
|
+
## What is Intlayer?
|
|
36
|
+
|
|
37
|
+
Most i18n libraries are either too complex, too rigid, or not built for modern frameworks.
|
|
38
|
+
|
|
39
|
+
Intlayer is a **modern i18n solution** for web and mobile apps.
|
|
40
|
+
It’s framework-agnostic, **AI-powered**, and includes a free **CMS & visual editor**.
|
|
41
|
+
|
|
42
|
+
With **per-locale content files**, **TypeScript autocompletion**, **tree-shakable dictionaries**, and **CI/CD integration**, Intlayer makes internationalization **faster, cleaner, and smarter**.
|
|
43
|
+
|
|
44
|
+
## Keys benefits of Intlayer:
|
|
45
|
+
|
|
46
|
+
| Feature | Description |
|
|
47
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
48
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
|
|
49
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.png?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
|
|
50
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
|
|
51
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
52
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
53
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
|
|
54
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/server_component.png?raw=true" alt="Feature" width="700"> | **Consistent Server Component Implementation**<br><br>Perfectly suited for Next.js server components, use the same implementation for both client and server components, no need to pass your `t` function across each server component. <br><br> - [Server Components](https://intlayer.org/doc/environment/nextjs#step-7-utilize-content-in-your-code) |
|
|
55
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
|
|
56
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
57
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
|
|
58
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.png?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
|
|
59
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.png?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
|
|
60
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.png?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
61
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
|
|
62
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
|
|
63
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.png?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
|
|
64
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, and react-intl. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 📦 Installation
|
|
69
|
+
|
|
70
|
+
Start your journey with Intlayer today and experience a smoother, more powerful approach to internationalization.
|
|
71
|
+
|
|
72
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">
|
|
73
|
+
<img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
|
|
74
|
+
</a>
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm install intlayer react-intlayer
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
⚡ Quick Start (Next.js)
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
// intlayer.config.ts
|
|
84
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
85
|
+
|
|
86
|
+
const config: IntlayerConfig = {
|
|
87
|
+
internationalization: {
|
|
88
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
89
|
+
defaultLocale: Locales.ENGLISH,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default config;
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
// app/home.content.ts
|
|
98
|
+
import { t, type Dictionary } from "intlayer";
|
|
99
|
+
|
|
100
|
+
const content = {
|
|
101
|
+
key: "home",
|
|
102
|
+
content: {
|
|
103
|
+
title: t({
|
|
104
|
+
en: "Home",
|
|
105
|
+
fr: "Accueil",
|
|
106
|
+
es: "Inicio",
|
|
107
|
+
}),
|
|
108
|
+
},
|
|
109
|
+
} satisfies Dictionary;
|
|
110
|
+
|
|
111
|
+
export default content;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
// app/page.tsx
|
|
116
|
+
import { useIntlayer } from "react-intlayer";
|
|
117
|
+
|
|
118
|
+
const HomePage = () => {
|
|
119
|
+
const { title } = useIntlayer("home");
|
|
120
|
+
|
|
121
|
+
return <h1>{title}</h1>;
|
|
122
|
+
};
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
<a href="https://intlayer.org/doc/environment/nextjs"> Get the full guide → </a>
|
|
126
|
+
|
|
127
|
+
## 🎥 Live tutorial on YouTube
|
|
128
|
+
|
|
129
|
+
[](https://youtu.be/e_PPG7PTqGU?si=GyU_KpVhr61razRw)
|
|
130
|
+
|
|
131
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">
|
|
132
|
+
<img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
|
|
133
|
+
</a>
|
|
134
|
+
|
|
135
|
+
## Table of Contents
|
|
136
|
+
|
|
137
|
+
Explore our comprehensive documentation to get started with Intlayer and learn how to integrate it into your projects.
|
|
138
|
+
|
|
139
|
+
<details open>
|
|
140
|
+
<summary style="font-size:16px; font-weight:bold;">📘 Get Started</summary>
|
|
141
|
+
<ul>
|
|
142
|
+
<li><a href="https://intlayer.org/doc/why" rel=''>Why Intlayer?</a></li>
|
|
143
|
+
<li><a href="https://intlayer.org/doc" rel=''>Introduction</a></li>
|
|
144
|
+
</ul>
|
|
145
|
+
</details>
|
|
146
|
+
|
|
147
|
+
<details>
|
|
148
|
+
<summary style="font-size:16px; font-weight:bold;">⚙️ Concept</summary>
|
|
149
|
+
<ul>
|
|
150
|
+
<li><a href="https://intlayer.org/doc/concept/how-works-intlayer" rel=''>How Intlayer Works</a></li>
|
|
151
|
+
<li><a href="https://intlayer.org/doc/concept/configuration" rel=''>Configuration</a></li>
|
|
152
|
+
<li><a href="https://intlayer.org/doc/concept/cli" rel=''>Intlayer CLI</a></li>
|
|
153
|
+
<li><a href="https://intlayer.org/doc/concept/editor" rel=''>Intlayer Editor</a></li>
|
|
154
|
+
<li><a href="https://intlayer.org/doc/concept/cms" rel=''>Intlayer CMS</a></li>
|
|
155
|
+
<li><a href="https://intlayer.org/doc/concept/content" rel=''>Dictionary</a>
|
|
156
|
+
<ul>
|
|
157
|
+
<li><a href="https://intlayer.org/doc/concept/content/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
|
|
158
|
+
<li><a href="https://intlayer.org/doc/concept/content/translation" rel=''>Translation</a></li>
|
|
159
|
+
<li><a href="https://intlayer.org/doc/concept/content/enumeration" rel=''>Enumeration</a></li>
|
|
160
|
+
<li><a href="https://intlayer.org/doc/concept/content/condition" rel=''>Condition</a></li>
|
|
161
|
+
<li><a href="https://intlayer.org/doc/concept/content/nesting" rel=''>Nesting</a></li>
|
|
162
|
+
<li><a href="https://intlayer.org/doc/concept/content/markdown" rel=''>Markdown</a></li>
|
|
163
|
+
<li><a href="https://intlayer.org/doc/concept/content/function-fetching" rel=''>Function Fetching</a></li>
|
|
164
|
+
<li><a href="https://intlayer.org/doc/concept/content/insertion" rel=''>Insertion</a></li>
|
|
165
|
+
<li><a href="https://intlayer.org/doc/concept/content/file" rel=''>File</a></li>
|
|
166
|
+
</ul>
|
|
167
|
+
</li>
|
|
168
|
+
</ul>
|
|
169
|
+
</details>
|
|
170
|
+
|
|
171
|
+
<details open>
|
|
172
|
+
<summary style="font-size:16px; font-weight:bold;">🌐 Environment</summary>
|
|
173
|
+
<ul>
|
|
174
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs" rel=''>Intlayer with Next.js 16</a>
|
|
175
|
+
<ul>
|
|
176
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/15" rel=''>Next.js 15</a></li>
|
|
177
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/14" rel=''>Next.js 14 (App Router)</a></li>
|
|
178
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/next-with-Page-Router" rel=''>Next.js Page Router</a></li>
|
|
179
|
+
</ul>
|
|
180
|
+
</li>
|
|
181
|
+
<li><a href="https://intlayer.org/doc/environment/create-react-app" rel=''>React CRA</a></li>
|
|
182
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React</a>
|
|
183
|
+
<ul>
|
|
184
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react/react-router-v7" rel=''>React-router-v7</a></li>
|
|
185
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react/tanstack-start" rel=''>Tanstack start</a></li>
|
|
186
|
+
</ul>
|
|
187
|
+
</li>
|
|
188
|
+
<li><a href="https://intlayer.org/doc/environment/react-native-and-expo" rel=''>React Native</a></li>
|
|
189
|
+
<li><a href="https://intlayer.org/doc/environment/lynx-and-react" rel=''>Lynx + React</a></li>
|
|
190
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-svelte" rel=''>Vite + Svelte</a></li>
|
|
191
|
+
<li><a href="https://intlayer.org/doc/environment/sveltekit" rel=''>SvelteKit</a></li>
|
|
192
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-preact" rel=''>Vite + Preact</a></li>
|
|
193
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
|
|
194
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-nuxt" rel=''>Vite + Nuxt</a></li>
|
|
195
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
|
|
196
|
+
<li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li>
|
|
197
|
+
<li><a href="https://intlayer.org/doc/environment/express" rel=''>Express</a></li>
|
|
198
|
+
<li><a href="https://intlayer.org/doc/environment/nest" rel=''>NestJS</a></li>
|
|
199
|
+
</ul>
|
|
200
|
+
</details>
|
|
201
|
+
|
|
202
|
+
<details>
|
|
203
|
+
<summary style="font-size:16px; font-weight:bold;">📰 Blog</summary>
|
|
204
|
+
<ul>
|
|
205
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/what_is_internationalization.md" rel=''>What is i18n</a></li>
|
|
206
|
+
<li><a href="https://intlayer.org/blog/SEO-and-i18n" rel=''>i18n and SEO</a></li>
|
|
207
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-next-i18next" rel=''>Intlayer and i18next</a></li>
|
|
208
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-react-i18next" rel=''>Intlayer and react-intl</a></li>
|
|
209
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-next-intl" rel=''>Intlayer and next-intl</a></li>
|
|
210
|
+
</ul>
|
|
211
|
+
</details>
|
|
212
|
+
|
|
213
|
+
## 🌐 Readme in other languages
|
|
214
|
+
|
|
215
|
+
<p align="center">
|
|
216
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/readme.md">English</a> •
|
|
217
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/readme.md">简体中文</a> •
|
|
218
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ru/readme.md">Русский</a> •
|
|
219
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/readme.md">日本語</a> •
|
|
220
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/readme.md">Français</a> •
|
|
221
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/readme.md">한국어</a> •
|
|
222
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/readme.md">Español</a> •
|
|
223
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/readme.md">Deutsch</a> •
|
|
224
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/readme.md">العربية</a> •
|
|
225
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/readme.md">Italiano</a> •
|
|
226
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/readme.md">English (UK)</a> •
|
|
227
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/readme.md">Português</a> •
|
|
228
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/readme.md">हिन्दी</a> •
|
|
229
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/tr/readme.md">Türkçe</a>
|
|
230
|
+
</p>
|
|
231
|
+
|
|
232
|
+
## 🤝 Community
|
|
233
|
+
|
|
234
|
+
Intlayer is built with and for the community and we’d love your input!
|
|
235
|
+
|
|
236
|
+
- Have a suggestion? [Open an issue](https://github.com/aymericzip/intlayer/issues)
|
|
237
|
+
- Found a bug or improvement? [Submit a PR](https://github.com/aymericzip/intlayer/pulls)
|
|
238
|
+
- Need help or want to connect? [Join our Discord](https://discord.gg/7uxamYVeCk)
|
|
239
|
+
|
|
240
|
+
You can also follow us on :
|
|
241
|
+
|
|
242
|
+
<div>
|
|
243
|
+
<br/>
|
|
244
|
+
<p align="center">
|
|
245
|
+
<a href="https://discord.gg/528mBV4N" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
246
|
+
src="https://img.shields.io/badge/discord-5865F2.svg?style=for-the-badge&logo=discord&logoColor=white"
|
|
247
|
+
alt="Intlayer Discord" height="30"/></a>
|
|
248
|
+
<a href="https://www.linkedin.com/company/intlayerorg" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
249
|
+
src="https://img.shields.io/badge/linkedin-%231DA1F2.svg?style=for-the-badge&logo=linkedin&logoColor=white"
|
|
250
|
+
alt="Intlayer LinkedIn" height="30"/></a>
|
|
251
|
+
<a href="https://www.instagram.com/intlayer/" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
252
|
+
src="https://img.shields.io/badge/instagram-%23E4405F.svg?style=for-the-badge&logo=Instagram&logoColor=white"
|
|
253
|
+
alt="Intlayer Instagram" height="30"/></a>
|
|
254
|
+
<a href="https://x.com/Intlayer183096" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
255
|
+
src="https://img.shields.io/badge/x-1DA1F2.svg?style=for-the-badge&logo=x&logoColor=white"
|
|
256
|
+
alt="Intlayer X" height="30"/></a>
|
|
257
|
+
<a href="https://www.youtube.com/@intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
258
|
+
src="https://img.shields.io/badge/youtube-FF0000.svg?style=for-the-badge&logo=youtube&logoColor=white"
|
|
259
|
+
alt="Intlayer YouTube" height="30"/></a>
|
|
260
|
+
<a href="https://www.tiktok.com/@intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
261
|
+
src="https://img.shields.io/badge/tiktok-000000.svg?style=for-the-badge&logo=tiktok&logoColor=white"
|
|
262
|
+
alt="Intlayer TikTok" height="30"/></a>
|
|
263
|
+
<br>
|
|
264
|
+
</p>
|
|
265
|
+
</div>
|
|
266
|
+
|
|
267
|
+
### Contribution
|
|
268
|
+
|
|
269
|
+
For more detailed guidelines on contributing to this project, please refer to the [`CONTRIBUTING.md`](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md) file. It contains essential information on our development process, commit message conventions, and release procedures. Your contributions are valuable to us, and we appreciate your efforts in making this project better!
|
|
270
|
+
|
|
271
|
+
### Thank You for the Support
|
|
272
|
+
|
|
273
|
+
If you like Intlayer, give us a ⭐ on GitHub. It helps others discover the project! [See why GitHub Stars matter](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md#why-github-stars-matter-).
|
|
274
|
+
|
|
275
|
+
[](https://star-history.com/#aymericzip/intlayer&Date)
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let node_module = require("node:module");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
let __intlayer_babel = require("@intlayer/babel");
|
|
5
|
+
let __intlayer_chokidar = require("@intlayer/chokidar");
|
|
6
|
+
let __intlayer_config = require("@intlayer/config");
|
|
7
|
+
let fast_glob = require("fast-glob");
|
|
8
|
+
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
9
|
+
|
|
10
|
+
//#region src/VueIntlayerCompiler.ts
|
|
11
|
+
/**
|
|
12
|
+
* Create a VueIntlayerCompiler - A Vite-compatible compiler plugin for Vue with Intlayer
|
|
13
|
+
*
|
|
14
|
+
* Handles Vue Single File Components (SFC) with special handling for:
|
|
15
|
+
* - Script blocks in .vue files
|
|
16
|
+
* - TypeScript in Vue files
|
|
17
|
+
* - Vue-specific transformations
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* // vite.config.ts
|
|
22
|
+
* import { defineConfig } from 'vite';
|
|
23
|
+
* import vue from '@vitejs/plugin-vue';
|
|
24
|
+
* import { vueIntlayerCompiler } from '@intlayer/vue-compiler';
|
|
25
|
+
*
|
|
26
|
+
* export default defineConfig({
|
|
27
|
+
* plugins: [vue(), vueIntlayerCompiler()],
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
const createVueIntlayerCompiler = (options) => {
|
|
32
|
+
let config;
|
|
33
|
+
let logger;
|
|
34
|
+
let projectRoot = "";
|
|
35
|
+
let mode = "dev";
|
|
36
|
+
let hmrVersion = -1;
|
|
37
|
+
const lastSourceTriggeredWrite = 0;
|
|
38
|
+
let filesList = [];
|
|
39
|
+
let babel = null;
|
|
40
|
+
let liveSyncKeys = [];
|
|
41
|
+
const configOptions = options?.configOptions;
|
|
42
|
+
const customCompilerConfig = options?.compilerConfig;
|
|
43
|
+
/**
|
|
44
|
+
* Build the list of files to transform based on configuration patterns
|
|
45
|
+
* Includes Vue-specific patterns
|
|
46
|
+
*/
|
|
47
|
+
const buildFilesList = async () => {
|
|
48
|
+
const { traversePattern } = config.build;
|
|
49
|
+
const { baseDir, mainDir } = config.content;
|
|
50
|
+
const transformPattern = customCompilerConfig?.transformPattern ?? traversePattern;
|
|
51
|
+
const excludePattern = customCompilerConfig?.excludePattern ?? ["**/node_modules/**"];
|
|
52
|
+
const patterns = Array.isArray(transformPattern) ? transformPattern : [transformPattern];
|
|
53
|
+
const vuePatterns = patterns.map((p) => {
|
|
54
|
+
if (p.includes(".vue") || p.includes("{")) return p;
|
|
55
|
+
return p.replace(/\{([^}]+)\}/, (_, exts) => `{${exts},vue}`);
|
|
56
|
+
});
|
|
57
|
+
const excludePatterns = Array.isArray(excludePattern) ? excludePattern : [excludePattern];
|
|
58
|
+
const filesListPattern = fast_glob.default.sync([...new Set([...patterns, ...vuePatterns])], {
|
|
59
|
+
cwd: baseDir,
|
|
60
|
+
ignore: excludePatterns
|
|
61
|
+
}).map((file) => (0, node_path.join)(baseDir, file));
|
|
62
|
+
const dictionariesEntryPath = (0, node_path.join)(mainDir, "dictionaries.mjs");
|
|
63
|
+
const unmergedDictionariesEntryPath = (0, node_path.join)(mainDir, "unmerged_dictionaries.mjs");
|
|
64
|
+
filesList = [
|
|
65
|
+
...filesListPattern,
|
|
66
|
+
dictionariesEntryPath,
|
|
67
|
+
unmergedDictionariesEntryPath
|
|
68
|
+
];
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Load dictionary keys that have live sync enabled
|
|
72
|
+
*/
|
|
73
|
+
const loadLiveSyncKeys = async () => {
|
|
74
|
+
try {
|
|
75
|
+
const { getDictionaries } = await import("@intlayer/dictionaries-entry");
|
|
76
|
+
const dictionaries = getDictionaries();
|
|
77
|
+
liveSyncKeys = Object.values(dictionaries).filter((dictionary) => dictionary.live).map((dictionary) => dictionary.key);
|
|
78
|
+
} catch {
|
|
79
|
+
liveSyncKeys = [];
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Initialize the compiler with the given mode
|
|
84
|
+
*/
|
|
85
|
+
const init = async (compilerMode) => {
|
|
86
|
+
mode = compilerMode;
|
|
87
|
+
config = (0, __intlayer_config.getConfiguration)(configOptions);
|
|
88
|
+
logger = (0, __intlayer_config.getAppLogger)(config);
|
|
89
|
+
try {
|
|
90
|
+
babel = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("@babel/core");
|
|
91
|
+
} catch {
|
|
92
|
+
logger("Failed to load @babel/core. Transformation will be disabled.", { level: "warn" });
|
|
93
|
+
}
|
|
94
|
+
await buildFilesList();
|
|
95
|
+
await loadLiveSyncKeys();
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Vite hook: configResolved
|
|
99
|
+
*/
|
|
100
|
+
const configResolved = async (viteConfig) => {
|
|
101
|
+
const compilerMode = viteConfig.env?.DEV ? "dev" : "build";
|
|
102
|
+
projectRoot = viteConfig.root;
|
|
103
|
+
await init(compilerMode);
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Prepare intlayer dictionaries and types
|
|
107
|
+
*/
|
|
108
|
+
const buildStart = async () => {
|
|
109
|
+
const isBuild = mode === "build";
|
|
110
|
+
await (0, __intlayer_chokidar.prepareIntlayer)(config, {
|
|
111
|
+
clean: isBuild,
|
|
112
|
+
cacheTimeoutMs: isBuild ? 1e3 * 30 : 1e3 * 60 * 60
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Configure the dev server with file watching
|
|
117
|
+
*/
|
|
118
|
+
const configureServer = async () => {
|
|
119
|
+
if (config.content.watch) (0, __intlayer_chokidar.watch)({ configuration: config });
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Handle HMR for content changes
|
|
123
|
+
*/
|
|
124
|
+
const handleHotUpdate = async (ctx) => {
|
|
125
|
+
const { file, server } = ctx;
|
|
126
|
+
if (!config.content.watchedFilesPatternWithPath.some((pattern) => {
|
|
127
|
+
return new RegExp(pattern.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*")).test(file);
|
|
128
|
+
})) {
|
|
129
|
+
const dictionariesDir = config.content.dictionariesDir;
|
|
130
|
+
if (file.startsWith(dictionariesDir)) return [];
|
|
131
|
+
hmrVersion++;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (!(performance.now() - lastSourceTriggeredWrite < 1e3)) {
|
|
135
|
+
server.ws.send({ type: "full-reload" });
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Transform handler with Vue-specific handling
|
|
141
|
+
*/
|
|
142
|
+
const transformHandler = async (code, id, _options) => {
|
|
143
|
+
if (!babel) return null;
|
|
144
|
+
const { optimize, importMode } = config.build;
|
|
145
|
+
if (!optimize && mode !== "build") return null;
|
|
146
|
+
const { dictionariesDir, dynamicDictionariesDir, unmergedDictionariesDir, fetchDictionariesDir, mainDir } = config.content;
|
|
147
|
+
/**
|
|
148
|
+
* Handle Vue SFC virtual modules
|
|
149
|
+
* Transform paths like:
|
|
150
|
+
* - .../Component.vue?vue&type=script&setup=true&lang.ts
|
|
151
|
+
* Into:
|
|
152
|
+
* - .../Component.vue
|
|
153
|
+
*/
|
|
154
|
+
const filename = id.split("?", 1)[0];
|
|
155
|
+
const checkFilename = id.includes("?vue&type=script") ? filename : filename;
|
|
156
|
+
if (!filesList.includes(checkFilename)) {
|
|
157
|
+
const baseVueFile = filename.endsWith(".vue") ? filename : null;
|
|
158
|
+
if (!baseVueFile || !filesList.some((f) => f === baseVueFile || f.startsWith(baseVueFile))) return null;
|
|
159
|
+
}
|
|
160
|
+
const dictionariesEntryPath = (0, node_path.join)(mainDir, "dictionaries.mjs");
|
|
161
|
+
const unmergedDictionariesEntryPath = (0, node_path.join)(mainDir, "unmerged_dictionaries.mjs");
|
|
162
|
+
const dynamicDictionariesEntryPath = (0, node_path.join)(mainDir, "dynamic_dictionaries.mjs");
|
|
163
|
+
try {
|
|
164
|
+
const result = babel.transformSync(code, {
|
|
165
|
+
filename,
|
|
166
|
+
plugins: [[__intlayer_babel.intlayerOptimizeBabelPlugin, {
|
|
167
|
+
dictionariesDir,
|
|
168
|
+
dictionariesEntryPath,
|
|
169
|
+
unmergedDictionariesEntryPath,
|
|
170
|
+
unmergedDictionariesDir,
|
|
171
|
+
dynamicDictionariesDir,
|
|
172
|
+
dynamicDictionariesEntryPath,
|
|
173
|
+
fetchDictionariesDir,
|
|
174
|
+
importMode,
|
|
175
|
+
filesList,
|
|
176
|
+
replaceDictionaryEntry: true,
|
|
177
|
+
liveSyncKeys
|
|
178
|
+
}]],
|
|
179
|
+
parserOpts: {
|
|
180
|
+
sourceType: "module",
|
|
181
|
+
allowImportExportEverywhere: true,
|
|
182
|
+
plugins: [
|
|
183
|
+
"typescript",
|
|
184
|
+
"jsx",
|
|
185
|
+
"decorators-legacy",
|
|
186
|
+
"classProperties",
|
|
187
|
+
"objectRestSpread",
|
|
188
|
+
"asyncGenerators",
|
|
189
|
+
"functionBind",
|
|
190
|
+
"exportDefaultFrom",
|
|
191
|
+
"exportNamespaceFrom",
|
|
192
|
+
"dynamicImport",
|
|
193
|
+
"nullishCoalescingOperator",
|
|
194
|
+
"optionalChaining"
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
if (result?.code) return {
|
|
199
|
+
code: result.code,
|
|
200
|
+
map: result.map
|
|
201
|
+
};
|
|
202
|
+
} catch (error) {
|
|
203
|
+
logger(`Failed to transform Vue file ${(0, node_path.relative)(projectRoot, filename)}: ${error}`, { level: "error" });
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Apply hook for determining when plugin should be active
|
|
209
|
+
*/
|
|
210
|
+
const apply = (_config, env) => {
|
|
211
|
+
const { optimize } = config?.build ?? {};
|
|
212
|
+
const isEnabled = customCompilerConfig?.enabled ?? true;
|
|
213
|
+
const isBuild = env.command === "build";
|
|
214
|
+
return isEnabled && (isBuild ? optimize ?? true : optimize ?? false);
|
|
215
|
+
};
|
|
216
|
+
return {
|
|
217
|
+
name: "vue-intlayer-compiler",
|
|
218
|
+
enforce: "post",
|
|
219
|
+
configResolved,
|
|
220
|
+
buildStart,
|
|
221
|
+
configureServer,
|
|
222
|
+
handleHotUpdate,
|
|
223
|
+
transform: {
|
|
224
|
+
order: "post",
|
|
225
|
+
handler: transformHandler
|
|
226
|
+
},
|
|
227
|
+
apply: (_viteConfig, env) => {
|
|
228
|
+
if (!config) config = (0, __intlayer_config.getConfiguration)(configOptions);
|
|
229
|
+
return apply(_viteConfig, env);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Factory function for creating a Vite plugin
|
|
235
|
+
*/
|
|
236
|
+
const vueIntlayerCompiler = (options) => {
|
|
237
|
+
return createVueIntlayerCompiler(options);
|
|
238
|
+
};
|
|
239
|
+
const VueIntlayerCompiler = createVueIntlayerCompiler;
|
|
240
|
+
|
|
241
|
+
//#endregion
|
|
242
|
+
exports.VueIntlayerCompiler = VueIntlayerCompiler;
|
|
243
|
+
exports.createVueIntlayerCompiler = createVueIntlayerCompiler;
|
|
244
|
+
exports.vueIntlayerCompiler = vueIntlayerCompiler;
|
|
245
|
+
//# sourceMappingURL=VueIntlayerCompiler.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VueIntlayerCompiler.cjs","names":["config: IntlayerConfig","logger: ReturnType<typeof getAppLogger>","mode: CompilerMode","filesList: string[]","babel: typeof import('@babel/core') | null","liveSyncKeys: string[]","fg","compilerMode: CompilerMode","intlayerOptimizeBabelPlugin"],"sources":["../../src/VueIntlayerCompiler.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { join, relative } from 'node:path';\nimport { intlayerOptimizeBabelPlugin } from '@intlayer/babel';\nimport { watch as chokidarWatch, prepareIntlayer } from '@intlayer/chokidar';\nimport {\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { CompilerConfig, IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * Mode of the compiler\n */\nexport type CompilerMode = 'dev' | 'build';\n\n/**\n * Context for hot update handling\n */\nexport type HotUpdateContext = {\n file: string;\n server: {\n ws: { send: (message: { type: string }) => void };\n moduleGraph: {\n getModulesByFile: (file: string) => Set<unknown> | null | undefined;\n invalidateModule: (\n module: unknown,\n seen: Set<unknown>,\n timestamp: number,\n isHmr: boolean\n ) => void;\n };\n };\n timestamp: number;\n};\n\n/**\n * Transform result from the compiler\n */\nexport type TransformResult = {\n code?: string;\n map?: unknown;\n} | null;\n\n/**\n * Options for initializing the Vue compiler\n */\nexport type VueIntlayerCompilerOptions = {\n /**\n * Configuration options for getting the intlayer configuration\n */\n configOptions?: GetConfigurationOptions;\n\n /**\n * Custom compiler configuration to override defaults\n */\n compilerConfig?: Partial<CompilerConfig>;\n};\n\n/**\n * Vite plugin object returned by the compiler\n */\nexport type VueIntlayerVitePlugin = {\n name: string;\n enforce: 'pre' | 'post';\n configResolved: (config: {\n env?: { DEV?: boolean };\n root: string;\n }) => Promise<void>;\n buildStart: () => Promise<void>;\n configureServer: () => Promise<void>;\n handleHotUpdate: (ctx: HotUpdateContext) => Promise<unknown[] | undefined>;\n transform: {\n order: 'pre' | 'post';\n handler: (\n code: string,\n id: string,\n options?: { ssr?: boolean }\n ) => Promise<TransformResult>;\n };\n apply: (config: unknown, env: { command: string }) => boolean;\n};\n\n/**\n * Create a VueIntlayerCompiler - A Vite-compatible compiler plugin for Vue with Intlayer\n *\n * Handles Vue Single File Components (SFC) with special handling for:\n * - Script blocks in .vue files\n * - TypeScript in Vue files\n * - Vue-specific transformations\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import vue from '@vitejs/plugin-vue';\n * import { vueIntlayerCompiler } from '@intlayer/vue-compiler';\n *\n * export default defineConfig({\n * plugins: [vue(), vueIntlayerCompiler()],\n * });\n * ```\n */\nexport const createVueIntlayerCompiler = (\n options?: VueIntlayerCompilerOptions\n): VueIntlayerVitePlugin => {\n // Private state\n let config: IntlayerConfig;\n let logger: ReturnType<typeof getAppLogger>;\n let projectRoot = '';\n let mode: CompilerMode = 'dev';\n let hmrVersion = -1;\n const lastSourceTriggeredWrite = 0;\n let filesList: string[] = [];\n // @ts-expect-error - @babel/core is a peer dependency\n let babel: typeof import('@babel/core') | null = null;\n let liveSyncKeys: string[] = [];\n\n const configOptions = options?.configOptions;\n const customCompilerConfig = options?.compilerConfig;\n\n /**\n * Build the list of files to transform based on configuration patterns\n * Includes Vue-specific patterns\n */\n const buildFilesList = async (): Promise<void> => {\n const { traversePattern } = config.build;\n const { baseDir, mainDir } = config.content;\n\n const transformPattern =\n customCompilerConfig?.transformPattern ?? traversePattern;\n const excludePattern = customCompilerConfig?.excludePattern ?? [\n '**/node_modules/**',\n ];\n\n // Add Vue file patterns\n const patterns = Array.isArray(transformPattern)\n ? transformPattern\n : [transformPattern];\n const vuePatterns = patterns.map((p) => {\n // Ensure Vue files are included\n if (p.includes('.vue') || p.includes('{')) {\n return p;\n }\n // Add .vue extension to patterns\n return p.replace(/\\{([^}]+)\\}/, (_, exts) => `{${exts},vue}`);\n });\n\n const excludePatterns = Array.isArray(excludePattern)\n ? excludePattern\n : [excludePattern];\n\n const filesListPattern = fg\n .sync([...new Set([...patterns, ...vuePatterns])], {\n cwd: baseDir,\n ignore: excludePatterns,\n })\n .map((file) => join(baseDir, file));\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n\n filesList = [\n ...filesListPattern,\n dictionariesEntryPath,\n unmergedDictionariesEntryPath,\n ];\n };\n\n /**\n * Load dictionary keys that have live sync enabled\n */\n const loadLiveSyncKeys = async (): Promise<void> => {\n try {\n const { getDictionaries } = await import('@intlayer/dictionaries-entry');\n const dictionaries = getDictionaries() as Record<\n string,\n { live?: boolean; key: string }\n >;\n liveSyncKeys = Object.values(dictionaries)\n .filter((dictionary) => dictionary.live)\n .map((dictionary) => dictionary.key);\n } catch {\n liveSyncKeys = [];\n }\n };\n\n /**\n * Initialize the compiler with the given mode\n */\n const init = async (compilerMode: CompilerMode): Promise<void> => {\n mode = compilerMode;\n config = getConfiguration(configOptions);\n logger = getAppLogger(config);\n\n // Load Babel dynamically\n try {\n const localRequire = createRequire(import.meta.url);\n babel = localRequire('@babel/core');\n } catch {\n logger('Failed to load @babel/core. Transformation will be disabled.', {\n level: 'warn',\n });\n }\n\n // Build files list for transformation\n await buildFilesList();\n\n // Load live sync keys\n await loadLiveSyncKeys();\n };\n\n /**\n * Vite hook: configResolved\n */\n const configResolved = async (viteConfig: {\n env?: { DEV?: boolean };\n root: string;\n }): Promise<void> => {\n const compilerMode: CompilerMode = viteConfig.env?.DEV ? 'dev' : 'build';\n projectRoot = viteConfig.root;\n await init(compilerMode);\n };\n\n /**\n * Prepare intlayer dictionaries and types\n */\n const buildStart = async (): Promise<void> => {\n const isBuild = mode === 'build';\n\n await prepareIntlayer(config, {\n clean: isBuild,\n cacheTimeoutMs: isBuild ? 1000 * 30 : 1000 * 60 * 60,\n });\n };\n\n /**\n * Configure the dev server with file watching\n */\n const configureServer = async (): Promise<void> => {\n if (config.content.watch) {\n chokidarWatch({ configuration: config });\n }\n };\n\n /**\n * Handle HMR for content changes\n */\n const handleHotUpdate = async (\n ctx: HotUpdateContext\n ): Promise<unknown[] | undefined> => {\n const { file, server } = ctx;\n\n // Check if this is a content declaration file\n const isContentFile = config.content.watchedFilesPatternWithPath.some(\n (pattern: string) => {\n const regex = new RegExp(\n pattern.replace(/\\*\\*/g, '.*').replace(/\\*/g, '[^/]*')\n );\n return regex.test(file);\n }\n );\n\n if (!isContentFile) {\n const dictionariesDir = config.content.dictionariesDir;\n if (file.startsWith(dictionariesDir)) {\n return [];\n }\n hmrVersion++;\n return undefined;\n }\n\n const sourceTriggered = performance.now() - lastSourceTriggeredWrite < 1000;\n\n if (!sourceTriggered) {\n server.ws.send({ type: 'full-reload' });\n return [];\n }\n\n return undefined;\n };\n\n /**\n * Transform handler with Vue-specific handling\n */\n const transformHandler = async (\n code: string,\n id: string,\n _options?: { ssr?: boolean }\n ): Promise<TransformResult> => {\n if (!babel) {\n return null;\n }\n\n const { optimize, importMode } = config.build;\n\n if (!optimize && mode !== 'build') {\n return null;\n }\n\n const {\n dictionariesDir,\n dynamicDictionariesDir,\n unmergedDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n } = config.content;\n\n /**\n * Handle Vue SFC virtual modules\n * Transform paths like:\n * - .../Component.vue?vue&type=script&setup=true&lang.ts\n * Into:\n * - .../Component.vue\n */\n const filename = id.split('?', 1)[0];\n\n // Check if this file should be transformed\n // For Vue files, also check the base .vue file\n const isVueVirtualModule = id.includes('?vue&type=script');\n const checkFilename = isVueVirtualModule ? filename : filename;\n\n if (!filesList.includes(checkFilename)) {\n // Also check without the virtual module query\n const baseVueFile = filename.endsWith('.vue') ? filename : null;\n if (\n !baseVueFile ||\n !filesList.some((f) => f === baseVueFile || f.startsWith(baseVueFile))\n ) {\n return null;\n }\n }\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n try {\n const result = babel.transformSync(code, {\n filename,\n plugins: [\n [\n intlayerOptimizeBabelPlugin,\n {\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesEntryPath,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n importMode,\n filesList,\n replaceDictionaryEntry: true,\n liveSyncKeys,\n },\n ],\n ],\n parserOpts: {\n sourceType: 'module',\n allowImportExportEverywhere: true,\n plugins: [\n 'typescript',\n 'jsx',\n 'decorators-legacy',\n 'classProperties',\n 'objectRestSpread',\n 'asyncGenerators',\n 'functionBind',\n 'exportDefaultFrom',\n 'exportNamespaceFrom',\n 'dynamicImport',\n 'nullishCoalescingOperator',\n 'optionalChaining',\n ],\n },\n });\n\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n } catch (error) {\n logger(\n `Failed to transform Vue file ${relative(projectRoot, filename)}: ${error}`,\n {\n level: 'error',\n }\n );\n }\n\n return null;\n };\n\n /**\n * Apply hook for determining when plugin should be active\n */\n const apply = (_config: unknown, env: { command: string }): boolean => {\n const { optimize } = config?.build ?? {};\n const isEnabled = customCompilerConfig?.enabled ?? true;\n const isBuild = env.command === 'build';\n\n return isEnabled && (isBuild ? (optimize ?? true) : (optimize ?? false));\n };\n\n return {\n name: 'vue-intlayer-compiler',\n enforce: 'post', // Run after Vue plugin\n configResolved,\n buildStart,\n configureServer,\n handleHotUpdate,\n transform: {\n order: 'post', // Run after Vue plugin transformation\n handler: transformHandler,\n },\n apply: (_viteConfig: unknown, env: { command: string }) => {\n if (!config) {\n config = getConfiguration(configOptions);\n }\n return apply(_viteConfig, env);\n },\n };\n};\n\n/**\n * Factory function for creating a Vite plugin\n */\nexport const vueIntlayerCompiler = (\n options?: VueIntlayerCompilerOptions\n): VueIntlayerVitePlugin => {\n return createVueIntlayerCompiler(options);\n};\n\n// Legacy export for backwards compatibility\nexport const VueIntlayerCompiler = createVueIntlayerCompiler;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const require_VueIntlayerCompiler = require('./VueIntlayerCompiler.cjs');
|
|
2
|
+
const require_vue_intlayer_extract = require('./vue-intlayer-extract.cjs');
|
|
3
|
+
|
|
4
|
+
exports.ATTRIBUTES_TO_EXTRACT = require_vue_intlayer_extract.ATTRIBUTES_TO_EXTRACT;
|
|
5
|
+
exports.VueIntlayerCompiler = require_VueIntlayerCompiler.VueIntlayerCompiler;
|
|
6
|
+
exports.createVueIntlayerCompiler = require_VueIntlayerCompiler.createVueIntlayerCompiler;
|
|
7
|
+
exports.defaultShouldExtract = require_vue_intlayer_extract.defaultShouldExtract;
|
|
8
|
+
exports.extractDictionaryKeyFromPath = require_vue_intlayer_extract.extractDictionaryKeyFromPath;
|
|
9
|
+
exports.generateKey = require_vue_intlayer_extract.generateKey;
|
|
10
|
+
exports.intlayerVueExtract = require_vue_intlayer_extract.intlayerVueExtract;
|
|
11
|
+
exports.shouldProcessFile = require_vue_intlayer_extract.shouldProcessFile;
|
|
12
|
+
exports.vueIntlayerCompiler = require_VueIntlayerCompiler.vueIntlayerCompiler;
|