Fixed issues with JSX.createElement definitions

This commit is contained in:
squidfunk
2017-02-25 14:49:49 +01:00
parent 7908140dc5
commit 672a39b697
39 changed files with 490 additions and 11627 deletions

View File

@@ -20,6 +20,7 @@
* IN THE SOFTWARE.
*/
import { transform } from "babel-core"
import jsdoc2flow from "flow-jsdoc"
import through from "through2"
@@ -37,9 +38,18 @@ export default (gulp, config) => {
if (file.isNull() || file.isStream())
return done()
/* Perform Babel transformation to resolve JSX calls */
const transformed = transform(file.contents.toString(), {
plugins: [
["transform-react-jsx", {
"pragma": "Jsx.createElement"
}]
]
})
/* Annotate contents */
file.contents = new Buffer(jsdoc2flow(
`/* @flow */\n\n${file.contents.toString()}`
`/* @flow */\n\n${transformed.code}`
).toString())
/* Push file to next stage */

View File

@@ -70,7 +70,7 @@ export default (gulp, config, args) => {
/* Provide JSX helper */
new webpack.ProvidePlugin({
JSX: path.join(process.cwd(), `${config.lib}/providers/jsx.js`)
Jsx: path.join(process.cwd(), `${config.lib}/providers/jsx.js`)
})
].concat(

View File

@@ -39,7 +39,7 @@ const format = eslint.getFormatter()
export default (gulp, config) => {
return () => {
return gulp.src(`${config.assets.src}/javascripts/**/*.js`)
return gulp.src(`${config.assets.src}/javascripts/**/*.{js,jsx}`)
/* Linting */
.pipe(