django-webpack / webpack-bundle-tracker

Spits out some stats about webpack compilation process to a file
MIT License
268 stars 107 forks source link

TypeError [ERR_INVALID_ARG_TYPE] with Webpack 5 and relativePath: true #78

Closed andersk closed 3 years ago

andersk commented 4 years ago
$ cat >webpack.config.js <<EOF
const BundleTracker = require("webpack-bundle-tracker");
module.exports = {
  plugins: [new BundleTracker({ relativePath: true })],
};
EOF
$ touch src.js
$ npm i webpack webpack-bundle-tracker webpack-cli
…
+ webpack-cli@4.1.0
+ webpack@5.3.2
+ webpack-bundle-tracker@1.0.0-alpha.1
added 147 packages from 168 contributors and audited 147 packages in 5.273s
…
$ npx webpack
[webpack-cli] TypeError [ERR_INVALID_ARG_TYPE]: The "to" argument must be of type string. Received undefined
    at validateString (internal/validators.js:124:11)
    at Object.relative (path.js:1054:5)
    at /tmp/test/node_modules/webpack-bundle-tracker/lib/index.js:138:30
    at /tmp/test/node_modules/lodash.foreach/index.js:221:11
    at baseForOwn (/tmp/test/node_modules/lodash.foreach/index.js:153:20)
    at /tmp/test/node_modules/lodash.foreach/index.js:190:14
    at forEach (/tmp/test/node_modules/lodash.foreach/index.js:290:10)
    at BundleTrackerPlugin._handleDone (/tmp/test/node_modules/webpack-bundle-tracker/lib/index.js:123:5)
    at Hook.eval [as callAsync] (eval at create (/tmp/test/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/tmp/test/node_modules/tapable/lib/Hook.js:18:14) {
  code: 'ERR_INVALID_ARG_TYPE'
}

At webpack-bundle-tracker/lib/index.js:138, the file object is a SizeOnlySource whose only property is _size, so fileInfo.path is undefined.

jon-mcclung-fortyau commented 3 years ago

Is there any fix or workaround for this?

fjsj commented 3 years ago

Thanks, we'll be checking this tomorrow

fjsj commented 3 years ago

Related: https://github.com/thredup/rollbar-sourcemap-webpack-plugin/issues/61