Skip to content

Commit ec64896

Browse files
authored
test(glob-import): cover absolute base resolving to files outside root (#22298)
1 parent 5d94d1b commit ec64896

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,14 @@ test('import.meta.glob and dynamic import vars transformations should be visible
367367
JSON.stringify({ globTransformed: true, dynamicImportTransformed: true }),
368368
)
369369
})
370+
371+
test('absolute base with files outside of root', async () => {
372+
await expect
373+
.poll(async () =>
374+
JSON.parse(await page.textContent('.absolute-base-outside-root')),
375+
)
376+
.toStrictEqual({
377+
'../external/x.js': 'hello from x',
378+
'../external/y.js': 'hello from y',
379+
})
380+
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const msg = 'hello from x'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const msg = 'hello from y'

playground/glob-import/root/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,19 @@ <h2>Transform visibility</h2>
313313
document.querySelector('.transform-visibility').textContent =
314314
JSON.stringify(result)
315315
</script>
316+
317+
<h2>Absolute base outside root</h2>
318+
<pre class="absolute-base-outside-root"></pre>
319+
320+
<script type="module">
321+
const modules = import.meta.glob('../external/*.js', {
322+
eager: true,
323+
base: '/',
324+
})
325+
document.querySelector('.absolute-base-outside-root').textContent =
326+
JSON.stringify(
327+
Object.fromEntries(Object.entries(modules).map(([k, v]) => [k, v.msg])),
328+
null,
329+
2,
330+
)
331+
</script>

0 commit comments

Comments
 (0)