-
Notifications
You must be signed in to change notification settings - Fork 288
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
Monorepo build tools incompatible with breakpoints #1893
Comments
I don't really know anything about your build setup without the log file that the bug template asks for, or a sample repo, but it sounds like you're bundling everything with webpack which will pave over the actual paths on disk. You will probably want to customize your I don't provide guidance on how to debug with a monorepo as part of our official docs, because basically every monorepo builds and debugs things different. For example, are package dependencies built ahead of time? Are they compiled with something like tsc or do you use some bundler to package them and then import them? Or are the bundled dynamically with the top level package you're debugging? Are you using webpack/esbuild/tsc/vite/babel/... to do this? It's quickly into |
Totally understand the concern, but it looks like there is a pretty common theme when googling "monorepo" here that this is a poor interaction between Webpack and monorepos. Whether in this repo or in others (next.js, vite, etc.) folks find that source maps were relative to the package they were built in, not relative to the "repository root". And there are a lot of issues in this repo, questions on StackOverflow, in other open source repos with this issue, including:
I have a hunch there is a solution here that isn't overly complex that solves the problem for most of the users running into this. Most of these build tools make it deliberately difficult to change the Webpack or other settings, as they are prone to causing breaks, or remove control from the framework e.g.: Next.js migrating to turbopack. That makes it pretty challenging to wrangle all of the parties involved to "do the right thing". But on the other hand, the "Debug Diagnostics" tool found the file! It just refused to use it for debugging. That seems fixable! |
Most of those things you mentioned are unique problems:
I haven't read through the search query you posted. If there is "a solution" to make life better in these cases, I'm all for it, but the issues you mention are different issues with different problems. Some general 'user setup issues' may be fixed with #1214
Can you share a log file so I can see what's going on in your case? I agree that is rather strange 🤔 |
I face a similar problem debugging my projects in an nx monorepo. Generally I set cwd in my VS Code launch.json to the project I'm working on. When I'm working in NeoVim, I can do this programmatically so I don't have to make manual edits every time I switch project (I build an appropriate cwd here). It would be great if I didn't have to coax it to find source like this, though. |
Please open a new issue with details about what you're trying to do. |
Closing this issue as we haven't heard back from the reporter in the last month. The issues brought up seem to be generally captured elsewhere (#1893 (comment)), and log files are needed for the additional issue mentioned. |
Describe the bug
Many monorepo tools are "oblivious" to the fact that they are in a monorepo, including most Node.js build tools. In my case, using any arbitrary tool (even a shell script) which runs
next dev
in multiple projects. The Next.js build tool produces source map paths that are relative to each package they are in, and source mapping fails.Expected behavior
In preference order:
That source mapped files in a monorepo "just work".
That the "Debug Diagnostics" menu helps me change my launch config to handle scenarios (possible feature request?) by adding the mapping for me. It clearly found a "file with the same name", why is there not an option to help me add that mapping?
That there is clear documentation on how to handle this scenario.
Actual behavior
Given a repo with the structure:
That is, a repository with
projects/foo
andprojects/bar
, the source maps for each are typically relative paths likewebpack://./src/index.ts
. When using a tool likenx
,turbo
,lerna
, et al., to launch processes in multiple projects simultaneously, these relative paths result in a failure to "find a corresponding source location", as described by Debug Diagnostics:Where, confusingly, the path it found "with the same name" will have the monorepo path highlighted in red. I can't reproduce that here in text or show a screenshot, but it looks to me like it finds a "piecewise diff" (Levenshtein edit distance?) with the location in the sourcemap, likely
webpack://./src/index.ts
.What makes this particularly frustrating is that it found the file. But it is very, very unclear from the documentation how to configure the launch.json to use it.
When changing the launch config to run the sub-project directly and viewing debug diagnostics on a successfully hit breakpoint, I see:
Unfortunately this is not quite what I want. Using the same shell script, makefile, monorepo tool (turbo, lerna, etc.) or other tool to launch other pre-requisite processes in a single command is the desired state.
The text was updated successfully, but these errors were encountered: