Skip to content

Commit 94fd9e7

Browse files
authored
test(glob-import): add subpath imports test from sub directory (#22059)
1 parent 7706a7d commit 94fd9e7

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

playground/glob-import/__tests__/glob-import.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ test('subpath imports', async () => {
289289
.toMatch('bar foo')
290290
})
291291

292+
test('subpath imports (sub dir)', async () => {
293+
await expect
294+
.poll(async () => await page.textContent('.subpath-imports-sub-dir'))
295+
.toMatch('bar foo')
296+
})
297+
292298
test('#alias imports', async () => {
293299
await expect
294300
.poll(async () => await page.textContent('.hash-alias-imports'))

playground/glob-import/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ <h2>Escape alias glob</h2>
2323
<pre class="escape-alias"></pre>
2424
<h2>Subpath imports</h2>
2525
<pre class="subpath-imports"></pre>
26+
<h2>Subpath imports (sub dir)</h2>
27+
<pre class="subpath-imports-sub-dir"></pre>
2628
<h2>#alias imports</h2>
2729
<pre class="hash-alias-imports"></pre>
2830
<h2>In package</h2>
@@ -157,6 +159,14 @@ <h2>Base</h2>
157159
.join(' ')
158160
</script>
159161

162+
<script type="module">
163+
import { globbed } from './subpath-imports-sub/index.js'
164+
document.querySelector('.subpath-imports-sub-dir').textContent =
165+
Object.values(globbed)
166+
.map((mod) => mod.default)
167+
.join(' ')
168+
</script>
169+
160170
<script type="module">
161171
const hashAliasImports = import.meta.glob('#alias/*', { eager: true })
162172
document.querySelector('.hash-alias-imports').textContent = Object.values(
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const globbed = import.meta.glob('#imports/*', { eager: true })

0 commit comments

Comments
 (0)