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
.
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 :)