1import{_ as s,i as a,o as t,ak as e}from"./chunks/framework.Da91f1N-.js";const g=JSON.parse('{"title":"Import Optimization","description":"","frontmatter":{},"headers":[],"relativePath":"features/import-optimization.md","filePath":"features/import-optimization.md"}'),n={name:"features/import-optimization.md"};function l(p,i,r,h,o,k){return t(),a("div",null,i[0]||(i[0]=[e(`<h1 id="import-optimization" tabindex="-1">Import Optimization <a class="header-anchor" href="#import-optimization" aria-label="Permalink to "Import Optimization"">â</a></h1><p>dtsx provides sophisticated import optimization capabilities to ensure your declaration files are clean and efficient.</p><h2 id="smart-import-tracking" tabindex="-1">Smart Import Tracking <a class="header-anchor" href="#smart-import-tracking" aria-label="Permalink to "Smart Import Tracking"">â</a></h2><p>dtsx tracks imports in several ways:</p><ul><li>Type imports (<code>import type</code>)</li><li>Value imports (<code>import</code>)</li><li>Mixed imports</li><li>Default imports</li><li>Namespace imports</li></ul><h2 id="import-optimization-strategies" tabindex="-1">Import Optimization Strategies <a class="header-anchor" href="#import-optimization-strategies" aria-label="Permalink to "Import Optimization Strategies"">â</a></h2><h3 id="type-only-imports" tabindex="-1">Type-Only Imports <a class="header-anchor" href="#type-only-imports" aria-label="Permalink to "Type-Only Imports"">â</a></h3><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Before optimization</span></span> 2<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { User, UserRole, processUser } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> './types'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span> 3<span class="line"></span> 4<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// After optimization</span></span> 5<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> type</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { User, UserRole } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> './types'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span> 6<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { processUser } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> './types'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span></code></pre></div><h3 id="unused-import-removal" tabindex="-1">Unused Import Removal <a class="header-anchor" href="#unused-import-removal" aria-label="Permalink to "Unused Import Removal"">â</a></h3><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Before optimization</span></span> 7<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { User, Role, Permission } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> './types'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span> 8<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Only User is used in the file</span></span> 9<span class="line"></span> 10<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// After optimization</span></span> 11<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">
11import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { User } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> './types'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span></code></pre></div><h3 id="import-consolidation" tabindex="-1">Import Consolidation <a class="header-anchor" href="#import-consolidation" aria-label="Permalink to "Import Consolidation"">â</a></h3><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Before optimization</span></span> 12<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { User } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> './types'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span> 13<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { Role } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> './types'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span> 14<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { Permission } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> './types'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span> 15<span class="line"></span> 16<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// After optimization</span></span> 17<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { User, Role, Permission } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> './types'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span></code></pre></div><h2 id="import-tracking-features" tabindex="-1">Import Tracking Features <a class="header-anchor" href="#import-tracking-features" aria-label="Permalink to "Import Tracking Features"">â</a></h2><h3 id="type-usage-tracking" tabindex="-1">Type Usage Tracking <a class="header-anchor" href="#type-usage-tracking" aria-label="Permalink to "Type Usage Tracking"">â</a></h3><ul><li>Tracks all type references</li><li>Maintains type relationships</li><li>Handles type aliases</li><li>Supports type augmentation</li></ul><h3 id="value-usage-tracking" tabindex="-1">Value Usage Tracking <a class="header-anchor" href="#value-usage-tracking" aria-label="Permalink to "Value Usage Tracking"">â</a></h3><ul><li>Tracks function calls</li><li>Tracks variable usage</li><li>Handles destructuring</li><li>Supports namespace usage</li></ul><h2 id="optimization-rules" tabindex="-1">Optimization Rules <a class="header-anchor" href="#optimization-rules" aria-label="Permalink to "Optimization Rules"">â</a></h2><ol><li><strong>Type-Only Rule</strong>: Imports used only as types are converted to type imports</li><li><strong>Unused Removal Rule</strong>: Unused imports are removed</li><li><strong>Consolidation Rule</strong>: Multiple imports from the same module are consolidated</li><li><strong>Namespace Rule</strong>: Namespace imports are optimized based on usage</li><li><strong>Default Import Rule</strong>: Default imports are handled appropriately</li></ol><h2 id="configuration-options" tabindex="-1">Configuration Options <a class="header-anchor" href="#configuration-options" aria-label="Permalink to "Configuration Options"">â</a></h2><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span>
17<pre class="shiki shiki-themes github-light github-dark vp-code" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">interface</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ImportOptimizationConfig</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span> 18<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Enable/disable import optimization</span></span> 19<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> optimizeImports</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> boolean</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span> 20<span class="line"></span> 21<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Keep certain imports even if unused</span></span> 22<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> preserveImports</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[];</span></span> 23<span class="line"></span> 24<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Custom import transformation rules</span></span> 25<span class="line"><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> transformRules</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ImportTransformRule</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[];</span></span> 26<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h2 id="best-practices" tabindex="-1">Best Practices <a class="header-anchor" href="#best-practices" aria-label="Permalink to "Best Practices"">â</a></h2><ol><li>Use type imports for type-only usage</li><li>Avoid mixing type and value imports when possible</li><li>Use namespace imports for large modules</li><li>Keep related imports together</li><li>Use consistent import styles</li></ol>`,23)]))}const m=s(n,[["render",l]]);export{g as __pageData,m as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.