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

test(resolve): ssr deep import resolve #13022

Merged
merged 1 commit into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions playground/ssr-resolve/__tests__/ssr-resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,13 @@ test.runIf(isBuild)('correctly resolve entrypoints', async () => {
new RegExp(`from ${_}@vitejs/test-resolve-pkg-exports/entry${_}`),
)

expect(contents).toMatch(
new RegExp(`from ${_}@vitejs/test-deep-import/foo/index.js${_}`),
)

expect(contents).toMatch(
new RegExp(`from ${_}@vitejs/test-deep-import/bar${_}`),
)

await expect(import(`${testDir}/dist/main.mjs`)).resolves.toBeTruthy()
})
7 changes: 7 additions & 0 deletions playground/ssr-resolve/deep-import/bar/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"private": true,
"version": "0.0.0",
"type": "module",
"main": "../utils/bar.js",
"module": "../utils/bar.js"
}
1 change: 1 addition & 0 deletions playground/ssr-resolve/deep-import/foo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'foo'
6 changes: 6 additions & 0 deletions playground/ssr-resolve/deep-import/foo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"version": "0.0.0",
"type": "module",
"module": "./index.js"
}
3 changes: 3 additions & 0 deletions playground/ssr-resolve/deep-import/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as foo } from './foo'
export { default as bar } from './bar'
export default 'external-nested'
7 changes: 7 additions & 0 deletions playground/ssr-resolve/deep-import/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@vitejs/test-deep-import",
"private": true,
"version": "0.0.0",
"type": "module",
"module": "index.js"
}
1 change: 1 addition & 0 deletions playground/ssr-resolve/deep-import/utils/bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'bar'
4 changes: 4 additions & 0 deletions playground/ssr-resolve/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import dirEntry from '@vitejs/test-entries/dir'
import fileEntry from '@vitejs/test-entries/file'
// has `exports` key, should resolve to pkg-exports/entry
import pkgExportsEntry from '@vitejs/test-resolve-pkg-exports/entry'
import deepFoo from '@vitejs/test-deep-import/foo'
import deepBar from '@vitejs/test-deep-import/bar'

export default `
entries/dir: ${dirEntry}
entries/file: ${fileEntry}
pkg-exports/entry: ${pkgExportsEntry}
deep-import/foo: ${deepFoo}
deep-import/bar: ${deepBar}
`
3 changes: 2 additions & 1 deletion playground/ssr-resolve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"dependencies": {
"@vitejs/test-entries": "file:./entries",
"@vitejs/test-resolve-pkg-exports": "file:./pkg-exports"
"@vitejs/test-resolve-pkg-exports": "file:./pkg-exports",
"@vitejs/test-deep-import": "file:./deep-import"
}
}
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.