Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

typescript+babel and coverage improvements #77

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

fasterthanlime
Copy link
Contributor

See #76

  • Drop [email protected] dependency, add babel-plugin-istanbul
  • Add getEnv() helper to SimpleCompilerBase
  • Support an environment string in the coverage option for both typescript and babel compilers
  • Make babel compiler use compilerContext as compile options
  • Drop sorcery dependency, pass inputSourceMap to babel instead
  • Always use babel+babel-plugin-istanbul to instrument code for measuring coverage
  • In ts+babel, translate ts sourcemap options to babel. With a twist, for
    inline sourcemaps.

See electron-userland#76

- Drop [email protected] dependency, add babel-plugin-istanbul
- Add getEnv() helper to SimpleCompilerBase
- Support an environment string in the `coverage` option for both typescript and babel compilers
- Make babel compiler use compilerContext as compile options
- Drop sorcery dependency, pass inputSourceMap to babel instead
- Always use babel+babel-plugin-istanbul to instrument code for measuring coverage
- In ts+babel, translate ts sourcemap options to babel. With a twist, for
inline sourcemaps.
@fasterthanlime
Copy link
Contributor Author

Quick update: using context to pass inputSourceMap breaks the inline html compiler. Fixing now

@fasterthanlime
Copy link
Contributor Author

Quick update: using context to pass inputSourceMap breaks the inline html compiler. Fixing now

Fixed in 262476a

@fasterthanlime
Copy link
Contributor Author

Another quick change I'm about to make: forward coverageInclude and coverageExclude keys to babel-plugin-instrument.

It's not possible to use the nyc block in package.json method unfortunately, because inputSourceMap is already passed directly to babel-plugin-instrument, so it doesn't even look at the package.json.

@fasterthanlime
Copy link
Contributor Author

Latest semantics:

  • code is only ever instrumented in testing (if you can think of a use case where one would like code to be instrumented in a non-test environment, let me know).
  • coverage: true does the same thing as before (except only in test)
  • coverage: { /* opts */ } passes options to babel-plugin-istanbul, like include and exclude, see documentation in fasterthanlime/electron-compile@4b23237

@fasterthanlime
Copy link
Contributor Author

New find! While babel:

  • will accept an inputSourceMap
  • will merge/combine/remap sourcemaps correctly
  • does have a sourceMaps: "inline" option

...if you specify inputSourceMap, sourceMaps is forced to true rather than "inline", so if you enable coverage on my branch, you don't get inline source maps. Fixing that now.

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

Successfully merging this pull request may close these issues.

1 participant