You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 95988b3
Browse filesBrowse the repository at this point in the historyBrowse files
feat(copy): add an ignore hook and never read from output.path (#22216)
* fix(copy): never read a file from inside output.path
A pattern whose base contains `output.path` copied the compilation's own
output back into itself, one directory deeper on every build: the watch
never settled and the output grew without bound. Exclude the output
directory from the walk, and do not watch a base that sits inside it.
* fix(copy): exclude a symlink resolving into output.path too
The lexical check saw only the link's own path, so a followed directory
symlink reached the output directory under a name it never matched.
Compare the resolved path where the walk already calls `realpath`.
* test(copy): cover a pattern whose own base is such a symlink
The alias case reaches the walk's check but not `walkBase`'s, which is
the one a `from` naming the link directly takes.
* feat(copy): add an ignore hook to CopyPlugin
Never reading from `output.path` is the right default, but it left a pattern
that deliberately read from there copying nothing and warning about it, with
no way to say otherwise. Give plugins the say instead, the way CleanPlugin's
`keep` hook does for what it deletes.
`CopyPlugin.getCompilationHooks(compilation).ignore` is consulted for every
path before `output.path` is: true ignores it, false copies it even from
inside the output directory, and nothing keeps webpack's answer. A directory
is answered like a file, because one that stays ignored is never walked — so
opting a subtree back in means answering the directory too.
The pattern's own `globOptions.ignore` still applies, so a plugin cannot
override what the user configured.
* fix(copy): exclude a file symlink resolving into output.path too
The symlink guard only reached directories. A followed link to a FILE is
reported by `stat` as a plain file and returned before anything canonicalizes
it, so the lexical check saw the link's own name and copied the build's own
output under it. A pattern naming such a link directly took the same path.
Reproduced before fixing: with output.path at static/build and a link
static/link.txt pointing into it, the copy emitted link.txt carrying the
stale output, and `from: static/link.txt` emitted named.txt/link.txt.
Resolve a followed file the same way a followed directory already is, in the
walk and for a directly named one. Reverting lib/CopyPlugin.js fails both new
assertions.
* fix(copy): skip the dependency for a base resolving into output.path
`walkBase` returns nothing for a base that resolves into the output directory,
but the dependency guard after it still read the base as written. A symlink
naming the output directory therefore copied nothing and was watched anyway,
so a write webpack made under output.path invalidated the build through the
alias.
Resolve the base once, before both, and let the guard read that. Reverting
lib/CopyPlugin.js fails the new assertion, which found the alias in
`contextDependencies`.
* fix(copy): copy a named symlink as a link when not following
`stat` follows the link, so a `from` naming one was classified as what it
points at: a `followSymlinks: false` read the target's bytes instead of
copying the link, which is what the same link reached through the walk gets.
* chore(changeset): note the named-symlink copy fix
* refactor(copy): make the ignore hook the one answer for a path
The hook sat inside the `output.path` check, so it overruled only that: a
`false` still lost to `globOptions.ignore`, and a followed symlink asked it
about the target's real path rather than the name the pattern reached it
under. It now answers first and alone, the way `CleanPlugin`'s `keep` does.
* chore(changeset): fold the copy changesets into one
* feat(copy): leave output.path to globOptions.ignore and the ignore hook
Reading from output.path can be intended, so it is no longer excluded by
default; a configuration opts out with globOptions.ignore or the hook.
* test(copy): cover lstat fallbacks and an ignored link when not following
* chore(changeset): keep the copy entry within 80 characters
* Answers whether a path is copied, ahead of `globOptions.ignore`: true never copies it, false copies it whatever `globOptions.ignore` says, and nothing leaves the decision to webpack. A directory has to be answered as well as the files below it, because one that is ignored is never walked.
0 commit comments