diff --git a/assets/fingerprint_test.go b/assets/fingerprint_test.go
index 60313cc..0eee2aa 100644
--- a/assets/fingerprint_test.go
+++ b/assets/fingerprint_test.go
@@ -427,15 +427,15 @@ func TestImportMap(t *testing.T) {
t.Run("valid importmap.json without application", func(t *testing.T) {
importMapJSON := `{
"imports": {
- "react": "/assets/react.js",
- "vue": "/assets/vue.js"
+ "lib-a": "/assets/lib-a.js",
+ "lib-b": "/assets/lib-b.js"
}
}`
m := assets.NewManager(fstest.MapFS{
"importmap.json": {Data: []byte(importMapJSON)},
- "react.js": {Data: []byte("// React code")},
- "vue.js": {Data: []byte("// Vue code")},
+ "lib-a.js": {Data: []byte("// Lib A code")},
+ "lib-b.js": {Data: []byte("// Lib B code")},
}, "/assets")
result, err := m.ImportMap()
@@ -447,11 +447,11 @@ func TestImportMap(t *testing.T) {
if !strings.Contains(resultStr, ``) {
t.Error("Should not contain application import when not present")
@@ -462,14 +462,14 @@ func TestImportMap(t *testing.T) {
importMapJSON := `{
"imports": {
"application": "/assets/application.js",
- "react": "/assets/react.js"
+ "lib-a": "/assets/lib-a.js"
}
}`
m := assets.NewManager(fstest.MapFS{
"importmap.json": {Data: []byte(importMapJSON)},
"application.js": {Data: []byte("// Application code")},
- "react.js": {Data: []byte("// React code")},
+ "lib-a.js": {Data: []byte("// Lib A code")},
}, "/assets")
result, err := m.ImportMap()
@@ -608,6 +608,497 @@ func TestImportMap(t *testing.T) {
})
}
+func TestImportMapWithScopes(t *testing.T) {
+ t.Run("importmap with scopes fingerprints all paths", func(t *testing.T) {
+ importMapJSON := `{
+ "imports": {
+ "@org/package-main": "vendor/@org/package-main@1.2.0/dist/index.js"
+ },
+ "scopes": {
+ "vendor/@org/package-main@1.2.0/": {
+ "@org/package-dep/utils": "vendor/@org/package-dep@2.3.0/dist/utils/index.js",
+ "package-helper": "vendor/package-helper@3.1.0/dist/index.js"
+ }
+ }
+ }`
+
+ m := assets.NewManager(fstest.MapFS{
+ "importmap.json": {Data: []byte(importMapJSON)},
+ "vendor/@org/package-main@1.2.0/dist/index.js": {Data: []byte("// Main package")},
+ "vendor/@org/package-dep@2.3.0/dist/utils/index.js": {Data: []byte("// Dep utils")},
+ "vendor/package-helper@3.1.0/dist/index.js": {Data: []byte("// Helper")},
+ }, "/assets")
+
+ result, err := m.ImportMap()
+ if err != nil {
+ t.Errorf("Expected no error, got %v", err)
+ }
+
+ resultStr := string(result)
+
+ // Check basic structure
+ if !strings.Contains(resultStr, `