Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect paths in compilation.fileDependencies #11971

Closed
MikeDevice opened this issue Nov 11, 2020 · 7 comments
Closed

Incorrect paths in compilation.fileDependencies #11971

MikeDevice opened this issue Nov 11, 2020 · 7 comments

Comments

@MikeDevice
Copy link

Bug report

What is the current behavior?
The compilation.fileDependencies (at a webpack plugin) contains incorrect paths, such as /, /home, etc. There is no such problem with webpack@4.

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

  1. Create an empty project.
  2. Install webpack and webpack-cli:
$ npm install --save-dev webpack webpack-cli
  1. Create webpack.config.js with the follow content:
class Plugin {
  apply(compiler) {
    compiler.hooks.emit.tapAsync('Plugin', (compilation, callback) => {
      console.log(Array.from(compilation.fileDependencies));
      callback();
    });
  }
}

module.exports = {
  plugins: [new Plugin()]
};
  1. Run build:
$ webpack
  1. See the console output. It will be like so:
[
  '<path-to-repo>/package.json',
  '<path-to-repo>/src',
  '<path-to-repo>/src/index.js',
  '<path-to-repo>',
  '/home/<username>',
  '/home',
  '/'
]

Here is a repo that reproduces this issue: https://github.com/MikeDevice/webpack-file-dependencies-issue.

What is the expected behavior?
The expected behavior is what webpack@4 has:

[
  '<path-to-repo>/src/index.js'
]

Other relevant information:
webpack version: 5.4.0
Node.js version: 12.14.0
Operating System: Ubuntu 18.04.5 LTS
Additional tools: webpack-cli: 4.2.0

@webpack-bot
Copy link
Contributor

webpack-bot commented Nov 11, 2020

For maintainers only:

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

@sokra
Copy link
Member

sokra commented Nov 11, 2020

/home/<username> could be a symlink which would affect resolving.

@alexander-akait
Copy link
Member

Answer above

@MikeDevice
Copy link
Author

I'm not sure, I understand you. Okay. Let's see another example. I created a new branch at the example repo (link), where I added @babel/runtime as a dependency.

Now at the build a get follow logs:

[
  '<path-to-repo>/node_modules/@babel/runtime',
  '<path-to-repo>/node_modules/@babel/runtime/package.json',
  '<path-to-repo>/node_modules/@babel/runtime/helpers/decorate.js',
  '<path-to-repo>/node_modules/@babel/runtime/helpers',
  '<path-to-repo>/node_modules/@babel',
  '<path-to-repo>/node_modules',
  // ...
  // other @babel/runtime paths
  // ...
]

When I use webpack@4 I don't get such paths as

  '<path-to-repo>/node_modules/@babel/runtime',
  '<path-to-repo>/node_modules/@babel/runtime/package.json',
  '<path-to-repo>/node_modules/@babel/runtime/helpers',
  '<path-to-repo>/node_modules/@babel',
  '<path-to-repo>/node_modules',

and It seems good, because these paths are not real dependencies.

@alexander-akait
Copy link
Member

alexander-akait commented Nov 11, 2020

@MikeDevice what is the problem? It is feature, right now webpack can follow for symlinks

@MikeDevice
Copy link
Author

The problem is license-checker-webpack-plugin doesn't work sometimes with webpack@5 and I thought It's been caused because of webpack's "bug", but as you said it's a feature, so now I realise it's a plugin's bug, not webpack.

@alexander-akait
Copy link
Member

Yes, please open an issue in license-checker-webpack-plugin, it is feature, also it give more abilities for watching and tracking

KKoukiou added a commit to KKoukiou/cockpit that referenced this issue Jun 15, 2021
* Minifier WA can be now dropped since the pulled cssnano version
includes the fix
* Adjust to new copy-webpack-plugin API.
* Adjust included node modules plugin needs to webpack 5 API
* Update html-webpack-plugin to remove deprecation warnings
  Previously we would get:
  BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
  See jantimon/html-webpack-plugin#1501
* Use lite cssnano preset because the default version makes problematic
  assumptions

Note: webpack's compilation.fileDependencies has changed and the
webpack-make needs to be adjusted accordingly:
webpack/webpack#11971
KKoukiou added a commit to cockpit-project/cockpit that referenced this issue Jun 15, 2021
* Minifier WA can be now dropped since the pulled cssnano version
includes the fix
* Adjust to new copy-webpack-plugin API.
* Adjust included node modules plugin needs to webpack 5 API
* Update html-webpack-plugin to remove deprecation warnings
  Previously we would get:
  BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
  See jantimon/html-webpack-plugin#1501
* Use lite cssnano preset because the default version makes problematic
  assumptions

Note: webpack's compilation.fileDependencies has changed and the
webpack-make needs to be adjusted accordingly:
webpack/webpack#11971
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants