-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(build): fix resolution algorithm when
build.ssr
is true (#9989)
- Loading branch information
Showing
12 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { expect, test } from 'vitest' | ||
import { isBuild, readFile, testDir } from '~utils' | ||
|
||
test.runIf(isBuild)('correctly resolve entrypoints', async () => { | ||
const contents = readFile('dist/main.mjs') | ||
|
||
const _ = `['"]` | ||
expect(contents).toMatch(new RegExp(`from ${_}entries/dir/index.js${_}`)) | ||
expect(contents).toMatch(new RegExp(`from ${_}entries/file.js${_}`)) | ||
expect(contents).toMatch(new RegExp(`from ${_}pkg-exports/entry${_}`)) | ||
|
||
await expect(import(`${testDir}/dist/main.mjs`)).resolves.toBeTruthy() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = __filename.slice(__filename.lastIndexOf('entries')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = __filename.slice(__filename.lastIndexOf('entries')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "entries", | ||
"private": true, | ||
"version": "0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// no `exports` key, should resolve to entries/dir/index.js | ||
import dirEntry from 'entries/dir' | ||
// no `exports` key, should resolve to entries/file.js | ||
import fileEntry from 'entries/file' | ||
// has `exports` key, should resolve to pkg-exports/entry | ||
import pkgExportsEntry from 'pkg-exports/entry' | ||
|
||
export default ` | ||
entries/dir: ${dirEntry} | ||
entries/file: ${fileEntry} | ||
pkg-exports/entry: ${pkgExportsEntry} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "ssr-resolve", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"build": "vite build", | ||
"debug": "node --inspect-brk ../../packages/vite/bin/vite build" | ||
}, | ||
"dependencies": { | ||
"entries": "file:./entries", | ||
"pkg-exports": "file:./pkg-exports" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 'pkg-exports entry' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "pkg-exports", | ||
"private": true, | ||
"version": "0.0.0", | ||
"exports": { | ||
".": "./index.js", | ||
"./entry": "./entry.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineConfig } from 'vite' | ||
|
||
export default defineConfig({ | ||
build: { | ||
ssr: './main.js' | ||
} | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.