-
Notifications
You must be signed in to change notification settings - Fork 65
Upgrading from babel-istanbul-loader, build fails with JSX #44
Comments
really weird, it should use the same Babel with |
@deepsweet Here's the error I get:
This is my import 'babel-polyfill';
import App from './app.jsx';
import AppStore from './store/AppStore';
import {Provider} from 'react-redux';
import React from 'react';
import {render} from 'react-dom';
const appStore = new AppStore();
render(
<Provider store={appStore}>
<App />
</Provider>, document.getElementById('app')
); |
Having this exact issue as well. I've got the {
test: /\.js$|\.jsx$/,
enforce: 'pre',
exclude: /node_modules|test/,
loader: 'istanbul-instrumenter-loader',
query: {
esModules: true,
presets: ['react']
}
} |
Any idea on this one? I'd like to upgrade to webpack2, but I don't wanna lose code coverage. |
looks like there should additional |
Since babylon doesnt expect plugins or presets, doesn't it seem like the instrumenter is expecting already-transpiled code? How did this work before with JSX/ES6? Was the code already transpiled before it got to the instrumenter? |
this one didn't work before with JSX/ES6 :) that's why we had babel-istanbul-loader and isparta-loader. |
Hmm, what should we do now since both those packages have been deprecated? |
they are deprecated because now we finally have "an official" solutiuon, new Istanbul integrated with Babel, but code coverage is a forever pita I personally have no idea how do they want to transpile it directly with Babylon and allow you to use any non-default transforms like JSX, Flow, etc at the same time. |
I'll give that a shot, thanks! |
@bencripps How did it go? |
I have tried this and this does not work well for us. This used to work with webpack 1 and the old "loader: 'babel-istanbul". We used this in the "preloader" stage, which correctly instrumented the es6/jsx code and coverage was correct. After upgrading to webpack 2 and now using the istanbul-instrumenter-loader it only works in the "post" stage, which to me seems incorrect. It's not desired to get coverage on transpiled code, since this code is not the original, its created by babel. If used in the "pre" stage it gets the error Unexpected Token as if it doesnt support JSX - but how did babel-instanbul support that? Whats the major difference here? I am also curious why it seems to be working for bencripps, I mean... is your coverage really correct, on the transpiled code? Do you get undefined line numbers in the report? |
I solved the problem regarding jsx support in pre-stage in istanbul-lib-instrument, will fork or try to get a pr through there. |
Sorry to butt in on this tthread - my question is for @Axbon
But npm fails with:
I might be wrong, but I think you might need to point your temp dependency url for istanbul-lib-instrument to your commit #c50e2cb rather than 1.4.2? e.g.
|
Ah true, anyway that fork was a temporary thing just to get JSX support added. I am happy to report that it has now landed in istanbul-lib-instrument@1.7.0 , perhaps @deepsweet could update the dependency so that jsx works, otherwise happy to send pr :) |
Hey @Axbon, I tried using istanbul-lib-instrument@1.7.0 still not working for jsx code. |
@kulakshay seems like they made a change and moved the istanbul-lib-instrument, it now says: deprecated, instead use https://github.com/istanbuljs/istanbuljs so I suppose the dependency has to be updated there, and I verified that the jsx support is indeed merged into that codebase, not the other one however. Sorry for the confusion! The code can be found here: https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-lib-instrument and I guess this repo has to be updated, so that the instrumenter is imported from istanbuljs instead. |
Thanks @Axbon! |
That is a good question, I suppose the guys behind istanbuljs have to re-publish to npm so that the package comes from their "monorepo" since it was migrated there. There appears to be no "istanbuljs" on npm where you would get access to all packages there :( I'll try to find out |
Thanks @Axbon, my current status is I can generate report in 'post' mode, but 'pre' mode is still not working. |
My coverage dropped about 10% while upgrading from Unable to change to pre without though.. EDIT: EDIT 2: You can check my repo with the implementation (webpack line). documentation should be updated to state the solution. |
@unimonkiez I'll definitely give it a shot, thanks !!! |
The recommended path to getting babel + istanbul instrumentation to work is to use the babel plugin to instrument your code, rather than this loader. Just remove this loader and add that babel plugin to your babel config when testing and everything should work great! 😄 |
This brings manager and docs up to the latest version of webpack 2.6 release. It will allow for future improvements that are only available in webpack 2+. Changes include: - Updated syntax for webpack loaders. [link](https://webpack.js.org/guides/migrating/#module-loaders-is-now-module-rules) - Use the babel-plugin-istanbul to instrument code for tests, as per recommendation by the webpack-contrib team. [link](webpack-contrib/istanbul-instrumenter-loader#44 (comment)) - Use `cross-env` for all npm scripts to improve compatibility.
* upgrade webpack to ^2.6.0 This brings manager and docs up to the latest version of webpack 2.6 release. It will allow for future improvements that are only available in webpack 2+. Changes include: - Updated syntax for webpack loaders. [link](https://webpack.js.org/guides/migrating/#module-loaders-is-now-module-rules) - Use the babel-plugin-istanbul to instrument code for tests, as per recommendation by the webpack-contrib team. [link](webpack-contrib/istanbul-instrumenter-loader#44 (comment)) - Use `cross-env` for all npm scripts to improve compatibility. * revert to npm test scripts without cross-env * update missed loader config to use
I saw that babel-istanbul-loader was deprecated and was pointed to this library as the upgrade. My webpack now fails to build if there is JSX syntax in code.
Does istanbul-instrumenter-loader support react JSX? Do I need any other changes?
Previous config from babel-istanbul-loader:
new config with istanbul-instrumenter-loader:
.babelrc
The text was updated successfully, but these errors were encountered: