question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugging Gatsby TypeScript in v2

See original GitHub issue

What is the correct way to debug a v2 Gatsby project made in TypeScript?

I’ve managed to get the debugger running, thanks to debugging-the-build-process guide.

But it only worked for .js files, like gatsby-node.js, both in Chrome and VSCode.

Are there additional steps for TypeScript, or is it even possible?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:23 (21 by maintainers)

github_iconTop GitHub Comments

4reactions
azdanovcommented, Aug 17, 2018

By using source-map-loader webpack plugin I’ve managed to sync sourcemaps, before there were similar issues as here.

@m-allanson Should it be included by default in gatsby-plugin-typescript?

module.exports.onCreateWebpackConfig = ({ actions }) => {
  actions.setWebpackConfig({
    devtool: "source-map",
    module: {
      rules: [
        {
          test: /\.js$/,
          use: ["source-map-loader"],
          enforce: "pre"
        }
      ]
    }
  });
};

Need to figure out how to make it work for incline-source-map.

3reactions
azdanovcommented, Aug 8, 2018

I’ve found a way to debug components with TypeScript in a web browser.

Add to gatsby-node.js

exports.onCreateWebpackConfig = ({ actions }) => {
  actions.setWebpackConfig({
    devtool: "eval-source-map"
  });
};

As mentioned in other thread: https://github.com/gatsbyjs/gatsby/issues/6877#issuecomment-410581050

This will add webpack-internal:// with src/ files where breakpoints work.

screen shot 2018-08-08 at 05 16 15
Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging the Build Process - Gatsby
VS Code Debugger (Auto-Config) · Press Ctrl + , or ⌘ + , to open your preferences. Type node debug into the search...
Read more >
How To Set Up a Gatsby Project with TypeScript - DigitalOcean
This will set your project up for edits in later steps. Open your computer's console/terminal and run the following command: gatsby new gatsby- ......
Read more >
What is needed that VS Code uses the inline sourcemaps of ...
When I debug with Gatsby build a new TypeScript file opens with the following content: (function (exports, require, module, __filename ...
Read more >
How to debug Gatsby.js in VS Code (build process and client ...
If you want to debug the part when Gatsby creates pages (gatsby-node.js) then follow this steps: ... 7. In the Debug view select...
Read more >
gatsby-typescript-scss-docker - CodeSandbox
gatsby. ^2.13.31 (2.32.13) · gatsby-plugin-react-helmet. ^3.1.2 (3.10.0) · gatsby-plugin-root-import. 2.0.5 · gatsby-plugin-sharp. 2.2.8 · gatsby-plugin-typescript.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found