简体   繁体   English

如何从我的应用程序打开 react-admin 源映射?

[英]How can I turn on react-admin source maps from my app?

I'm using react-admin to build my app but I'm having trouble wrapping my brain around some of the errors react-admin is throwing.我正在使用 react-admin 来构建我的应用程序,但我无法将大脑围绕 react-admin 抛出的一些错误。 I can't inspect the code because devtools just refers to a chunk.js file.我无法检查代码,因为 devtools 只是引用了一个 chunk.js 文件。

I see in the react-admin source that in the tsconfig file there is an option to build source maps.我在 react-admin 源代码中看到 tsconfig 文件中有一个构建源映射的选项。 I could modify this in the node_modules folder but that's never a good idea.我可以在 node_modules 文件夹中修改它,但这绝不是一个好主意。

How can I enable source maps for react-admin from my app?如何从我的应用程序为 react-admin 启用源映射?

My conclusion was that this is not really a react-admin issue in the way I described it.我的结论是,按照我描述的方式,这并不是一个真正的 react-admin 问题。

Instead, in order to get a similar result I did the following:相反,为了获得类似的结果,我执行了以下操作:

  1. Cloned the react-admin repo ( https://github.com/marmelab/react-admin )克隆了 react-admin 仓库( https://github.com/marmelab/react-admin
  2. Edit tsconfig.json to enable source maps - uncomment line "sourceMap": true编辑 tsconfig.json 以启用源映射 - 取消注释行 "sourceMap": true
  3. In a terminal run command "make run"在终端运行命令“make run”
  4. View Simple demo site at http://localhost:8080在 http://localhost:8080 查看简单的演示站点
  5. Recreate issue in the Simple site in the /examples/simple folder在 /examples/simple 文件夹中的简单站点中重新创建问题
  6. View errors with correct line numbers now that source maps are enabled启用源映射后,使用正确的行号查看错误

It's not ideal in that it's not your specific app, but most issue can be recreated in the simple example app in order to find the line number of where the error is happening.这并不理想,因为它不是您的特定应用程序,但大多数问题可以在简单的示例应用程序中重新创建,以便找到发生错误的行号。

I basically followed instructions under the heading "Testing Your Changes In The Example Apps" in the readme.md.我基本上按照 readme.md 中“测试示例应用程序中的更改”标题下的说明进行操作。

I tried using yarn link to the locally clone react-admin but wasn't able to get it to work, ended up in an endless loop for some reason that crashed my browser tab.我尝试使用纱线链接到本地克隆 react-admin 但无法使其工作,由于某种原因导致我的浏览器选项卡崩溃,最终陷入无限循环。

Anyway, hopefully this will help someone.无论如何,希望这会对某人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM