Skip to content

Commit

Permalink
test(resolve): ssr deep import resolve (#13022)
Browse files Browse the repository at this point in the history
  • Loading branch information
sun0day authored Apr 27, 2023
1 parent 2f8502f commit fe73198
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 1 deletion.
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.

0 comments on commit fe73198

Please sign in to comment.