Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions playground/glob-import/__tests__/glob-import.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,14 @@ test('import.meta.glob and dynamic import vars transformations should be visible
JSON.stringify({ globTransformed: true, dynamicImportTransformed: true }),
)
})

test('absolute base with files outside of root', async () => {
await expect
.poll(async () =>
JSON.parse(await page.textContent('.absolute-base-outside-root')),
)
.toStrictEqual({
'../external/x.js': 'hello from x',
'../external/y.js': 'hello from y',
})
})
1 change: 1 addition & 0 deletions playground/glob-import/external/x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const msg = 'hello from x'
1 change: 1 addition & 0 deletions playground/glob-import/external/y.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const msg = 'hello from y'
21 changes: 21 additions & 0 deletions playground/glob-import/root/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,24 @@ <h2>Transform visibility</h2>
document.querySelector('.transform-visibility').textContent =
JSON.stringify(result)
</script>

<h2>Absolute base outside root</h2>
<pre class="absolute-base-outside-root"></pre>

<script type="module">
// Regression test for https://github.com/rolldown/rolldown/issues/9144:
// `import.meta.glob` with `base: '/'` matching files outside of vite's root
// must emit a root-relative import path (prefixed with `/`) rather than an
// importer-relative one, otherwise the bundler resolves it against the
// importer and lands on a non-existent file.
Comment thread
shulaoda marked this conversation as resolved.
Outdated
const modules = import.meta.glob('../external/*.js', {
eager: true,
base: '/',
})
document.querySelector('.absolute-base-outside-root').textContent =
JSON.stringify(
Object.fromEntries(Object.entries(modules).map(([k, v]) => [k, v.msg])),
null,
2,
)
</script>
Loading