Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Undistraction opened this issue Apr 4, 2022 · 4 comments
Open

Comments

@Undistraction
Copy link

Undistraction commented Apr 4, 2022

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 
@valscion
Copy link
Member

valscion commented Apr 4, 2022

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?

@pionl
Copy link

pionl commented May 9, 2022

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 ?

@valscion
Copy link
Member

Please create a small reproduction case

@pionl
Copy link

pionl commented May 10, 2022

I'l try 👍 Thank you for your time

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

No branches or pull requests

3 participants