Closed hydrotik closed 8 years ago
It looks like you are missing the babel require hook. If you are using babel 6, you must have at least the jsx plugin enabled.
Doesn't seem to be using 6 yet:
"babel-core": "^5.8.25",
"babel-eslint": "^4.1.3",
"babel-loader": "^5.3.2",
"babel-plugin-rewire": "^0.1.22",
"babel-plugin-typecheck": "^1.3.0",
"babel-runtime": "^5.8.25",
The views must be compiled before this plugin gets them. The error is due to the fact that node is seeing the jsx file before then (the invalid '<' gives it away). You must either precompile the templates as a build step or use https://babeljs.io/docs/usage/require in your code.
All set thanks!
After getting this working and then moving the setup to the manifest and using visionary, I am back to the unexpected token issue. I'm pretty sure I have everything included and moved over from what was working.
plugins: {
inert: {},
vision: {},
visionary: {
engines: {
jsx: "hapi-react-views"
},
compileOptions: {
useNodeJsx: false
},
relativeTo: __dirname,
path: "./src/global/server/views/"
}
, './global/server/views/home': {}
, './global/server/api/index': {}
}
I am also still including the babel hook:
require('babel-core/register')({});
and .babelrc is still the same:
{
"presets": ["es2015", "react", "stage-0"],
"plugins": [
"transform-react-jsx",
"syntax-jsx"
]
}
And getting:
[1] Debug: internal, implementation, error
[1] SyntaxError: /myproject/src/global/server/views/home/Index.jsx: Unexpected token (16:12)
[1] 14 |
[1] 15 | return(
[1] > 16 | <html>
[1] | ^
[1] 17 | <head>
[1] 18 |
[1] 19 | <meta charSet="utf-8"></meta>
Seems like it could be related to https://github.com/jedireza/hapi-react-views/pull/32
Changed to:
require('babel-core/register')({
presets: ['react', 'es2015']
});
Thanks @tanepiper!
Should probably update the README as well.