webpack-bundle-tracker icon indicating copy to clipboard operation
webpack-bundle-tracker copied to clipboard

Setting "path" option no longer works

Open bennettrogers opened this issue 3 years ago • 2 comments

It seems that setting the path option in the BundleTracker options no longer has an effect. I think the issue was introduced in this commit. Regardless of what the path option is set to, the stats file is rooted in the cwd.

It's possible to work around the issue by specifying the full file path in the filename option.

bennettrogers avatar Dec 20 '21 15:12 bennettrogers

Hi @bennettrogers, this was changed on https://github.com/django-webpack/webpack-bundle-tracker/pull/91

We still have the outputChunkDir variable and we use it: https://github.com/django-webpack/webpack-bundle-tracker/blob/8a517eea7b30e8ac47ce5a7d2d93eca356fe8e52/lib/index.js#L71

but only if the filename is a relative path: https://github.com/django-webpack/webpack-bundle-tracker/blob/8a517eea7b30e8ac47ce5a7d2d93eca356fe8e52/lib/index.js#L161-L163

Are you passing a relative filename path? Or does it have a leading /?

fjsj avatar Dec 21 '21 20:12 fjsj

@fjsj There might be some confusion here, the webpack-stats.json file seems to not be respecting the path option provided in options and is now just writing the stats file in the pwd. Your response seems to be in relation to publicPath that's written for each chunk. This is a bug with the path to webpack-stats.json

I can confirm I've worked around the bug by using an absolute filename. If this is intentional then perhaps the docs need updating?

Broken:

new BundleTracker({
  path: OUTPUT_DIRECTORY,
  filename: 'webpack-stats.json'
})

Workaround:

new BundleTracker({
  filename: path.join(
    OUTPUT_DIRECTORY,
    'webpack-stats.json'
})

dannyshaw avatar Jan 19 '22 23:01 dannyshaw

same here, upgraded from 0.4.2 to 1.8.0

not a big deal, as a workaround mentioned above is perfectly fine, but d.ts tells me, that I should be able to use this (broken) option, which is confusing

vasili4396 avatar Jan 16 '23 08:01 vasili4396

So I think the issue is on typings.d.ts Thanks for reporting @vasili4396 If you can/want open a PR solving this, please feel free.

fjsj avatar Jan 16 '23 14:01 fjsj