MCPcopy Index your code
hub / github.com/TheLarkInn/virtual-dependency-loader

github.com/TheLarkInn/virtual-dependency-loader @v0.1.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.1 ↗ · + Follow
7 symbols 20 edges 10 files 5 documented · 71%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

virtual-dependency-loader

Take a single file, process pieces of that file as "dependencies" in loader chain. This is traditionally leveraged inside of other loaders.

Usage

Inside of another loader implementation

loader.js

import querystring from 'querystring';
import {stringifyRequest} from 'loader-utils';

export default function someLoader(source, map, ast) {
  const [normalSource, virtualizedSource] = source.split("__virtual_dependency__");
  const {loadModule, resourcePath, async} = this;
  const callback = async();
  const dummyFilePath = path.resolve(__dirname, "../dummy-file.js");

  const inlineLoaderOptions = queryString.stringify({
    code: virtualizedSource,
    filename: `${resourcePath}.script.js`
  });

  const resource = stringifyRequest(`inline-loader?${inlineLoaderOptions}!${dummyFilePath}`)

  const virtualizedSourceProcessedByOtherLoaders = loadModule(resource, (err, code, map) => {
    const newSource = [normalSource, code].join("__virtual_dependency__");

    callback(null, newSource);
  });
};

file-that-was-ran-through-loader.js

var hello = "hello";

/* __virtual_dependency__ */
class Bar {
  constructor(foo) {
    this.foo = foo;
  };

  print() {
    console.log(this.foo);
  }
}

const baz = new Bar(hello);

Core symbols most depended-on inside this repo

getFixtureResource
called by 4
test/test-utils.js
getFixture
called by 3
test/test-utils.js
getLoader
called by 2
test/test-utils.js
getExampleConfig
called by 1
test/test-utils.js
runWebpackExampleInMemory
called by 0
test/test-utils.js
virtualDependencyLoader
called by 0
src/index.js
getLazyModule
called by 0
examples/simple/src/index.js

Shape

Function 7

Languages

TypeScript100%

Modules by API surface

test/test-utils.js5 symbols
src/index.js1 symbols
examples/simple/src/index.js1 symbols

For agents

$ claude mcp add virtual-dependency-loader \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact