|
| Language | Extensions | Supported Patterns |
|---|---|---|
| JavaScript | .js, .jsx, .mjs, .cjs |
React.lazy(), dynamic(), loadable(), import() |
| TypeScript | .ts, .tsx, .mts, .cts |
React.lazy(), dynamic(), loadable(), import(), with types |
✅ Detection Examples
// ✅ All of these patterns are detected:
// React lazy loading
const LazyComponent = React.lazy(() => import('./components/LazyComponent'));
const AnotherLazy = lazy(() => import('./components/AnotherComponent'));
// Next.js dynamic imports
const DynamicComponent = dynamic(() => import('./components/Button'));
const ConditionalComponent = dynamic(() => import('./components/Modal'), {
ssr: false
});
// @loadable/component imports
import loadable from '@loadable/component';
const LoadableComponent = loadable(() => import('./components/LoadableComponent'));
const LoadableWithOptions = loadable(() => import('./components/Advanced'), {
fallback: <div>Loading...</div>
});
// Variable declarations with lazy/dynamic/loadable
let MyLazyComp = React.lazy(() => import('./MyComponent'));
var MyDynamicComp = dynamic(() => import('./MyComponent'));
const MyLoadableComp = loadable(() => import('./MyComponent'));
const MyComponent = lazy(() => import('./path/to/MyComponent'));
// TypeScript with types
const TypedComponent: React.ComponentType = lazy(() => import('./TypedComponent'));
const TypedLoadable: LoadableComponent<any> = loadable(() => import('./TypedLoadable'));
const WithProps = dynamic<Props>(() => import('./WithProps'), { ssr: false });
// Wrappers used as object values
export const Views = {
card: dynamic(() => import('./views/card')),
[Kind.Spread]: dynamic(() => import('./views/spread')),
};
// Named exports picked from the module
const Chart = lazy(() => import('./charts').then((m) => ({ default: m.Chart })));
// Plain import() calls
const { loadUser } = await import('./api/user');
const barrel = await import('./widgets/banner');
barrel.default;
No TypeScript or config file is required: relative imports always resolve. Aliases are read from:
tsconfig.json/jsconfig.json:paths(longest match wins),baseUrlandextendschains, from the importer's nearest configpackage.jsonimports:#components/*subpath patterns and conditions- Workspace packages linked in
node_modules(npm, yarn, pnpm):exports, thensource/module/main
Aliases that aren't declared in any of those, such as Vite, webpack, Babel or Metro aliases, are inferred:
@/components/Modal,~/utils/format,@components/Modalandsrc/lib/chart-style imports are tried from the package root down towards the importer, so a feature-localcomponents/Modalnever shadows the shared one- Other aliases (
@ui/Input→src/shared/ui/Input) resolve only when exactly one file in the workspace matches; ambiguous matches are skipped rather than guessed
Third-party packages are never scanned, and a specifier that names an installed package is never treated as an alias.
Barrels (export { default } from './ui/banner'), export * and export default memo(Component) are followed to the real declaration, so Find All References works from the component itself or from any file that imports it.
❌ Not Supported
// Computed specifiers can't be resolved statically:
const page = await import(`./pages/${name}`);
⚙️ Configuration
Zero configuration required! 🎉 The extension works automatically when enabled.
🎛️ Custom Matchers
Want to add support for your own lazy loading functions or libraries? You can configure custom matchers in your VS Code settings:
📝 Custom Matchers Configuration (Click to expand)
Add this to your VS Code settings.json:
{
"dynamicImportReferences.customMatchers": [
{
"kind": "named",
"name": "asyncComponent",
"source": "react-async-component",
"allowAlias": true
},
{
"kind": "member",
"namespace": "React",
"member": "lazy",
"source": "react"
},
{
"kind": "identifier",
"name": "myCustomLoader",
"requireImport": false
}
]
}
Configuration Options
| Property | Type | Description | Required |
|---|---|---|---|
kind |
string |
How the function is referenced: • "named" = named import (import { lazy })• "default" = default import (import dynamic)• "member" = namespace member (React.lazy)• "identifier" = local/project utility |
✅ |
name |
string |
Function name to detect (e.g., "lazy", "loadable", "myLazy") |
For named, member, identifier |
source |
string |
Module specifier (e.g., "react", "@loadable/component") |
For named, default, member |
namespace |
string |
Namespace identifier for member access (e.g., "R" in R.lazy) |
For member |
member |
string |
Member function name (e.g., "lazy" in R.lazy) |
For member |
allowAlias |
boolean |
Allow aliased imports (e.g., { lazy as myLazy }) |
Optional (default: true) |
requireImport |
boolean |
Require function to be imported vs. locally declared | Optional (default: true) |
memberAccess |
boolean |
Back-compat: allow member access patterns | Optional (default: false) |
Examples
Named Import Pattern:
{
"kind": "named",
"name": "asyncComponent",
"source": "react-async-component"
}
Detects: import { asyncComponent } from 'react-async-component'
Member Access Pattern:
{
"kind": "member",
"namespace": "Utils",
"member": "lazy",
"source": "./utils"
}
Detects: import * as Utils from './utils' then Utils.lazy(...)
Local Function Pattern:
{
"kind": "identifier",
"name": "myLazyLoader",
"requireImport": false
}
Detects: Locally defined myLazyLoader function
🔧 Built-in Patterns
The extension automatically detects these patterns without configuration:
| Library | Pattern | Example |
|---|---|---|
| React | lazy |
const Comp = lazy(() => import('./Comp')) |
| Next.js | dynamic |
const Comp = dynamic(() => import('./Comp')) |
| @loadable/component | loadable |
const Comp = loadable(() => import('./Comp')) |
🛠️ Development & Contributing
🚀 Local Development Setup
Prerequisites
Node.js 24+, npm and VS Code 1.104+
Getting Started
# Clone the repository
git clone https://github.com/bubablue/dynamic-import-references.git
cd dynamic-import-references
# Install dependencies
npm install
# Open in VS Code
code .
# Start development
npm run watch:esbuild
Running Tests
# Run all tests
npm test
# Run tests in watch mode
npm run watch-tests
Debugging
- Press
F5to launch the Extension Development Host - Open a test project in the new window
- Test the extension functionality
To try a local build on a real project while the Marketplace version is installed, start an isolated instance instead of installing the .vsix:
npm run package
code --extensionDevelopmentPath="$PWD" \
--extensions-dir /tmp/dir-extensions \
--user-data-dir /tmp/dir-user \
/path/to/project
Building for Release
npm run package
🤝 How to Contribute
We welcome contributions! Here's how you can help:
- 🐛 Report Bugs - Found an issue? Open an issue
- 💡 Suggest Features - Have an idea? We'd love to hear it!
- 📝 Improve Documentation - Help make the docs even better
- 🔧 Submit Code - Fix bugs or add features with a PR
Contribution Guidelines
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
🎯 Core Features
|
🔮 Future Enhancements
|
💡 Have an idea? Suggest a feature • 🐛 Found a bug? Report it
💝 Support
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by developers, for developers
Icon by Arkinasi