MCPcopy
hub / github.com/zh-lx/code-inspector

github.com/zh-lx/code-inspector @main sqlite

repository ↗ · DeepWiki ↗
536 symbols 1,676 edges 328 files 18 documented · 3%
README

code-inspector

中文文档 | Documentation

NPM version GITHUB star NPM Downloads MIT-license GITHUB-language


📖 Introduction

Click the element on the page, it can automatically open the code editor and position the cursor to the source code of the element.

code-inspector

💻 Try it out online

🎨 Support

The following are which compilers, web frameworks and editors we supported now:

  • The following bundlers are currently supported:

✅ webpack

✅ vite

✅ rspack / rsbuild

✅ farm

✅ esbuild

✅ turbopack

✅ mako

  • The following Web frameworks are currently supported:

✅ vue2 / vue3 / nuxt

✅ react / nextjs / umijs

✅ preact

✅ solid

✅ qwik

✅ svelte

✅ astro

🚀 Install

npm i code-inspector-plugin -D
# or
yarn add code-inspector-plugin -D
# or
pnpm add code-inspector-plugin -D

🌈 Usage

Please check here for more usage information: code-inspector-plugin configuration

  • 1.Configuring Build Tools

Click to expand configuration about: webpack

```js // webpack.config.js const { codeInspectorPlugin } = require('code-inspector-plugin');

module.exports = () => ({ plugins: [ codeInspectorPlugin({ bundler: 'webpack', }), ], }); ```

Click to expand configuration about: vite

```js // vite.config.js import { defineConfig } from 'vite'; import { codeInspectorPlugin } from 'code-inspector-plugin';

export default defineConfig({ plugins: [ codeInspectorPlugin({ bundler: 'vite', }), ], }); ```

Click to expand configuration about: rspack

```js // rspack.config.js const { codeInspectorPlugin } = require('code-inspector-plugin');

module.exports = { // other config... plugins: [ codeInspectorPlugin({ bundler: 'rspack', }), // other plugins... ], }; ```

Click to expand configuration about: rsbuild

```js // rsbuild.config.js const { codeInspectorPlugin } = require('code-inspector-plugin');

module.exports = { // other config... tools: { rspack: { plugins: [ codeInspectorPlugin({ bundler: 'rspack', }), ], }, }, }; ```

Click to expand configuration about: esbuild

```js // esbuild.config.js const esbuild = require('esbuild'); const { codeInspectorPlugin } = require('code-inspector-plugin');

esbuild.build({ // other configs... // [注意] esbuild 中使用时,dev 函数的返回值需自己根据环境判断,本地开发的环境返回 true,线上打包返回 false plugins: [codeInspectorPlugin({ bundler: 'esbuild', dev: () => true })], }); ```

Click to expand configuration about: farm

```js // farm.config.js import { defineConfig } from '@farmfe/core'; import { codeInspectorPlugin } from 'code-inspector-plugin';

export default defineConfig({ vitePlugins: [ codeInspectorPlugin({ bundler: 'vite', }), // ...other code ], }); ```

Click to expand configuration about: vue-cli

```js // vue.config.js const { codeInspectorPlugin } = require('code-inspector-plugin');

module.exports = { // ...other code chainWebpack: (config) => { config.plugin('code-inspector-plugin').use( codeInspectorPlugin({ bundler: 'webpack', }) ); }, }; ```

Click to expand configuration about: nuxt

  • For nuxt3.x :

    ```js // nuxt.config.js import { codeInspectorPlugin } from 'code-inspector-plugin';

    // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ vite: { plugins: [codeInspectorPlugin({ bundler: 'vite' })], }, }); ```

  • For nuxt2.x :

    ```js // nuxt.config.js import { codeInspectorPlugin } from 'code-inspector-plugin';

    export default { build: { extend(config) { config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' })); return config; }, }, }; ```

Click to expand configuration about: next.js

  • For next.js(<= 14.x):

    ```js // next.config.js const { codeInspectorPlugin } = require('code-inspector-plugin');

    const nextConfig = { webpack: (config, { dev, isServer }) => { config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' })); return config; }, };

    module.exports = nextConfig; ```

  • For next.js(15.0.x ~ 15.2.x):

    ```js import type { NextConfig } from 'next'; import { codeInspectorPlugin } from 'code-inspector-plugin';

    const nextConfig: NextConfig = { experimental: { turbo: { rules: codeInspectorPlugin({ bundler: 'turbopack', }), }, }, };

    export default nextConfig; ```

  • For next.js(>= 15.3.x):

    ```js // next.config.js import type { NextConfig } from 'next'; import { codeInspectorPlugin } from 'code-inspector-plugin';

    const nextConfig: NextConfig = { turbopack: { rules: codeInspectorPlugin({ bundler: 'turbopack', }), }, };

    export default nextConfig; ```

