Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Show component file path in Elements panel / 支持在 elements 面板显示组件文件路径 #166

Closed
tjx666 opened this issue Apr 26, 2024 · 8 comments · Fixed by #174

Comments

@tjx666
Copy link
Contributor

tjx666 commented Apr 26, 2024

描述

https://github.com/webfansplz/vite-plugin-vue-inspector 一样:

image

使用场景

有时候两个组件在网页上非常接近不好选中,如果可以直接在 elements 面板中清除的看到某个元素对应哪个文件就好了

@zthxxx
Copy link
Owner

zthxxx commented Apr 27, 2024

@tjx666
可以添加 babel 插件,提供了 @react-dev-inspector/babel-plugin

https://react-dev-inspector.zthxxx.me/docs/compiler-plugin#react-dev-inspectorbabel-plugin

效果如:

// Input
<div />
 
// Output
<div data-inspector-relative-path="src/path/Component.tsx" data-inspector-line="10" data-inspector-column="6" />

@tjx666
Copy link
Contributor Author

tjx666 commented Apr 27, 2024

抱歉,我应该先仔细看一下文档的。

试用了下,我感觉更理想的效果:

  1. 只注入一个属性:data-inspector-path="src/a.ts?line=100&col=21"
  2. 应该只在快捷键开启时显示这个属性
  3. 貌似和 mui 冲突
image

@zthxxx
Copy link
Owner

zthxxx commented Apr 27, 2024

Get, 明白你说的问题点呢~

近期目标是提供一个右键菜单以支持选择父级各个组件。

@zthxxx
Copy link
Owner

zthxxx commented Jul 6, 2024

@tjx666

inspect-context-panel.png

@zthxxx zthxxx changed the title [feat] 支持在 elements 面板显示组件文件路径 [feat] Show component file path in Elements panel / 支持在 elements 面板显示组件文件路径 Jul 6, 2024
@tjx666
Copy link
Contributor Author

tjx666 commented Jul 6, 2024

@zthxxx

 Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/yutengjing/code/xxx/web/node_modules/solid-element/dist/index.js from /Users/yutengjing/code/xxx/web/node_modules/@react-dev-inspector/web-components/dist/cjs/index.js not supported.
image

@zthxxx
Copy link
Owner

zthxxx commented Jul 8, 2024

@tjx666 报错信息和截图似乎没有关联,发下完整配置信息和完整报错栈呢

examples/nextjs-custom-server 是能正常启动的

https://github.com/zthxxx/react-dev-inspector/blob/dev/examples/nextjs-custom-server/server.mjs

@tjx666
Copy link
Contributor Author

tjx666 commented Jul 12, 2024

@zthxxx
Copy link
Owner

zthxxx commented Jul 13, 2024

@tjx666 workaround:

I'll try to fix it in release 2.1.0

image
import dynamic from 'next/dynamic';
import type { AppProps } from 'next/app';

const Inspector = dynamic(
  () => import('react-dev-inspector').then(({ Inspector }) => Inspector),
  { ssr: false }
);

export default function App({ Component, pageProps }: AppProps) {
  return (
    <>
      <Inspector />
      <Component {...pageProps} />
    </>
  );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants