js: Let ESBuild handle all imports from node_modules

This commit fixes some issues where modules in /assets share the same name as in node_modules.

This was not intended, and with this commit the node_modules-components should be isolated. If you want to redefine something inside node_modules, use the `defines` option.

Fixes #7948
This commit is contained in:
Bjørn Erik Pedersen
2020-11-13 08:54:29 +01:00
committed by GitHub
parent 5e03f644a4
commit 78f227b664
6 changed files with 26 additions and 46 deletions

View File

@@ -267,7 +267,7 @@ func (s SourceFilesystems) IsI18n(filename string) bool {
// It will return an empty string if the filename is not a member of a static filesystem.
func (s SourceFilesystems) MakeStaticPathRelative(filename string) string {
for _, staticFs := range s.Static {
rel := staticFs.MakePathRelative(filename)
rel, _ := staticFs.MakePathRelative(filename)
if rel != "" {
return rel
}
@@ -276,8 +276,7 @@ func (s SourceFilesystems) MakeStaticPathRelative(filename string) string {
}
// MakePathRelative creates a relative path from the given filename.
// It will return an empty string if the filename is not a member of this filesystem.
func (d *SourceFilesystem) MakePathRelative(filename string) string {
func (d *SourceFilesystem) MakePathRelative(filename string) (string, bool) {
for _, dir := range d.Dirs {
meta := dir.(hugofs.FileMetaInfo).Meta()
@@ -288,10 +287,10 @@ func (d *SourceFilesystem) MakePathRelative(filename string) string {
if mp := meta.Path(); mp != "" {
rel = filepath.Join(mp, rel)
}
return strings.TrimPrefix(rel, filePathSeparator)
return strings.TrimPrefix(rel, filePathSeparator), true
}
}
return ""
return "", false
}
func (d *SourceFilesystem) RealFilename(rel string) string {