-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix build for vite 3 + "type": "module"
Background: pnpm injects `NODE_PATH` when installing npm script binaries in order to simulate flat install structure when running npm scripts. This previously made files outside of VitePress to be able to import transitive deps (e.g. `vue`), but this breaks when upgrading to Vite 3 or in esm mode, because: - "type": "module", aka ESM mode doesn't support `NODE_PATH`, so now project files can't resolve `vue` which is a transitive dep. - Vite 3 now auto-resolves SSR externals, but it requires the dep to be resolvable first. Since it can't resovle `vue`, the Rollup build will fail. The fix: detect if `vue` is resolvable from project root's node_modules. If not, create a symlink to the version of `vue` from VitePress' own deps.
- Loading branch information
Showing
7 changed files
with
126 additions
and
106 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// entry for SSR | ||
import { createApp } from './index.js' | ||
import { renderToString } from 'vue/server-renderer' | ||
|
||
export async function render(path: string) { | ||
const { app, router } = createApp() | ||
await router.go(path) | ||
return renderToString(app) | ||
} |
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
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
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