Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

TypeError: Property 'mkdirpSync' of object #<Object> is not a function #4

Closed
kisenka opened this issue Jun 30, 2015 · 5 comments
Closed

Comments

@kisenka
Copy link

kisenka commented Jun 30, 2015

I am getting following error when starts webpack-dev-server:

TypeError: Property 'mkdirpSync' of object #<Object> is not a function
    at MemoryFileSystem.(anonymous function) (node_modules/webpack-dev-server/node_modules/webpack-dev-middleware/node_modules/memory-fs/lib/MemoryFileSystem.js:193:34)
    at Tapable.<anonymous> (node_modules/webpack-stats-plugin/lib/stats-writer-plugin.js:68:5)
    at Tapable.applyPluginsAsync (node_modules/webpack/node_modules/tapable/lib/Tapable.js:71:13)
    at Tapable.afterEmit (node_modules/webpack/lib/Compiler.js:270:8)
    at Tapable.<anonymous> (node_modules/webpack/lib/Compiler.js:265:14)
    at done (node_modules/webpack/node_modules/async/lib/async.js:132:19)
    at node_modules/webpack/node_modules/async/lib/async.js:32:16
    at MemoryFileSystem.writeFile (node_modules/webpack-dev-server/node_modules/webpack-dev-middleware/node_modules/memory-fs/lib/MemoryFileSystem.js:224:9)
    at Tapable.writeOut (node_modules/webpack/lib/Compiler.js:259:27)
    at Tapable.<anonymous> (node_modules/webpack/lib/Compiler.js:245:20)

Looks like it memory-fs issue but, maybe, you can help me with it?
Btw, It really cool feature to write stats file to memory fs! :)

@ryan-roemer
Copy link
Member

@kisenka -- Have you tried writing other webpack output to memory-fs? I've wanted to slightly retool this plugin to just add the stats output as a file like normal JS bundles are emitted and that ideally would just solve your issue too...

@kisenka
Copy link
Author

kisenka commented Jun 30, 2015

@ryan-roemer yes, with the same result :( As the temporary solution I write stats file to the ordinary file system and seems like its the only way to deal with it.

@ryan-roemer
Copy link
Member

@kisenka -- Let me see what I can do ;) This is a use case that makes sense to support.

If there were no mkdirpSync call, would it otherwise work? (Off the top of my head, I could infer if there was any path delimiter like / and not do the mkdirpSync call if no delimiters...)

@kisenka
Copy link
Author

kisenka commented Jun 30, 2015

@ryan-roemer if there is no mkdirpSync call it quits with Path doesn't exist error. Here is my experiment.

webpack.config.js:

var path = require('path');
var MemoryFs = require('webpack-dev-server/node_modules/webpack-dev-middleware/node_modules/memory-fs/lib/MemoryFileSystem');

...

{
  plugins: [
    {
      apply: function (compiler) {
        var targetPath = path.join(__dirname, '_assets', 'qwe'); // your custom path

        compiler.plugin('after-emit', function (curCompiler, callback) {
          var stats = curCompiler.getStats().toJson().assetsByChunkName;
          var fs = compiler.outputFileSystem;

          console.log(compiler.outputFileSystem instanceof MemoryFs); // true

          fs.mkdirpSync(targetPath, function (err) {
            if (err) console.log(err);

            fs.writeFileSync(path.join(targetPath, 'test.json'), JSON.stringify(stats), 'utf-8', function() {});
          });

        });
      }
    }
  ]
}

If you run webpack with this config - it works great, file _assets/qwe/test.txt will be created. But with webpack-dev-server it causes an error.

Maybe @sokra can help us with this issue? :)

@ryan-roemer
Copy link
Member

Fixed in v0.1.0.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants