PageSourceSearch

https://rspack.rs/static/js/async/route-6fbb01eeae23.a1f9f42cef.js

js rspack.rs collected 2026-09-24 17:14:21 UTC 15,245 bytes, 1 lines download raw bytes

1"use strict";(self.rspackChunkrspack_website=self.rspackChunkrspack_website||[]).push([[47],{js(e,s,n){n.r(s);var r=n("i"),i=n("f");function a(e){let s={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",span:"span",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(s.h1,{id:"debugging",children:[(0,r.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#debugging",children:"#"}),"Debugging"]}),"\n",(0,r.jsxs)(s.h2,{id:"debugging-with-vs-code",children:[(0,r.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#debugging-with-vs-code",children:"#"}),"Debugging with VS Code"]}),"\n",(0,r.jsxs)(s.ol,{children:["\n",(0,r.jsxs)(s.li,{children:["Install ",(0,r.jsx)(s.code,{children:"go install github.com/go-delve/delve/cmd/dlv@latest"})]}),"\n",(0,r.jsxs)(s.li,{children:["Install VS Code extension ",(0,r.jsx)(s.a,{href:"https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer",rel:"noopener noreferrer",target:"_blank",children:"rust-analyzer"})," and ",(0,r.jsx)(s.a,{href:"https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb",rel:"noopener noreferrer",target:"_blank",children:"CodeLLDB"})]}),"\n",(0,r.jsxs)(s.li,{children:["build ",(0,r.jsx)(s.code,{children:"@rspack/cli"})," and napi binding by run ",(0,r.jsx)(s.code,{children:"pnpm install && pnpm -w build:cli:dev"})]}),"\n",(0,r.jsxs)(s.li,{children:["In VS Code's ",(0,r.jsx)(s.code,{children:"Run and Debug"})," tab, select ",(0,r.jsx)(s.code,{children:"Debug Rspack"})," to start debugging the initial launch of ",(0,r.jsx)(s.code,{children:"@rspack/cli"})," with a simple rspack project. This task can be configured in ",(0,r.jsx)(s.code,{children:".vscode/launch.json"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(s.h2,{id:"using-rspack-debugcore",children:[(0,r.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#using-rspack-debugcore",children:"#"}),"Using ",(0,r.jsx)(s.code,{children:"@rspack-debug/core"})]}),"\n",(0,r.jsxs)(s.p,{children:["Frameworks and tools that integrate Rspack usually depend on the release build of ",(0,r.jsx)(s.code,{children:"@rspack/core"}),". The release package is suitable for normal builds, but it does not include some debug-only capabilities. When you need these capabilities for local investigation, override ",(0,r.jsx)(s.code,{children:"@rspack/core"})," with ",(0,r.jsx)(s.code,{children:"@rspack-debug/core"})," in the project that runs the build."]}),"\n",(0,r.jsx)(s.p,{children:"For example, with pnpm:"}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(s.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",title:"package.json",lang:"json",children:(0,r.jsxs)(s.code,{children:[(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"{"})}),"\n",(0,r.jsxs)(s.span,{className:"line",children:[(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'  "pnpm"'}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" {"})]}),"\n",(0,r.jsxs)(s.span,{className:"line",children:[(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'    "overrides"'}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" {"})]}),"\n",(0,r.jsxs)(s.span,{className:"line",children:[(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'      "@rspack/core"'}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:' "npm:@rspack-debug/core@latest"'})]}),"\n",(0,r.jsxs)(s.span,{className:"line",children:[(0,r.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"    }"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,r.jsxs)(s.span,{className:"line",children:[(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"}
1,children:'    "peerDependencyRules"'}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" {"})]}),"\n",(0,r.jsxs)(s.span,{className:"line",children:[(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'      "allowAny"'}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" ["}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"@rspack/*"'}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"]"})]}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"    }"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"  }"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"}"})})]})})}),"\n",(0,r.jsx)(s.p,{children:"Then reinstall dependencies and run the original build command again. For example, if the project builds through Rsbuild:"}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(s.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"bash",children:(0,r.jsxs)(s.code,{children:[(0,r.jsxs)(s.span,{className:"line",children:[(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"pnpm"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:" install"})]}),"\n",(0,r.jsxs)(s.span,{className:"line",children:[(0,r.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:"RSPACK_PROFILE"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:"OVERVIEW"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-foreground)"},children:" RSPACK_TRACE_LAYER"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:"perfetto"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:" rsbuild"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:" build"})]})]})})}),"\n",(0,r.jsxs)(s.p,{children:[(0,r.jsx)(s.code,{children:"@rspack-debug/core"})," should only be used for local debugging and diagnostics. Prefer pinning it to the same version as the original ",(0,r.jsx)(s.code,{children:"@rspack/core"})," dependency when investigating a version-specific issue, and remove the override after the investigation."]}),"\n",(0,r.jsxs)(s.h3,{id:"common-debugging-scenarios-guide",children:[(0,r.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#common-debugging-scenarios-guide",children:"#"}),"Common debugging scenarios guide"]}),"\n",(0,r.jsxs)(s.h4,{id:"debugging-rust",children:[(0,r.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#debugging-rust",children:"#"}),"Debugging Rust"]}),"\n",(0,r.jsxs)(s.p,{children:["Simply set breakpoints in the specified Rust code and start ",(0,r.jsx)(s.code,{children:"Debug Rspack"})," to begin debugging."]}),"\n",(0,r.jsxs)(s.h4,{id:"debugging-javascript",children:[(0,r.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#debugging-javascript",children:"#"}),"Debugging JavaScript"]}),"\n",(0,r.jsxs)(s.p,{children:["When starting ",(0,r.jsx)(s.code,{children:"Debug Rspack"}),", select the ",(0,r.jsx)(s.code,{children:"--inspect"})," or ",(0,r.jsx)(s.code,{children:"--inspect-brk"})," option, then start ",(0,r.jsx)(s.code,{children:"Attach JavaScript"})," and choose the PID of the corresponding process."]}),"\n",(0,r.jsxs)(s.h4,{id:"debugging-a-running-rspack-process",children:[(0,r.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#debugging-a-running-rspack-process",children:"#"}),"Debugging a running Rspack process"]}),"\n",(0,r.jsxs)(s.p,{children:["When Rspack is integrated into other frameworks or tools (such as Nx), it may be difficult to independently start Rspack in Launch mode. In this case, you can debug the code through attach mode. Start ",(0,r.jsx)(s.code,{children:"Attach Rust"})," and select the PID of the Rspack process, and start ",(0,r.jsx)(s.code,{children:"Attach JavaScript"})," to debug JavaScript."]}),"\n",(0,r.jsxs)(s.h4,{id:"debugging-a-rspack-process-with-a-deadlock",children:[(0,r.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#debugging-a-rspack-process-with-a-deadlock",children:"#"}),"Debugging a Rspack process with a deadlock"]}),"\n",(0,r.jsxs)(s.p,{children:["When using ",(0,r.jsx)(s.code,{children:"Attach Rust"})," to attach the debugger to the Rspack process, click the Pause button on the Debugger to set breakpoints at the deadlock scene."]}),"\n",(0,r.jsxs)(s.h2,{id:"rust-lldb",children:[(0,r.jsx)(s.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#rust-lldb",children:"#"}),"rust-lldb"]}),"\n",(0,r.jsxs)(s.p,{children:[(0,r.jsx)(s.code,{children:"rust-lldb"})," can be used to get panic information from debug builds"]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(s.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"bash",children:(0,r.jsx)(s.code,{children:(0,r.jsxs)(s.span,{className:"line",children:[(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"rust-lldb"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:" --"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:" node"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:" /path/to/rspack"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:" build"})]})})})}),"\n",(0,r.jsxs)(s.p,{children:["Once it launches, press ",(0,r.jsx)(s.code,{children:"r"})," for running the program."]}),"\n",(0,r.jsxs)(s.p,{children:["For example, ",(0,r.jsx)(s.code,{children:"examples/arco-pro"})," crashes without any information before ",(0,r.jsx)(s.a,{href:"https://github.com/web-infra-dev/rspack/pull/3195/files",rel:"noopener noreferrer",target:"_blank",children:"this fix"}),":"]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(s.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"txt",children:(0,r.jsxs)(s.code,{children:[(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"rspack/examples/arco-pro ❯ node ../../packages/rspack-cli/bin/rspack build"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"Rspack ██████████████████████░░░░░░░░░░░░░░░░░░ 56% building ./pages/welcome"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"zsh: bus error  node ../../packages/rspack-cli/bin/rspack build"})})]})})}),"\n",(0,r.jsxs)(s.p,{children:["Using ",(0,r.jsx)(s.code,{children:"rust-lldb"})]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(s.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"bash",children:(0,r.jsx)(s.code,{children:(0,r.jsxs)(s.span,{className:"line",children:[(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"rspack/examples/arco-pro"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:" ❯"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:" rust-lldb"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:" --"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:" node"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:" ../../packages/rspack-cli/bin/rspack"}),(0,r.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:" build"})]})})})}),"\n",(0,r.jsxs)(s.p,{children:["Press ",(0,r.jsx)(s.code,{children:"r"})," and it prints:"]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(s.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"txt",children:(0,r.jsxs)(s.code,{children:[(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"Process 23110 stopped"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"* thread #10, name = 'tokio-runtime-worker', stop reason = EXC_BAD_ACCESS (code=2, address=0x70000cc66560)"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"    frame #0: 0x0000000140d0db4b rspack.darwin-x64.node`swc_ecma_parser::parser::expr::ops::_$LT$impl$u20$swc_ecma_parser..parser..Parser$LT$I$GT$$GT$::parse_unary_expr::h29f49330a806839c(self=0x0000000000000000) at ops.rs:244"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"   241 	    /// Parse unary expression and update expression."})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"   242 	    ///"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"   243 	    /// spec: 'UnaryExpression'"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"-> 244 	    pub(in crate::parser) fn parse_unary_expr(&mut self) -> PResult<Box<Expr>> {"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"   245 	        trace_cur!(self, parse_unary_expr);"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"   246 	        let start = cur_pos!(self);"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"   247"})}),"\n",(0,r.jsx)(s.span,{className:"line",children:(0,r.jsx)(s.span,{children:"Target 0: (node) stopped."})})]})})})]})}function c(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:s}={...(0,i.R)(),...e.components};return s?(0,r.jsx)(s,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}c.__RSPRESS_PAGE_META={},c.__RSPRESS_PAGE_META["en%2Fcontribute%2Fdevelopment%2Fdebugging.mdx"]={toc:[{id:"debugging-with-vs-code",text:"Debugging with VS Code",depth:2},{id:"using-rspack-debugcore",text:"Using `@rspack-debug/core`",depth:2},{id:"common-debugging-scenarios-guide",text:"Common debugging scenarios guide",depth:3},{id:"debugging-rust",text:"Debugging Rust",depth:4},{id:"debugging-javascript",text:"Debugging JavaScript",depth:4},{id:"debugging-a-running-rspack-process",text:"Debugging a running Rspack process",depth:4},{id:"debugging-a-rspack-process-with-a-deadlock",text:"Debugging a Rspack process with a deadlock",depth:4},{id:"rust-lldb",text:"rust-lldb",depth:2}],title:"Debugging",headingTitle:"Debugging",frontmatter:{description:"Simply set breakpoints in the specified Rust code and start Debug Rspack to begin debugging"}},n.d(s,{default:()=>c})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.