Folder structure (including installed packages):
- yarn.lock
- node_modules // workspace root
- import-local
- [email protected]
- my-project
- webpack.config.js
- package.json // includes an npm script to invoke WDS
- node_modules
- [email protected]
When I invoke WDS from the nested my-project directory it should use v3.11.0
v3.11.0 is invoked correctly at first, but the importLocal check in the /bin/webpack-dev-server.js script causes v3.7.2 to be used. This is because of a bug in the import-local package (which I have reported here) where it doesn't take into account that there might be multiple node_modules folders, like in a Yarn workspace.
The bug is intermittent because it depends on Yarn's hoisting behaviour; if import-local had been placed in the nested node_modules directory then v3.11.0 would be used as intended.
The bug can occur for any versions of WDS; 3.11.0 and 3.7.2 are just the versions in my project.
It's tricky to reproduce this reliably as it depends on Yarn's hoisting behaviour, but it should be possible to manually recreate a folder structure like the above and observe the behaviour.
I would like to propose a flag to skip the importLocal check. In my scenario I can be sure there won't be a global installation of WDS, so there's no need to run the check at all, which would avoid any issues like this.
@elliotdavies let's wait answer from @sindresorhus
This issue had no activity for at least half a year.
It's subject to automatic issue closing if there is no activity in the next 15 days.
@webpack/cli-team here simple fix, we need add WEBPACK_CLI_SKIP_IMPORT_LOCAL here https://github.com/webpack/webpack-cli/blob/master/packages/webpack-cli/bin/cli.js#L16 (if defined we don't use import-local package)
wip
Thanks @anshumanv!