-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
snapshot throw error with V8 #8
Comments
Hi, there. I'm dealing with the same issue when using Limenius/ReactBundle to do SSR with my Symfony 4 + Create React App. Here's some info :
The index.js looks like this import ReactOnRails from 'react-on-rails';
import App from './App';
ReactOnRails.register({ App }); And App.jsx import React from 'react';
function App() {
return <h1>Hello, world!</h1>;
}
export default App; Do you need more info to solve this issue ? |
can you show me your serverside config, for me production build dont work too |
It's based on facebook/create-react-app so the configurations are the one used by react-scripts. https://github.com/facebook/create-react-app/tree/next/packages/react-scripts/config |
i'm using symfony/encore like the symfony_react_sandbox and last time i tried both prod and dev throw me the error. var Encore = require('@symfony/webpack-encore');
var webpack = require('webpack')
Encore
// directory where all compiled assets will be stored
.setOutputPath('app/Resources/webpack')
// what's the public path to this directory (relative to your project's document root dir)
.setPublicPath('/')
// empty the outputPath dir before each build
.cleanupOutputBeforeBuild()
// will output as web/build/app.js
.addEntry('server-bundle', ['babel-polyfill',
'./client/client.js'
])
// allow legacy applications to use $/jQuery as a global variable
// .enableReactPreset()
if(Encore.isProduction()){
Encore.addPlugin(new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}))
}
// export the final configuration
//module.exports = Encore.getWebpackConfig();
var config = Encore.getWebpackConfig();
config.watchOptions = { poll: true, ignored: /node_modules/ };
module.exports = config; |
i guess this should come from non declared global variable that react should use, but seem your configuration load them somewhere for prod ... if i could get prod working with V8js, i could use node during dev x') |
OK, I'll keep you posted if I find a solution to have the development build working. Thank you. |
if i can make production work, i guess we can add a snapshot parameter who is default to false, and be true if we are on production env (with app.php in sf3) or APP_EVN=prod (on sf4), i'm pretty sure the v0.8.8 function createContext work for you too, i'm trying to make my prod working with v8 and i'll try make a PR for this, and hoping nacmartin will see our issues x'). |
try replace directly in your vendor the createContext function from phpexecJs (vendor/nacmartin/PhpExecJs/Runtime/V8jsRuntime.php) by the exemple from v0.8.8 i writed above to be sure that we get the same issue. (ofc revert change after this or simply re-install your vendor by deleting vendor folder and re-launching a composer install after) |
i "solved" the prob by removing the \V8Js::createSnapshot($code);
if you get a SSR working with \V8Js::createSnapshot($code); please give the version or additional optional requierement you setted up for V8
here is my dockerfile for get a exemple of my V8js installation (used https://github.com/phpv8/v8js/blob/php7/README.Linux.md )
note that everything working with node installed instead of V8js for SSR or with skipping \V8Js::createSnapshot($code); during SSR
i just tryed
this do not throw an error, that appear the error should come from react or any dependency.
I get the same error when i'm using your symfony 4 react sandbox (phpExecJs ^2.0.0)
The text was updated successfully, but these errors were encountered: