django-webpack / webpack-bundle-tracker

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

Add assets source filenames #125

Closed batistadasilva closed 5 months ago

batistadasilva commented 5 months ago

Add sourceFilename field

Asset resources in webpack-stats.json file will look like,

"assets": {
  "assets/test-bbf3c94e2a3948c98900.txt": {
    "name": "assets/test-bbf3c94e2a3948c98900.txt",
    "path": "/home/user/project-root/assets/test-bbf3c94e2a3948c98900.txt",
    "publicPath": "http://localhost:3000/assets/test-bbf3c94e2a3948c98900.txt",
    "sourceFilename": "src/test.txt"
  }
}

Related to https://github.com/django-webpack/django-webpack-loader/issues/343

batistadasilva commented 5 months ago

@fjsj Thanks for the review

fjsj commented 5 months ago

Some tests are breaking @batistadasilva Could you please check?

batistadasilva commented 5 months ago

@fjsj It seems like there is a broken test in master branch

fjsj commented 5 months ago

The last build from 3 months ago did pass: https://github.com/django-webpack/webpack-bundle-tracker/actions/runs/7466611716 Are you seeing the same errors in localhost as well? Or in your fork?

batistadasilva commented 5 months ago

I am seeing the same errors when running in localhost on the commit 97c7ec6

How can I help?

fjsj commented 5 months ago

The error is this:

    -   "js/862.js",
    +   "js/75.js",

Please check if this is simply a hash change. If so, you can safely change the test assertion.

batistadasilva commented 5 months ago

Please check if this is simply a hash change.

Yes it was

fjsj commented 5 months ago

@batistadasilva I think now it breaks in Webpack 4? I think it's safe to ignore sourceFilename in Webpack 4. Whoever needs to use this should upgrade, as it's not a critical feature.

batistadasilva commented 5 months ago

@fjsj It seems like a typing error, but I don't know how to handle it

Could you help me wit this?

fjsj commented 5 months ago

If assetsInfo is undefined, you can ignore adding sourceFilename. Like:

if (stats.compilation.assetsInfo) {
  fileInfo.sourceFilename = stats.compilation.assetsInfo.get(assetName).sourceFilename;
}
batistadasilva commented 5 months ago

@fjsj Done

However, the typing errors may still remain

fjsj commented 5 months ago

@batistadasilva I see that's a tsc error, but we can ignore it on Webpack 4.

Please enable me to edit this PR: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork

Or look for a way to ignore the error TS2339 in those two lines.

batistadasilva commented 5 months ago

Please enable me to edit this PR:

It would be with pleasure, but I couldn't find the checkbox the documentation is talking about

Or look for a way to ignore the error TS2339 in those two lines.

I don't think we can ignore a specific TS rule, so I ignored TS in both lines. I hope it's fine.

fjsj commented 5 months ago

Thanks! We will release soon.