Skip to content

SymlinkPlugin's behavior has changed since Webpack 5 #287

@mjameswh

Description

@mjameswh

In webpack 4, when SymlinkPlugin identified that a requested path indeed contained a symlink, it would invoke hook relative with the canonical path.

if (symlinks) plugins.push(new SymlinkPlugin("file", "relative"));

However, in Webpack 5, this behavior was changed to:

if (symlinks)
plugins.push(new SymlinkPlugin("existing-file", "existing-file"));

This modification was done in the process of adding support for Yarn PnP, though it seems that this might have been unintentional. See notably sokra's comment on this regard here. It should also be noted that this specific change does not appear in the final PR.

This undocumented change of behavior affects some external plugins that relied on early hooks to be invoked after symlink resolution, notably Gatsby's theme shadowing (see related Gastby issue).

My first impression is that this specific change should be reverted back and I will soon submit a PR in this direction.

On the other side, it means that any plugin that relies on the former behavior would not support Yarn PnP; there might also be a non negligeable performance cost to redo a part of the resolution pipeline after symlink resolution. Consequently, somes could argue that restoring the former behavior is not desirable. If this is indeed the official position, however, then I suggest that this should be clearly mentioned in Webpack release notes.

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