pux-starter-app
pux-starter-app copied to clipboard
Broken in Windows environment
So I am following your instructions on the Readme, but I get an odd error when I run npm start:
pux-example master* $ npm start
> [email protected] start C:\Purescript\experiments\pux-example
> gulp watch
[20:44:22] Using gulpfile C:\Purescript\experiments\pux-example\gulpfile.js
[20:44:22] Starting 'clean'...
[20:44:22] Finished 'clean' after 113 ms
[20:44:22] Starting 'watch'...
[20:44:22] [webpack] Building...
[20:44:28] [webpack] Build finished.
Hash: 2ad8de32c52e979028a0
Version: webpack 1.12.13
Time: 5848ms
Asset Size Chunks Chunk Names
js/bundle.js 660 kB 0 [emitted] main
ERROR in ./src/purs/Client.purs
Module not found: Error: Cannot resolve module '....outpuundle.js' in C:\Purescript\experiments\pux-example\src\purs
@ ./src/purs/Client.purs 1:17-50
ERROR in ./src/purs/Server.purs
Module not found: Error: Cannot resolve module '....outpuundle.js' in C:\Purescript\experiments\pux-example\src\purs
@ ./src/purs/Server.purs 1:17-50
ERROR in ./src/purs/State.purs
Module not found: Error: Cannot resolve module '....outpuundle.js' in C:\Purescript\experiments\pux-example\src\purs
@ ./src/purs/State.purs 1:17-50
Seems like a file name is getting truncated somewhere, but I don't know enough about this set-up to know where to look. Have you ever seen behavior like this before?
Hrm... I'm not able to reproduce those exact errors. Using a fresh clone I was getting an entirely different set of errors I have no seen before. I didn't spend much time to investigate – I suspect this has to do with dependencies not being pinned and purescript 0.8.0. Anyways, I've pushed an update for purescript 0.8.0, and doing a fresh clone npm install
then npm start
is working for me now. Could you confirm?
I will check it out today. For some reason I suspected that it had something to do with how the purescript webpack plugin was creating the output file path on Windows (I am using Windows 7 at the moment). It seems to use path.join
under the hood which shouldn't be creating platform issues, but when you look at that truncated name "outpuundle"...
Ok, so I cloned the new version and the same issue is still happening. I was able to isolate where the errors are coming from, but I don't know enough about the webpack build process to figure out what is causing them. The last few lines of dist/bundle.js is where the errors are being thrown from. The code is below. The truncating file name doesn't seem to be the cause of the issue, but just a byproduct of the way the error code is written (windows path separator is '\'). Here is the code generated at the bottom of dist/bundle.js:
/* 158 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"....output\bundle.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))['Client'];
/***/ },
/* 159 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"....output\bundle.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))['Server'];
/***/ },
/* 160 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"....output\bundle.js\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()))['State'];
/***/ },
/* 161 */
Hrm... it seems the issue is originating from purescript-webpack-plugin, which spawns a child process of psc-bundle
and specifies output/bundle.js
in the arguments. require('child_process').spawn
is a notorious source of cross-platform issues because it's essentially just calling out to the CLI. Looking at the code for purescript-webpack-plugin nothing immediately jumps out at me though.
I have very little Windows experience, so setting up a VM with a Windows 7 development environment will take me some time...
On second thought, if it was a problem with spawning the child process the bundle would not finish as it did in the output you pasted above. It could also be an issue with the babel-loader or purs-loader plugins..
Yes, it appears that on first run that the three purs files throwing errors are indeed being found and built by the plugin as I can see their compiled JavaScript counterparts in the output folder. But perhaps webpack is failing to find them when it assembles everything together? Again, my experience with webpack is about 12 hours in total.
Adam