Webpack-cli: caching failures with webpack serve when pointing to a specific config file

Created on 18 Nov 2020  Â·  11Comments  Â·  Source: webpack/webpack-cli


Bug report




What is the current behavior?

If you change the name of your webpack configuration file and specify it with webpack serve --config [filename] you get caching errors in the console..

ℹ 「wdm」: Compiled with warnings.
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Can't resolve 'webpack.launcher.js' in '/Users/xxx/Projects/xxx/src/shell'
<w> while resolving 'webpack.launcher.js' in /Users/xxx/Projects/xxx/src/shell as file

If the current behavior is a bug, please provide the steps to reproduce.

Setup a webpack dev configuration where configuration X in extends from another configuration and merged though webpack merge. (Though i don't think this is absolutely necessary). Ensure that the configuration has file caching turned on.

  cache: {
    name: 'shell',
    type: 'filesystem',
    cacheDirectory: path.resolve(__dirname, '../..', '.cache'),
    buildDependencies: {
      config: [path.resolve(__dirname, 'webpack.common.js'), path.resolve(__filename)],
    },
  },

Launch webpack serve --config webpack.launcher.js. This throw the above error. If however, you rename this file to webpack.config.js and run without --config. It will work.






What is the expected behavior?

Should be able to name a webpack configuration file anything I want and point to it with --config when running webpack serve and filesystem caching should not be affected.


Other relevant information:
webpack version: 5.3.2
Node.js version: v12.19.0
Operating System: OSX
Additional tools:

Bug

Most helpful comment

@sppatel not released yet, ETA is today/tomorrow

All 11 comments

For maintainers only:

  • [ ] webpack-4
  • [ ] webpack-5
  • [ ] bug
  • [ ] critical-bug
  • [ ] enhancement
  • [ ] documentation
  • [ ] performance
  • [ ] dependencies
  • [ ] question

Please create reproducible test repo, can't reproduce

Ok, will do.. give me a day to put it togather.

@evilebottnawi attached is reproducible test case.

(1) Extract archive
(2) cd test-case
(3) yarn install
(4) yarn launch-works (This path works)
(5) kill process from webpack/webpack#4
(6) yarn launch-broken (This path shows an error)

ℹ 「wdm」: Compiled successfully.
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Can't resolve 'webpack.launcher.js' in '/Users/xxx/Projects/test-case'
<w> while resolving 'webpack.launcher.js' in /Users/xxx/Projects/test-case as file

The difference between 4 and 6 is the use of --config but the contents of the file are the same in each case.

test-case.zip

Yes, bug, bug on webpack-cli side

@anshumanv It is related to default cache with the filesystem type and adding buildDependencies, we should always add absolute path

/cc @webpack/cli-team high priority

Will take a look

WIP

@alexander-akait has this fix been released yet? If so which version? I am running the latest and still experiencing the issue.

Current versions are:

"webpack": "5.10.3",
"webpack-cli": "4.2.0",
"webpack-dev-server": "3.11.0",

@sppatel not released yet, ETA is today/tomorrow

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RobotnickIsrael picture RobotnickIsrael  Â·  5Comments

sumukhah picture sumukhah  Â·  3Comments

snitin315 picture snitin315  Â·  5Comments

evenstensberg picture evenstensberg  Â·  5Comments

Pomax picture Pomax  Â·  3Comments