-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Regression in media type suffix lookup #8406
Comments
Changing the A mid term solution would be a flag like |
The mediaType is passed to esbuild in the options to determine which content loader esbuild should choose to process the file. esbuild only supports certain content types and cannot process custom formats in the way that Hugo does. The error message that you received seems like it is the correct way for this to be handled, indicating that you are attempting to use js.Build with an unsupported media type and so it does not know how to process the data. |
I'm sorry but I can't see where I pass it, it seems to be passed implicit... |
Going through your test program (which I did not see before, I apologize), I was wondering if either of the two js dependencies have an import statement that imports a geo+json file? Does Mirador have an import for that file type within its code? |
It looks like openlayers defines a geoJSON type and imports it within the code. As js.Build goes through the files to create a single javascript file, it must attempt to import this file, does not recognize the type, and this is likely where the failure is occurring. I think that is the case, though I do not know how to address it. |
Well, I've just updated my test case since there might have been the case that OpenLayers has to do something with this. But even without OpenLayers (or Mirador) this happens. It's a hugo issue (not ESBuild), since the error is risen here |
When the custom media type is created, it creates a suffixesCSV which contains "geojson, gson." As Hugo processes the mediaTypes for javascript files, it checks to see the associated media types based on the suffix "js." Lines 307 to 308 in 33d5f80
This code sees "js" in "geoJSon" and adds it as the first mediaType of javascript files which then passes it to the js.Build and creates the error. This is a bug. Edit: it is actually occuring when a new resource is created here: hugo/resources/resource_spec.go Line 271 in 3ddffd0
Though, the issue will occur at the other location also. I'm not sure where the custom resources are added to the spec mediaTypes, but if they are added after the built-in types it could address the problem temporarily as the custom type would not be the first associated type. |
@matt9189 Thanks for investigating - since there is a workaround and only a few affected suffixes I guess it has a lower priority. |
I saw during my debugging that there was a "todo" regarding the ambiguous nature of mediaTypes in resource_spec.go. The above issue may be fixed by checking for an exact match in the suffixesCSV. I am not going to create a pull request, mostly because I am not very fluent at using github and I need someone to show me some stuff. I will post this here though as a possible fix for mediaType.go hasSuffix() function above. hugo/resources/resource_spec.go Lines 271 to 276 in 3ddffd0
|
Why do you pass these files into |
@bep: I don't pass anything - |
|
@beb: Maybe your using a development version of Hugo? Or am I missing something by reusing the #8370 test case? |
@cmahnke no, I forgot to init the submodule when I cloned it. I get the error now, I will eventually get to it. |
Introduced in Hugo 0.82.0. Fixes gohugoio#8406
@bep: Thanks for fixing! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes
Description
I've defined a custom output format to generate GeoJSON:
When this is added to
config.toml
, the following error message is displayed during the build:I suspect the error in 'resources/resource_transformers/js/options.go', line 319, somehow the media type get's passed there - I don't really understand why.
If it's just because of the
application/
prefix of the media type some XML formats (application/xml
) will suffer as well.I've updated the example repository from #8370, see cmahnke/hugo-0.82-test
The text was updated successfully, but these errors were encountered: