-
Notifications
You must be signed in to change notification settings - Fork 211
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
Unbound breakpoints when using nx-console with nest project #2042
Comments
It looks like the console is correctly launched with a debugger attached. Can you provide some more context why you think this is an issue with Nx Console vs a misconfiguration in your bundler? |
I just used nx to create this project:
not using any bundler of my choosing - only what nx uses. How should I check if this is a problem with nx-console vs something else? |
Did you go through the VSCode troubleshooting steps for unbound breakpoints? |
Ok, i see no source maps are being generated in dist folder. |
I don't think this is something we should generate by default either way. Source maps potentially take up lots of space so by generating them by default we would increase bundle sizes for everyone. I think keeping them opt-in is smarter. |
I expected debugging to work out of the box, it doesn't, however it can be fixed by changing webpack.config.js to generate source maps that contain relative links. This way auto attach works automatically, and there is no need to generate launch.json file in vscode: const { NxWebpackPlugin } = require('@nx/webpack');
const path = require('path');
const outDir = path.join(__dirname, '../../dist/apps/app');
module.exports = {
output: {
devtoolModuleFilenameTemplate(info) {
const { absoluteResourcePath, namespace, resourcePath } = info;
if (path.isAbsolute(absoluteResourcePath)) {
return path.relative(outDir, absoluteResourcePath);
}
// Mimic Webpack's default behavior:
return `webpack://${namespace}/${resourcePath}`;
},
path: outDir,
},
plugins: [
new NxWebpackPlugin({
target: 'node',
compiler: 'tsc',
main: './src/main.ts',
tsConfig: './tsconfig.app.json',
assets: ['./src/assets'],
optimization: false,
outputHashing: 'none',
sourceMap: true
}),
],
}; |
I do not recall what I upgraded from, but breakpoints in nx-console were working perfectly fine. Generate a new project and run. Exactly what I would expect. After upgrading, they don't work out of the box. I spent a very large amount of time troubleshooting this and after running into this comment, things work. The only reason why I use nx-console is to get my nx projects up and running with a simple click. I do not understand why someone decided that debugging shouldn't work out of the box. That is a basic fundamental need when writing code.
So it's better to opt people out of basic debugging rights by default? The nx.json/project.json has the ability to know which environment/configurations it's targeting. Pretty simple rule --- if config is dev, sourcemaps = true, else sourcemaps = false. That's how other things work. Debugging should work out of the box when running in your IDE. Period. |
Current Behavior
When debugging I get unbound breakpoint and cannot debug
Expected Behavior
Breakpoint is bound and i can debug the app
Steps to Reproduce
I created a project using:
Added a breakpoint in file app.service.ts in line 6
Then served the newly created app using nx-console in vscode:
However, breakpoint is unbound and cannot be hit:
repro: https://github.com/Gorthog/nx-debugging
Environment
Node : 18.16.0
OS : darwin-arm64
npm : 9.5.1
nx (global) : 18.0.6
nx : 18.0.6
@nx/js : 18.0.6
@nx/jest : 18.0.6
@nx/linter : 18.0.6
@nx/eslint : 18.0.6
@nx/workspace : 18.0.6
@nx/devkit : 18.0.6
@nx/eslint-plugin : 18.0.6
@nx/nest : 18.0.6
@nx/node : 18.0.6
@nrwl/tao : 18.0.6
@nx/web : 18.0.6
@nx/webpack : 18.0.6
typescript : 5.3.3
The text was updated successfully, but these errors were encountered: