Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

SyntaxError: Unexpected end of JSON input #4

Closed
stuartjnelson opened this issue Sep 12, 2018 · 3 comments
Closed

SyntaxError: Unexpected end of JSON input #4

stuartjnelson opened this issue Sep 12, 2018 · 3 comments

Comments

@stuartjnelson
Copy link

"webpack": "^4.18.0"
"webpack-php-loader": "^0.5.0"
macOS 10.13.6
ERROR in ./index.php
Module build failed (from (webpack)-php-loader/index.js):
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at runPhp (/my/project/path/node_modules/webpack-php-loader/index.js:69:10)

On line 69 of the plugin there is;

JSON.parse(dependencies).forEach(function(dependency) {
    self.addDependency(dependency)
});

My index.php file works fine when being served on it's own. Any ideas what this could be? Is it an issue with the plugin not being compatible with Webpack 4?

@devthejo
Copy link
Member

The role of this code snippet is to add all required php files and add them as dependencies files to webpack (for recompliation on files changes), but if php throw a fatal error before end of stack, the dependencies can't be getted
I've not the time to add a try{} catch{} block around and eventually a shutdown callback to catch fatal error, but if you want, you can try to fork the repo and propose a pull request ;)
else you can always ensure that your php code is executed without errors before trying to load it with webpack-php-loader
on the other hand I developped it on webpack 3 and never tested on webpack 4, but I see no reason that can break it

@stuartjnelson
Copy link
Author

Hi @TakioN,

Thanks for the super fast reply! Let me double check my PHP as I was pretty sure it was fine... If that isn't the case I'll see if I can get time at work to have a look at the codebase.

Aside from creating broken PHP code are they any other things you can think of that could be the cause?

@devthejo
Copy link
Member

Hi @stuartjnelson, at first glance no, but let me know if you find another bug origin

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants