mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
js: Resolve index.esm.js
Same logic as for `index.{js,ts...}` files applies; if both `index.esm.js` and `index.js` exists (unlikely), you need to use the name with extension when importing, else the `index.js` will win. Fixes #8631
This commit is contained in:
@@ -176,6 +176,12 @@ func resolveComponentInAssets(fs afero.Fs, impPath string) *hugofs.FileMeta {
|
||||
if m != nil {
|
||||
return m
|
||||
}
|
||||
if filepath.Base(impPath) == "index" {
|
||||
m = findFirst(impPath + ".esm")
|
||||
if m != nil {
|
||||
return m
|
||||
}
|
||||
}
|
||||
|
||||
// Finally check the path as is.
|
||||
fi, err := fs.Stat(impPath)
|
||||
@@ -183,6 +189,9 @@ func resolveComponentInAssets(fs afero.Fs, impPath string) *hugofs.FileMeta {
|
||||
if err == nil {
|
||||
if fi.IsDir() {
|
||||
m = findFirst(filepath.Join(impPath, "index"))
|
||||
if m == nil {
|
||||
m = findFirst(filepath.Join(impPath, "index.esm"))
|
||||
}
|
||||
} else {
|
||||
m = fi.(hugofs.FileMetaInfo).Meta()
|
||||
}
|
||||
|
Reference in New Issue
Block a user