filer: Webpack entry cannot be found after importing filer

Context

I am trying to add FilerWebpackPlugin to an existing Webpack configuration.

Problem

As soon as I require('filer'), Webpack starts failing because it cannot find the entry file anymore.

Analysis

This problem seems to be caused by a side effect in src/path.js:

/**
 * Patch process to add process.cwd(), always giving the root dir.
 * NOTE: this line needs to happen *before* we require in `path`.
 */
process.cwd = () => '/';

Workaround

The only workaround that I found is to save process.cwd before importing filer, and to restore it afterwards.

const cwd = process.cwd;
const filer = require('filer');
process.cwd = cwd;

With this fix, Webpack is able to find the entry file again.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (12 by maintainers)

Commits related to this issue

Most upvoted comments

No problem!

@humphd shall we proceed with PR #793 so we can close this issue?

EDIT: I have seen the other issue about the shims not being present in the version distributed through npm - don’t have time to address that until this evening or tomorrow but we should probably ship any fix for that with the fix for this issue imo