Doesn't recognize static properies
roastedfrost-zz opened this issue · 4 comments
roastedfrost-zz commented
fails on
class Klass {
static props = {
prop: 'value'
}
}
but ok with
class Klass {
}
Klass.props = {
prop: 'value'
};
Used with babel-istanbul-instrumenter-loader (with updated babel-istanbul dependency).
jeffrifwald commented
Hi @roastedfrost,
By fails, do you mean it won't even run or it produces incorrect instrumentation? Also, what version of babel are you using? Thanks!
roastedfrost-zz commented
Hi @jmcriffey,
I'm using babel-core v. 5.8.38. It fails with syntax error (unexpected token) and without coverage output.
"babel-core": "5.8.38",
"babel-istanbul-instrumenter-loader": "1.0.1",
"babel-loader": "5.4.2",
"babel-polyfill": "6.13.0",
"babel-runtime": "5.8.38",
But there aren't fails with static props during code execution, only for code instrumentation.
jeffrifwald commented
Try adding a semicolon to the end of your static prop. Also make sure you are using babel-plugin-transform-class-properties
.
class Klass {
static props = {
prop: 'value'
};
}
roastedfrost-zz commented
I'm sorry, everything is ok! I forgot to pass babel config into instrumenter.
var babelConfig = {
presets: [
[require.resolve('babel-preset-es2015'), {loose: true}],
require.resolve('babel-preset-stage-0'),
require.resolve('babel-preset-react')
],
plugins: [
require.resolve('babel-plugin-add-module-exports'),
require.resolve('babel-plugin-transform-decorators-legacy'),
require.resolve('babel-plugin-transform-class-properties')
]
};
return instrumenter.instrumentSync(source, this.resourcePath, babelConfig);