2
npm i babel-cli babel-preset-env
echo '{"presets": ["env"]}' > .babelrc
printf "import u from 'util';\ndebugger;\nconsole.log(u);\n" > foo.es
babel-node --inspect-brk foo.es

Continue to breakpoint F8 and inspect u. You get a ReferenceError: u is not defined.

daxim
  • 39,270
  • 4
  • 65
  • 132

1 Answers1

1

Run:

npm install --save-dev babel-plugin-transform-es2015-modules-commonjs-simple

Then, add it to your .babelrc:

{
  "presets": [
      "env"
  ],
  "plugins": [
    ["transform-es2015-modules-commonjs-simple", {
       "noMangle": true
    }]
  ]
}

With noMangle: true the original variable names are preserved in sourcemaps.

Then run:

babel-node --inspect foo.es

Your variable u is there :)

calbertts
  • 1,513
  • 2
  • 15
  • 34