empty-scopes.json (5377B)
1 { 2 "name": "Scope sorting with multiple empty scopes", 3 "details": "Tests that empty scopes don't interfere with scope resolution priority. This reproduces a bug where having multiple empty scope entries before a more specific scope causes the wrong scope to be selected.", 4 "link": "https://github.com/astegmaier/playground-import-maps", 5 "tests": { 6 "Multiple empty scopes before specific scope": { 7 "importMap": { 8 "scopes": { 9 "./__bundles__/asdfasdf/": {}, 10 "./__bundles__/qwerqwer/": {}, 11 "./__bundles__/foo/": { 12 "bar": "./__bundles__/bar/version2/index.js" 13 }, 14 "./__bundles__/": { 15 "bar": "./__bundles__/bar/version1/index.js" 16 } 17 } 18 }, 19 "importMapBaseURL": "https://example.com/", 20 "tests": { 21 "Import from foo should use version2": { 22 "baseURL": "https://example.com/__bundles__/foo/index.js", 23 "expectedResults": { 24 "bar": "https://example.com/__bundles__/bar/version2/index.js" 25 } 26 }, 27 "Import from root bundles should use version1": { 28 "baseURL": "https://example.com/__bundles__/other/index.js", 29 "expectedResults": { 30 "bar": "https://example.com/__bundles__/bar/version1/index.js" 31 } 32 }, 33 "Import from asdfasdf should use version1 (empty scope)": { 34 "baseURL": "https://example.com/__bundles__/asdfasdf/index.js", 35 "expectedResults": { 36 "bar": "https://example.com/__bundles__/bar/version1/index.js" 37 } 38 }, 39 "Import from qwerqwer should use version1 (empty scope)": { 40 "baseURL": "https://example.com/__bundles__/qwerqwer/index.js", 41 "expectedResults": { 42 "bar": "https://example.com/__bundles__/bar/version1/index.js" 43 } 44 } 45 } 46 }, 47 "Empty scopes after specific scope": { 48 "importMap": { 49 "scopes": { 50 "./__bundles__/foo/": { 51 "bar": "./__bundles__/bar/version2/index.js" 52 }, 53 "./__bundles__/": { 54 "bar": "./__bundles__/bar/version1/index.js" 55 }, 56 "./__bundles__/asdfasdf/": {}, 57 "./__bundles__/qwerqwer/": {} 58 } 59 }, 60 "importMapBaseURL": "https://example.com/", 61 "tests": { 62 "Import from foo should use version2 (order independent)": { 63 "baseURL": "https://example.com/__bundles__/foo/index.js", 64 "expectedResults": { 65 "bar": "https://example.com/__bundles__/bar/version2/index.js" 66 } 67 }, 68 "Import from root bundles should use version1": { 69 "baseURL": "https://example.com/__bundles__/other/index.js", 70 "expectedResults": { 71 "bar": "https://example.com/__bundles__/bar/version1/index.js" 72 } 73 } 74 } 75 }, 76 "Single empty scope before specific scope": { 77 "importMap": { 78 "scopes": { 79 "./__bundles__/asdfasdf/": {}, 80 "./__bundles__/foo/": { 81 "bar": "./__bundles__/bar/version2/index.js" 82 }, 83 "./__bundles__/": { 84 "bar": "./__bundles__/bar/version1/index.js" 85 } 86 } 87 }, 88 "importMapBaseURL": "https://example.com/", 89 "tests": { 90 "Import from foo should use version2 (single empty scope)": { 91 "baseURL": "https://example.com/__bundles__/foo/index.js", 92 "expectedResults": { 93 "bar": "https://example.com/__bundles__/bar/version2/index.js" 94 } 95 } 96 } 97 }, 98 "Deeply nested scopes with empty scopes": { 99 "importMap": { 100 "scopes": { 101 "./a/b/c/d/": {}, 102 "./a/b/c/e/": {}, 103 "./a/b/foo/": { 104 "pkg": "./resolved/version2.js" 105 }, 106 "./a/b/": { 107 "pkg": "./resolved/version1.js" 108 } 109 } 110 }, 111 "importMapBaseURL": "https://example.com/", 112 "tests": { 113 "Import from a/b/foo should use version2": { 114 "baseURL": "https://example.com/a/b/foo/index.js", 115 "expectedResults": { 116 "pkg": "https://example.com/resolved/version2.js" 117 } 118 }, 119 "Import from a/b/ should use version1": { 120 "baseURL": "https://example.com/a/b/other.js", 121 "expectedResults": { 122 "pkg": "https://example.com/resolved/version1.js" 123 } 124 } 125 } 126 }, 127 "Many empty scopes with different lengths": { 128 "importMap": { 129 "scopes": { 130 "./x/": {}, 131 "./xy/": {}, 132 "./xyz/": {}, 133 "./xyzw/": {}, 134 "./xyzwv/": {}, 135 "./packages/foo/": { 136 "bar": "./bar/version2.js" 137 }, 138 "./packages/": { 139 "bar": "./bar/version1.js" 140 } 141 } 142 }, 143 "importMapBaseURL": "https://example.com/", 144 "tests": { 145 "Import from packages/foo should use version2": { 146 "baseURL": "https://example.com/packages/foo/index.js", 147 "expectedResults": { 148 "bar": "https://example.com/bar/version2.js" 149 } 150 }, 151 "Import from packages/ should use version1": { 152 "baseURL": "https://example.com/packages/other.js", 153 "expectedResults": { 154 "bar": "https://example.com/bar/version1.js" 155 } 156 } 157 } 158 } 159 } 160 }