Skip to content

Webpack entry cannot be found after importing filer #790

@thomas-jakemeyn

Description

@thomas-jakemeyn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions