Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle imports from dot directories #3739

Merged
merged 7 commits into from Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/playground/optimize-deps/.hidden-dir/foo.js
@@ -0,0 +1 @@
export const greeting = 'hello!'
Expand Up @@ -67,3 +67,7 @@ test('esbuild-plugin', async () => {
isBuild ? `Hello from a package` : `Hello from an esbuild plugin`
)
})

test('import from hidden dir', async () => {
expect(await page.textContent('.hidden-dir')).toBe('hello!')
})
6 changes: 6 additions & 0 deletions packages/playground/optimize-deps/index.html
Expand Up @@ -43,6 +43,9 @@ <h2>Vue & Vuex</h2>
<h2>Dep with changes from esbuild plugin</h2>
<div>This should show a greeting: <span class="esbuild-plugin"></span></div>

<h2>Dep from hidden dir</h2>
<div>This should show hello!: <span class="hidden-dir"></span></div>

<script type="module">
// test dep detection in globbed files
const globbed = import.meta.globEager('./glob/*.js')
Expand Down Expand Up @@ -70,4 +73,7 @@ <h2>Dep with changes from esbuild plugin</h2>

import { hello } from 'dep-esbuild-plugin-transform'
document.querySelector('.esbuild-plugin').textContent = hello()

import { greeting } from '.hidden-dir/foo.js'
Shinigami92 marked this conversation as resolved.
Show resolved Hide resolved
document.querySelector('.hidden-dir').textContent = greeting
</script>
2 changes: 1 addition & 1 deletion packages/vite/src/node/optimizer/esbuildDepPlugin.ts
Expand Up @@ -150,7 +150,7 @@ export function esbuildDepPlugin(
const entryFile = qualified[id]

let relativePath = normalizePath(path.relative(root, entryFile))
if (!relativePath.startsWith('.')) {
if (!relativePath.startsWith('./')) {
hpx7 marked this conversation as resolved.
Show resolved Hide resolved
relativePath = `./${relativePath}`
}

Expand Down