webpack / webpack.js.org

Repository for webpack documentation and more!
https://webpack.js.org
Creative Commons Attribution 4.0 International
2.21k stars 3.31k forks source link

devtoolModuleFilenameTemplate `info.loaders` is undefined #4880

Open skjnldsv opened 3 years ago

skjnldsv commented 3 years ago

Bug report

What is the current behavior?

The example given on the docs https://webpack.js.org/configuration/output/#outputdevtoolmodulefilenametemplate suggest using webpack:///${info.resourcePath}?${info.loaders}. But logging info shows that lots of the mentionned keys are not available


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

Have a webpack config with the following output:

        devtoolNamespace: appName,
        devtoolModuleFilenameTemplate(info) {
            const rootDir = process.cwd()
            const rel = path.relative(rootDir, info.absoluteResourcePath)
            console.info(info);
            return `webpack:///${appName}/${rel}?${info.loaders}`
        },

appName is a string. notifications is the current example I'm working on.

The console and sourcemap diffs logs:

{
  identifier: [Getter/Setter],
  shortIdentifier: [Getter/Setter],
  resource: [Getter/Setter],
  resourcePath: [Getter/Setter],
  absoluteResourcePath: [Getter/Setter],
  allLoaders: [Getter/Setter],
  query: [Getter/Setter],
  moduleId: [Getter/Setter],
  hash: [Getter/Setter],
  namespace: [Getter/Setter]
}
+?undefined
... etc

What is the expected behavior?

info.loaders should be defined


Other relevant information: webpack version: 5.31.2 webpack-cli version: 4.6.0 Node.js version: 14.16.0 Operating System: Linux workstation 5.10.26-1-lts webpack/webpack#1 SMP x86_64 GNU/Linux (Arch) Additional tools: -

webpack-bot commented 3 years ago

For maintainers only:

alexander-akait commented 3 years ago

We need update out docs