अपने प्रश्न को पूछें और दस्तावेज़ का सारांश प्राप्त करें, इस पृष्ठ और आपके चुने हुए AI प्रदाता का उपयोग करके
यह दस्तावेज़ पुराना है, आधार संस्करण को इस तिथि पर अपडेट किया गया है 25 जून 2026.
अंग्रेजी दस्तावेज़ पर जाएँसंस्करण इतिहास
- "प्रारंभिक डॉक्यूमेंटेशन"v8.0.021/1/2026
इस पृष्ठ की सामग्री एक AI द्वारा अनुवादित की गई है।
अंग्रेजी में मूल सामग्री के अंतिम संस्करण देखेंIf you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
intlayerPrune Vite प्लगइन दस्तावेज़
intlayerPrune Vite प्लगइन का उपयोग आपकी एप्लिकेशन बंडल से उपयोग में न आने वाले डिक्शनरीज़ को ट्री-शेक और प्रून (हटाने) करने के लिए किया जाता है। यह केवल आवश्यक बहुभाषी सामग्री को ही शामिल करके अंतिम बंडल आकार को कम करने में मदद करता है।
उपयोग
intlayer() के भाग के रूप में (अनुशंसित)
अपने Intlayer कॉन्फ़िगरेशन के माध्यम से pruning सक्षम करें और मुख्य प्लगइन सब कुछ संभालता है:
कोड को क्लिपबोर्ड पर कॉपी करें
// intlayer.config.tsimport { defineConfig } from "intlayer";export default defineConfig({ build: { optimize: true, // prune और minify दोनों को सक्षम करता है },});कोड को क्लिपबोर्ड पर कॉपी करें
// vite.config.tsimport { defineConfig } from "vite";import { intlayer } from "vite-intlayer";export default defineConfig({ plugins: [intlayer()],});स्वतंत्र
यदि आप प्लगइन स्टैक को मैन्युअल रूप से कंपोज़ कर रहे हैं, तो intlayerPrune और intlayerMinify एक PruneContext ऑब्जेक्ट साझा करते हैं जिसे एक बार बनाया जाना चाहिए और दोनों को पारित किया जाना चाहिए:
कोड को क्लिपबोर्ड पर कॉपी करें
// vite.config.tsimport { defineConfig } from "vite";import { intlayerPrune, intlayerMinify } from "vite-intlayer";import { createPruneContext } from "@intlayer/babel";import { getConfiguration } from "@intlayer/config/node";const intlayerConfig = getConfiguration();const pruneContext = createPruneContext();export default defineConfig({ plugins: [ intlayerPrune(intlayerConfig, pruneContext), intlayerMinify(intlayerConfig, pruneContext), // वैकल्पिक, समान संदर्भ से पढ़ता है ],});यह कैसे काम करता है
1. उपयोग विश्लेषण (buildStart)
buildStart के दौरान, intlayerOptimize plugin (जो intlayer() का भी हिस्सा है) build.filesList में सूचीबद्ध प्रत्येक component source file को स्कैन करता है। प्रत्येक useIntlayer('key') या getIntlayer('key') कॉल के लिए, यह रिकॉर्ड करता है कि कौन से fields को exactly एक्सेस किया गया है, जैसे:
कोड को क्लिपबोर्ड पर कॉपी करें
const { title, description } = useIntlayer("myDict");// records: myDict → { title, description }यह किसी भी transform कॉल के चलने से पहले pruneContext.fieldUsageMap बनाता है।
2. JSON pruning (transform, enforce: 'pre')
जब Vite एक compiled dictionary JSON फ़ाइल को प्रोसेस करता है, तो intlayerPrune इसे Vite के built-in JSON → ESM conversion से पहले intercept करता है। यह pruneContext से field-usage map को पढ़ता है और किसी भी content field को हटाता है जो recorded usage set में नहीं है।
दो content shapes समर्थित हैं:
- Static dictionaries —
{ nodeType: "translation", translation: { en: {...}, fr: {...} } }. Fields कोtranslationके अंदर per-locale pruned किया जाता है। - Dynamic (per-locale) dictionaries — flat
{ fieldA: ..., fieldB: ... }. Fields को top level पर pruned किया जाता है।
3. Edge cases
यदि किसी dictionary की content structure को पहचाना नहीं जा सकता (उदाहरण के लिए, एक असामान्य nested shape), तो इसे pruneContext.dictionariesWithEdgeCases में जोड़ा जाता है और अछूता छोड़ दिया जाता है। एक warning लॉग की जाती है। intlayerMinify भी इन dictionaries को छोड़ देता है।
4. Field-rename map
जब pruning सफल होता है, intlayerPrune pruneContext.dictionaryKeyToFieldRenameMap भी लिखता है — मूल field names से short aliases तक एक mapping। intlayerMinify इस map को output JSON में fields को rename करने के लिए पढ़ता है, और intlayerOptimize का Babel rename pass source files में property accesses को अपडेट करता है।
सक्रियण शर्तें
intlayerPrune सक्रिय है केवल जब निम्नलिखित सभी सत्य हों:
- Vite कमांड
buildहै। build.optimizetrueहै (याundefined, जो builds के लिए डिफ़ॉल्ट रूप सेtrueहै)।build.purgeआपके Intlayer config मेंtrueहै।
यह स्वचालित रूप से अक्षम हो जाता है जब editor.enabled true है क्योंकि संपादक को पूर्ण शब्दकोश सामग्री की आवश्यकता होती है।