Giter Site home page Giter Site logo

Comments (8)

Gorthog avatar Gorthog commented on August 17, 2024 1

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
    }),
  ],
};

from nx-console.

MaxKless avatar MaxKless commented on August 17, 2024

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?

from nx-console.

Gorthog avatar Gorthog commented on August 17, 2024

I just used nx to create this project:

npx create-nx-workspace@latest debugging --name debugging --preset nest --appName app --docker true --nxCloud skip

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?
It's either nx-console, or nx generator...

from nx-console.

MaxKless avatar MaxKless commented on August 17, 2024

Did you go through the VSCode troubleshooting steps for unbound breakpoints?
What executor are you using to build your nest app?
Did you set the source map option on your executor?
Did you check whether a sourcemap file was actually generated in the dist folder?

from nx-console.

Gorthog avatar Gorthog commented on August 17, 2024

Ok, i see no source maps are being generated in dist folder.
However, I'm just using default project generated by Nx. can you please point me where should I open an issue for this?

from nx-console.

Gorthog avatar Gorthog commented on August 17, 2024

I fixed the issue with the sourcemaps (added explicitly sourcemap: true in webpack.config.js), but still it won't work.

image

any suggestions?

from nx-console.

MaxKless avatar MaxKless commented on August 17, 2024

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.
Closing this issue for now :)

from nx-console.

marc-wilson avatar marc-wilson commented on August 17, 2024

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.

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. Closing this issue for now :)

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.

from nx-console.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.