Skip to content

Debugging issues and tips on WebStorm using Babel and Node 4/5

Notifications You must be signed in to change notification settings

coma/ws-babel-debug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ws-babel-debug

The idea behind this repository is sharing my findings around the whole process of debugging a transpiled code using Babel and WebStorm.

Contributions to this repository are welcome!

Tools

Config

Setting up WebStorm...

No Lazy

In order to avoid this error

error

While debugging using babel-node instead of node, all you have to do is remove the --no-lazy option:

help find registry

lib debugging (transpiled code, check the build script in package.json)

lib debugging

src debugging (raw code, using babel-node from the babel-cli module)

src debugging

Breakpoints

src

src index src other

lib

lib index lib other

Debugging lib in node 4.2.4

  • it stops on the lib/other.js:12 breakpoint
  • local variables are collected
  • time variable is collected
  • Global.process.env.PORT is undefined (among others)
  • after resuming, it stops on the lib/index.js:31 breakpoint
  • local variables are collected
  • Global.process.env.PORT is undefined (among others)

Debugging src in node 4.2.4

  • it stops on the src/other.js:5 breakpoint
  • local variables are collected
  • time variable is collected
  • Global.process.env.PORT is undefined (among others)
  • after resuming, it stops on the src/other.js:5 breakpoint
  • after resuming, it stops on an imaginary line src/other.js:13
  • after resuming, it stops on the src/index.js:8 breakpoint
  • local variables are collected
  • Global.process.env.PORT is undefined (among others)

Debugging lib in node 5.3.0

  • it stops on the lib/other.js:12 breakpoint
  • local variables are collected
  • time variable is collected
  • Global.process.env.PORT is undefined (among others)
  • after resuming, it stops on the lib/index.js:31 breakpoint
  • local variables are collected
  • Global.process.env.PORT is undefined (among others)

Debugging src in node 5.3.0

  • the debugger goes crazy...
  • it stops on src/index.js:9 and src/other.js:6 without calling the server, just after starting it
  • sometimes it stops on the src/index.js:8 breakpoint, but most of the time it skips both breakpoints
  • local variables are a mess and the ctx one shows a reference error

Final thoughts

  • the debugger works pretty well on both scenarios under node 4.2.4
  • it breaks really bad when it comes to raw code and sourcemaps under node 5.3.0
  • it works on transpiled code under node 5.3.0
  • some collected data (like environment variables) are always undefined
  • I'm not sure if this is the right way of adding the babel-polyfill since babel-node adds its own causing an error

Some links

About

Debugging issues and tips on WebStorm using Babel and Node 4/5

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published