Skip to content

Commit

Permalink
fix: inject instead of auto import server entry (#8)
Browse files Browse the repository at this point in the history
* link vike

* pin react-streaming

* Revert "pin react-streaming"

This reverts commit b812f5d.

* Revert "link vike"

This reverts commit e8b8e28.

* override vite-plugin-server-entry

* showcase with examples/express-react

* link vite-plugin-server-entry

* fix: inject instead of auto import server entry

* try standalone

* Revert "try standalone"

This reverts commit ac54072.

* Revert "showcase with examples/express-react"

This reverts commit 97d424f.

* Revert "link vite-plugin-server-entry"

This reverts commit 3340f62.

* Revert "override vite-plugin-server-entry"

This reverts commit 1f07296.

* update vike

* update @brillout/vite-plugin-server-entry of example

* don't assume writeBundle() to be called

* link vike

* Revert "link vike"

This reverts commit 4941edb.

* udpate vike
  • Loading branch information
brillout authored Aug 23, 2024
1 parent 7bcb780 commit 15eccda
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 38 deletions.
2 changes: 1 addition & 1 deletion examples/express-react-vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"express": "^4.19.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"vike": "^0.4.184",
"vike": "^0.4.193",
"vike-node": "^0.1.16",
"vike-react": "^0.4.18",
"vite": "^5.4.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/express-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"express": "^4.19.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"vike": "^0.4.184",
"vike": "^0.4.193",
"vike-node": "^0.1.16",
"vike-react": "^0.4.18",
"vite": "^5.4.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/hono-react-cf-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"hono": "^4.5.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"vike": "^0.4.184",
"vike": "^0.4.193",
"vike-node": "^0.1.16",
"vike-react": "^0.4.18",
"vite": "^5.4.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/hono-react-vercel-edge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"hono": "^4.5.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"vike": "^0.4.184",
"vike": "^0.4.193",
"vike-node": "^0.1.16",
"vike-react": "^0.4.18",
"vite": "^5.4.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/vike-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"resolve-from": "^5.0.0"
},
"peerDependencies": {
"vike": "^0.4.181",
"vike": "^0.4.193",
"vite": "^5.0.10"
},
"devDependencies": {
Expand All @@ -50,7 +50,7 @@
"h3": "^1.12.0",
"hono": "^4.5.5",
"typescript": "^5.5.4",
"vike": "^0.4.184",
"vike": "^0.4.193",
"vite": "^5.4.0"
},
"typesVersions": {
Expand Down
8 changes: 6 additions & 2 deletions packages/vike-node/src/plugin/plugins/serverEntryPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import pc from '@brillout/picocolors'
import { createRequire } from 'module'
import path from 'path'
import type { Plugin } from 'vite'
import type { Plugin, ResolvedConfig } from 'vite'
import type { EntryResolved } from '../../types.js'
import { assert, assertUsage } from '../../utils/assert.js'
import { getConfigVikeNode } from '../utils/getConfigVikeNode.js'
import { injectRollupInputs } from '../utils/injectRollupInputs.js'
import { viteIsSSR } from '../utils/viteIsSSR.js'
import type { ConfigVitePluginServerEntry } from 'vike/types'

const require_ = createRequire(import.meta.url)

export function serverEntryPlugin(): Plugin {
return {
name: 'vike-node:serverEntry',
async configResolved(config) {
async configResolved(config: ResolvedConfig & ConfigVitePluginServerEntry) {
const resolvedConfig = getConfigVikeNode(config)
const { entry } = resolvedConfig.server
const entries = Object.entries(entry)
Expand Down Expand Up @@ -48,6 +49,9 @@ export function serverEntryPlugin(): Plugin {
config
)
}

config.vitePluginServerEntry ??= {}
config.vitePluginServerEntry.inject = Object.keys(resolvedEntries)
}
}
}
2 changes: 1 addition & 1 deletion packages/vike-node/src/plugin/plugins/standalonePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function standalonePlugin(): Plugin {
let root = ''
let outDir = ''
let outDirAbs = ''
let rollupEntryFilePaths: string[]
let rollupEntryFilePaths: string[] = []
let rollupResolve: any

return {
Expand Down
63 changes: 35 additions & 28 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion test/vike-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"sharp": "^0.33.4",
"telefunc": "^0.1.76",
"typescript": "^5.5.4",
"vike": "^0.4.184",
"vike": "^0.4.193",
"vike-node": "link:../../packages/vike-node",
"vite": "^5.4.0"
},
Expand Down

0 comments on commit 15eccda

Please sign in to comment.