SimonDegraeve / hapi-webpack-plugin

Webpack middleware for Hapi. Supports HMR.
57 stars 25 forks source link

webpack.config.js with ES6 exports does not work #8

Open ljani opened 8 years ago

ljani commented 8 years ago

Consider the example someone else posted: https://github.com/adam-beck/hapi-plz

If you apply this patch, everything breaks although ES6 exports should work with "the second way" mentioned in usage:

diff --git a/package.json b/package.json
index fb601cc..1249129
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
   "description": "",
   "main": "index.js",
   "scripts": {
-    "dev": "node dev-server.js",
+    "dev": "babel-node dev-server.js",
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "keywords": [],
@@ -21,6 +21,7 @@
     "webpack": "^1.13.0"
   },
   "dependencies": {
+    "babel-cli": "^6.8.0",
     "hapi": "^13.3.0",
     "react": "^15.0.1",
     "react-dom": "^15.0.1"
diff --git a/webpack.config.js b/webpack.config.js
index ae00368..c5e09aa 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -3,7 +3,7 @@ const webpack = require('webpack');

 const HtmlWebpackPlugin = require('html-webpack-plugin');

-module.exports = {
+export default ({
   entry: [
     'webpack-hot-middleware/client',
     './src/index.js'
@@ -34,4 +34,4 @@ module.exports = {
       colors: true
     }
   }
-};
+});

The error is:

C:\devel\hapi-plz\node_modules\webpack-dev-middleware\middleware.js:106
                        if(err) throw err;
                                ^
 Error: invalid argument
    at pathToArray (C:\devel\hapi-plz\node_modules\memory-fs\lib\MemoryFileSystem.js:44:10)
    at MemoryFileSystem.mkdirpSync (C:\devel\hapi-plz\node_modules\memory-fs\lib\MemoryFileSystem.js:139:13)
    at MemoryFileSystem.(anonymous function) [as mkdirp] (C:\devel\hapi-plz\node_modules\memory-fs\lib\MemoryFileSystem.js:279:34)
    at Compiler.<anonymous> (C:\devel\hapi-plz\node_modules\webpack\lib\Compiler.js:229:25)
    at Compiler.applyPluginsAsync (C:\devel\hapi-plz\node_modules\tapable\lib\Tapable.js:60:69)
    at Compiler.emitAssets (C:\devel\hapi-plz\node_modules\webpack\lib\Compiler.js:226:7)
    at Watching.<anonymous> (C:\devel\hapi-plz\node_modules\webpack\lib\Compiler.js:54:18)
    at C:\devel\hapi-plz\node_modules\webpack\lib\Compiler.js:403:12
    at Compiler.next (C:\devel\hapi-plz\node_modules\tapable\lib\Tapable.js:67:11)
    at Compiler.<anonymous> (C:\devel\hapi-plz\node_modules\webpack\lib\CachePlugin.js:40:4)
    at Compiler.applyPluginsAsync (C:\devel\hapi-plz\node_modules\tapable\lib\Tapable.js:71:13)
    at Compiler.<anonymous> (C:\devel\hapi-plz\node_modules\webpack\lib\Compiler.js:400:9)
    at Compilation.<anonymous> (C:\devel\hapi-plz\node_modules\webpack\lib\Compilation.js:577:13)
    at Compilation.applyPluginsAsync (C:\devel\hapi-plz\node_modules\tapable\lib\Tapable.js:60:69)
    at Compilation.<anonymous> (C:\devel\hapi-plz\node_modules\webpack\lib\Compilation.js:572:10)
    at Compilation.applyPluginsAsync (C:\devel\hapi-plz\node_modules\tapable\lib\Tapable.js:60:69)

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\opt\\node\\node.exe" "C:\\opt\\node\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.7
npm ERR! code ELIFECYCLE
npm ERR! hapi-plz@1.0.0 dev: `babel-node dev-server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hapi-plz@1.0.0 dev script 'babel-node dev-server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the hapi-plz package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     babel-node dev-server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs hapi-plz
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls hapi-plz
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\devel\hapi-plz\npm-debug.log

Any ideas how to setup this with Babel? Everything works fine if I use the plugin via "the first way"

AYapejian commented 8 years ago

Seeing the same issue, just started checking it out I'll update if I find something worthwhile.

FullStackForger commented 7 years ago

Is there any update on this one?

Kamahl19 commented 5 years ago

It seems this package is unmaintained so I decided to rewrite it in TS and fix all the issues. You can find it here https://github.com/Kamahl19/hapi-webpack-plugin-2