metalsmith-webpack icon indicating copy to clipboard operation
metalsmith-webpack copied to clipboard

Unable to use plugin on Windows, project tests also failing

Open mattdsteele opened this issue 9 years ago • 3 comments

I'm trying to use this in a Metalsmith project I just started, but am getting an error regarding Invalid Paths on Windows.

It's reproducible in this project if I run npm test on my Windows machines. I see these failures:

  metalsmith-webpack
    1) should pack basic
    2) should pack complex


  0 passing (200ms)
  2 failing

  1) metalsmith-webpack should pack basic:
     Uncaught Error: Invalid path '\js\index.js'
      at pathToArray (C:\code\github\metalsmith-webpack\node_modules\memory-fs\lib\MemoryFileSystem.js:23:38)
      at MemoryFileSystem.readFileSync (C:\code\github\metalsmith-webpack\node_modules\memory-fs\lib\MemoryFileSystem.js:71:13)
      at C:\code\github\metalsmith-webpack\lib\index.js:20:34
      at Array.forEach (native)
      at C:\code\github\metalsmith-webpack\lib\index.js:16:48
      at Compiler.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:194:14)
      at Compiler.emitRecords (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:282:37)
      at Compiler.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:187:11)
      at C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:275:11
      at Compiler.applyPluginsAsync (C:\code\github\metalsmith-webpack\node_modules\tapable\lib\Tapable.js:60:69)
      at Compiler.afterEmit (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:272:8)
      at Compiler.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:267:14)
      at C:\code\github\metalsmith-webpack\node_modules\async\lib\async.js:52:16
      at Object.async.forEachOf.async.eachOf (C:\code\github\metalsmith-webpack\node_modules\async\lib\async.js:236:30)
      at Object.async.forEach.async.each (C:\code\github\metalsmith-webpack\node_modules\async\lib\async.js:209:22)
      at Compiler.emitFiles (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:235:20)
      at MemoryFileSystem.(anonymous function) [as mkdirp] (C:\code\github\metalsmith-webpack\node_modules\webpack\node_modules\memory-fs\lib\MemoryFileSystem.js:283:10)
      at Compiler.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:229:25)
      at Compiler.applyPluginsAsync (C:\code\github\metalsmith-webpack\node_modules\tapable\lib\Tapable.js:60:69)
      at Compiler.emitAssets (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:226:7)
      at Compiler.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:184:10)
      at C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:403:12
      at Compiler.next (C:\code\github\metalsmith-webpack\node_modules\tapable\lib\Tapable.js:67:11)
      at Compiler.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\CachePlugin.js:40:4)
      at Compiler.applyPluginsAsync (C:\code\github\metalsmith-webpack\node_modules\tapable\lib\Tapable.js:71:13)
      at Compiler.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:400:9)
      at Compilation.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compilation.js:577:13)
      at Compilation.applyPluginsAsync (C:\code\github\metalsmith-webpack\node_modules\tapable\lib\Tapable.js:60:69)
      at Compilation.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compilation.js:572:10)
      at Compilation.applyPluginsAsync (C:\code\github\metalsmith-webpack\node_modules\tapable\lib\Tapable.js:60:69)
      at Compilation.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compilation.js:567:9)
      at Compilation.applyPluginsAsync (C:\code\github\metalsmith-webpack\node_modules\tapable\lib\Tapable.js:60:69)
      at Compilation.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compilation.js:563:8)
      at Compilation.applyPluginsAsync (C:\code\github\metalsmith-webpack\node_modules\tapable\lib\Tapable.js:60:69)
      at Compilation.seal (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compilation.js:525:7)
      at Compiler.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compiler.js:397:15)
      at C:\code\github\metalsmith-webpack\node_modules\tapable\lib\Tapable.js:103:11
      at Compilation.<anonymous> (C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compilation.js:445:10)
      at C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compilation.js:417:12
      at C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compilation.js:332:10
      at C:\code\github\metalsmith-webpack\node_modules\async\lib\async.js:52:16
      at done (C:\code\github\metalsmith-webpack\node_modules\async\lib\async.js:246:17)
      at C:\code\github\metalsmith-webpack\node_modules\async\lib\async.js:44:16
      at C:\code\github\metalsmith-webpack\node_modules\webpack\lib\Compilation.js:332:10
      at C:\code\github\metalsmith-webpack\node_modules\async\lib\async.js:52:16
      at done (C:\code\github\metalsmith-webpack\node_modules\async\lib\async.js:246:17)
      at C:\code\github\metalsmith-webpack\node_modules\async\lib\async.js:44:16

  2) metalsmith-webpack should pack complex:
     Uncaught Error: ENOENT, no such file or directory 'C:\code\github\metalsmith-webpack\test\fixtures\basic\build'
      at Object.fs.lstatSync (fs.js:679:18)
      at read (C:\code\github\metalsmith-webpack\node_modules\fs-readdir-recursive\index.js:12:10)
      at assertDirEqual (C:\code\github\metalsmith-webpack\node_modules\assert-dir-equal\lib\index.js:24:19)
      at Metalsmith.<anonymous> (C:\code\github\metalsmith-webpack\test\index.js:41:17)
      at Object._onImmediate (C:\code\github\metalsmith-webpack\node_modules\co\index.js:52:14)

Tested on two Windows machines, one with node 0.10.26, one with node 5.1.0. Running on a Mac with node 0.12.7 works fine.

The version of webpack pulled down is 1.12.9. If I run webpack standalone using the same configuration in my project, it works fine.

I'm not super familiar with how the plugin runs, but I'm guessing there was an API change in Webpack for Windows machines that the Metalsmith plugin doesn't handle?

mattdsteele avatar Dec 05 '15 00:12 mattdsteele

These errors are generated by MemoryFileSystem which is no longer used in v2.

leviwheatcroft avatar May 12 '17 22:05 leviwheatcroft

@leviwheatcroft Hi.The only solution is upgrade to webpack2?

NE-SmallTown avatar May 29 '17 05:05 NE-SmallTown

v2 branch in this repo uses webpack 2, and has a variety of other improvements.

You can install with npm i --save github://christophercliff/metalsmith-webpack#v2.

It's stable, I'm using it in several production projects. Only reason it's not published on npm yet is because I don't have collaborator (publish) access on npm.

leviwheatcroft avatar May 29 '17 07:05 leviwheatcroft