Skip to content

Incorrect bundle paths when bundles are in multiple directories.  #506

Closed

Description

@Undistraction

Issue description

Where bundles are output to more than one directory, bundle paths are incorrect.

I'm using webpack-bundle-analyser with Gatsby via gatsby-plugin-webpack-bundle-analyser-v2 which is a very thin plugin. Gatsby adds bundles to /public/, however another plugin I use gatsby-plugin-netlify-cms adds bundles to /public/admin/. When BundleAnalyzerPlugin derives the bundleDir it resolves (using this.compiler.outputPath to /path/to/public/admin/ which it then uses as a prefix for all bundle paths. This means only the bundles that are generated to /admin/ are correct. The rest are not and result in warnings:

Error parsing bundle asset "/Users/me/Sites/www/public/app.js": no such file

It seems the current architecture can't handle situations where bundles are in written to different locations.

Technical info

  System:
    OS: macOS 12.3.1
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 133.81 MB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 14.18.2 - ~/.nvm/versions/node/v14.18.2/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.2/bin/npm
    Watchman: 2021.11.15.00 - /usr/local/bin/watchman
  npmPackages:
    gatsby-plugin-webpack-bundle-analyser-v2: ^1.1.26 => 1.1.26 

Activity

  1. valscion commented on Apr 4, 2022

    @valscion
    Collaborator

    Hmm this does sound complicated and a likely bug. Would you be able to create a small reproduction so it would be possible to fix this at some point?

  2. pionl commented on May 9, 2022

    @pionl

    Hi, I can confirm this.

    Here a part of json I have:

    "children": [{
    		"hash": "acbf87df4bf149c73cd1",
    		"version": "5.65.0",
    		"time": 28955,
    		"builtAt": 1652089618297,
    		"publicPath": "/assets/static/",
    		"outputPath": "/app/public/assets/static",
    		"assetsByChunkName": {
    			"static:fonts": ["style/fonts-acbf87df4bf149c73cd1.css", "js/fonts-0a26b8e32bf029c9d244c1cd344336a5.js"],
    			"static:pdf-availability": ["style/pdf-availability-acbf87df4bf149c73cd1.css", "js/pdf-availability-6a5493c1496fd7e44b08a976c90cd01a.js"],
    			"static:pdf": ["style/pdf-acbf87df4bf149c73cd1.css", "js/pdf-801d6111f8a308117ba0f8c07cc16d37.js"]
    		},
    

    Warning for the file:

    Error parsing bundle asset "/app/public/assets/js/pdf-availability-6a5493c1496fd7e44b08a976c90cd01a.js": no such file
    

    It seems it ignores the publicPath ?

  3. valscion commented on May 10, 2022

    @valscion
    Collaborator

    Please create a small reproduction case

  4. pionl commented on May 10, 2022

    @pionl

    I'l try 👍 Thank you for your time

  5. Srushti-33 commented on Feb 11, 2026

    @Srushti-33
    Contributor

    @valscion @Undistraction

    Just put together a minimal repro for this:
    https://github.com/Srushti-33/webpack-bundle-analyzer-506-repro

    What's happening:
    When you reuse the same plugin instance across multiple compilers with different output paths, the plugin only picks up the last compiler's path. So it tries looking for the first compiler's assets in the wrong folder.

    Steps:

    git clone https://github.com/Srushti-33/webpack-bundle-analyzer-506-repro
    cd webpack-bundle-analyzer-506-repro
    npm install
    npm run build
    
  6. alexander-akait commented on Feb 12, 2026

    @alexander-akait
    Member

    @Srushti-33 thanks for debuging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions