Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Importing babelHelpers messes up source maps #64

Closed
maxdavidson opened this issue Jun 23, 2016 · 3 comments
Closed

Importing babelHelpers messes up source maps #64

maxdavidson opened this issue Jun 23, 2016 · 3 comments

Comments

@maxdavidson
Copy link

maxdavidson commented Jun 23, 2016

As of v2.5.0, the babel helpers are imported as the virtual file __babelHelpers__. This messes up the source maps, since the path is apparently resolved to the root directory. Reverting to v2.4.0 fixes this.

{"version":3,"file":null,"sources":["../src/symbol.ts","../src/defaults.ts","../../../../../__babelHelpers__","../src/utils.ts","../src/index.ts"], ... }

This is very noticeable when doing coverage reports that utilize the source maps to map back to the original source. It also downright breaks coveralls, since it seems to check that all sources actually exist on disk.

➜  dynamic-typed-array git:(master) ✗ npm run test:coveralls

> dynamic-typed-array@0.1.2 test:coveralls /Users/maxdavidson/Developer/dynamic-typed-array
> cat coverage/lcov.info | coveralls

fs.js:634
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/__babelHelpers__'
    at Error (native)
    at Object.fs.openSync (fs.js:634:18)
    at Object.fs.readFileSync (fs.js:502:33)
    at convertLcovFileObject (/Users/maxdavidson/Developer/dynamic-typed-array/node_modules/coveralls/lib/convertLcovToCoveralls.js:18:18)
    at /Users/maxdavidson/Developer/dynamic-typed-array/node_modules/coveralls/lib/convertLcovToCoveralls.js:64:34
    at Array.forEach (native)
    at /Users/maxdavidson/Developer/dynamic-typed-array/node_modules/coveralls/lib/convertLcovToCoveralls.js:63:12
    at walkFile (/Users/maxdavidson/Developer/dynamic-typed-array/node_modules/lcov-parse/lib/index.js:103:9)
    at /Users/maxdavidson/Developer/dynamic-typed-array/node_modules/lcov-parse/lib/index.js:112:20
    at FSReqWrap.cb [as oncomplete] (fs.js:251:19)
@Rich-Harris
Copy link
Contributor

Thanks, good catch. Two parts to this: first, this plugin should use the convention of signifying a helper module with a \0 character, so __babelHelpers__ becomes \0babelHelpers. (That works because \0 is an illegal character in filenames and e.g. npm packages.) I've made that change and released it as 2.6.0.

Secondly, Rollup itself needs to exclude helper modules from the generated sourcemap – that's where rollup/rollup#747 comes in. As soon as that's released this should work correctly.

Slightly maddening that code coverage tools insist on seeing the sources on disk even if they're accounted for in sourcesContent – I've been bitten by that before.

@Rich-Harris
Copy link
Contributor

Have released 0.32.3, so if you reinstall rollup and rollup-plugin-babel this should be fixed now. Reopen if not! Thanks

@maxdavidson
Copy link
Author

Yes, that did it! Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants