├── index.js ├── .babelrc ├── .gitignore ├── package.json └── README.md /index.js: -------------------------------------------------------------------------------- 1 | let x = y 2 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | {"presets": ["es2015"]} 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | compiled.js 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "babel-cli": "^6.4.5", 4 | "babel-plugin-transform-runtime": "^6.4.3", 5 | "babel-preset-es2015": "^6.3.13", 6 | "babel-register": "^6.4.3", 7 | "source-map-support": "^0.4.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # babel-runtime-wtf 2 | 3 | _(Should have been named babel-register-wtf, whoops)_ 4 | 5 | ## What am I doing wrong with babel-register? 6 | 7 | * Issue filed at 8 | 9 | ```bash 10 | $ npm install 11 | ... 12 | 13 | # This error doesn't make sense to me. Why is the initial line number 3? Why 14 | # does the code example show the transpiled code (var x = y;) instead of the 15 | # original code (let x = y)? 16 | 17 | $ node -r babel-register ./index 18 | /private/tmp/test/index.js:3 19 | var x = y; 20 | ^ 21 | 22 | ReferenceError: y is not defined 23 | at Object. (index.js:1:9) 24 | at Module._compile (module.js:435:26) 25 | at loader (/private/tmp/test/node_modules/babel-register/lib/node.js:130:5) 26 | at Object.require.extensions.(anonymous function) [as .js] (/private/tmp/test/node_modules/babel-register/lib/node.js:140:7) 27 | at Module.load (module.js:356:32) 28 | at Function.Module._load (module.js:311:12) 29 | at Function.Module.runMain (module.js:467:10) 30 | at startup (node.js:134:18) 31 | at node.js:961:3 32 | 33 | # If I compile index.js to compiled.js and then (in a separate step) run the 34 | # compiled code with sourcemap support, I get the stack trace I'm looking for. 35 | # Why don't I see this when compiling on-the-fly with babel-register? 36 | 37 | $ ./node_modules/.bin/babel --source-maps inline index.js --out-file compiled.js 38 | 39 | $ node -r source-map-support/register ./compiled 40 | 41 | index.js:1 42 | let x = y 43 | ^ 44 | ReferenceError: y is not defined 45 | at Object. (index.js:1:9) 46 | at Module._compile (module.js:435:26) 47 | at Object.Module._extensions..js (module.js:442:10) 48 | at Module.load (module.js:356:32) 49 | at Function.Module._load (module.js:311:12) 50 | at Function.Module.runMain (module.js:467:10) 51 | at startup (node.js:134:18) 52 | at node.js:961:3 53 | ``` 54 | --------------------------------------------------------------------------------