Click to expand configuration about: umi.js

  • With webpack:

    ```js // umi.config.js or umirc.js import { defineConfig } from '@umijs/max'; import { codeInspectorPlugin } from 'code-inspector-plugin';

    export default defineConfig({ chainWebpack(memo) { memo.plugin('code-inspector-plugin').use( codeInspectorPlugin({ bundler: 'webpack', }) ); }, // other config }); ```

  • With mako:

    ```ts // .umirc.ts import { defineConfig } from 'umi'; import { codeInspectorPlugin } from 'code-inspector-plugin';

    export default defineConfig({ // other config... mako: { plugins: [ codeInspectorPlugin({ bundler: 'mako', }), ], }, }); ```

Click to expand configuration about: astro

```js // astro.config.mjs import { defineConfig } from 'astro/config'; import { codeInspectorPlugin } from 'code-inspector-plugin';

export default defineConfig({ vite: { plugins: [codeInspectorPlugin({ bundler: 'vite' })], }, }); ```

  • 2.Using the function

Now you can enjoy using it!~

When pressing the combination keys on the page, moving the mouse over the page will display a mask layer on the DOM with relevant information. Clicking will automatically open the IDE and position the cursor to the corresponding code location. (The default combination keys for Mac are Option + Shift; for Windows, it's Alt + Shift, and the browser console will output related combination key prompts)

👨‍💻 Contributors

Special thanks to the contributors of this project:

📧 Communication and Feedback

For any usage issues, please leave a message below my Twitter post or submit an issue on Github.

For Chinese users, you can join the QQ group 769748484 or add the author's WeiXin account zhoulx1688888 for consultation and feedback:

💖 Sponsor

Sponsoring this project can help the author create better. If you are willing, you can sponsor me through Alipay or WeChatPay:

Star History

Star History Chart

Extension points exported contracts — how you extend this code

Options (Interface)
(no doc)
packages/mako/types/index.d.ts
CodeInspectorPluginOptions (Interface)
(no doc)
packages/code-inspector-plugin/types/index.d.ts
Position (Interface)
(no doc)
packages/core/types/client/index.d.ts
Options (Interface)
(no doc)
packages/turbopack/types/index.d.ts
Options (Interface)
(no doc)
packages/esbuild/types/index.d.ts
Options (Interface)
(no doc)
packages/vite/types/index.d.ts
EntryDescription (Interface)
(no doc)
packages/webpack/types/entry.d.ts
GlobalComponents (Interface)
(no doc)
demos/vite-vue2/components.d.ts

Core symbols most depended-on inside this repo

transformJsx
called by 111
packages/core/src/server/transform/transform-jsx.ts
setProjectRecord
called by 60
packages/core/src/shared/record-cache.ts
transformVue
called by 59
packages/core/src/server/transform/transform-vue.ts
transformCode
called by 53
packages/core/src/server/transform/index.ts
apply
called by 42
packages/webpack/src/index.ts
getCodeWithWebComponent
called by 41
packages/core/src/server/use-client.ts
isEscapeTags
called by 40
packages/core/src/shared/utils.ts
ViteCodeInspectorPlugin
called by 38
packages/vite/src/index.ts

Shape

Function 439
Interface 67
Method 17
Class 12
Enum 1

Languages

TypeScript100%

Modules by API surface

packages/core/src/server/transform/transform-mdx.ts54 symbols
packages/core/src/server/transform/transform-jsx.ts47 symbols
packages/core/src/server/use-client.ts23 symbols
packages/core/src/server/transform/transform-astro.ts18 symbols
packages/core/src/client/index.ts18 symbols
packages/core/src/shared/utils.ts17 symbols
packages/webpack/src/index.ts15 symbols
packages/vite/src/index.ts11 symbols
demos/vite-react/src/utils/utils.ts10 symbols
demos/vite-react/src/services/axios.ts9 symbols
demos/vite-react/src/pages/login/index.tsx9 symbols
demos/vite-react/src/layouts/default/useMenu.tsx9 symbols

Dependencies from manifests, versioned

@ant-design/icons4.8.0 · 1×
@ant-design/plots1.2.2 · 1×
@astrojs/check0.5.5 · 1×
@astrojs/mdx6.0.2 · 1×
@babel/core7.21.3 · 1×
@babel/plugin-proposal-decorators7.22.7 · 1×
@babel/plugin-syntax-import-meta7.10.4 · 1×
@babel/plugin-transform-typescript7.21.3 · 1×
@builder.io/qwik1.5.1 · 1×
@code-inspector/coreworkspace:* · 1×
@code-inspector/esbuildworkspace:* · 1×

For agents

$ claude mcp add code-inspector \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact