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

fix: inject instead of auto import server entry #8

Merged
merged 19 commits into from
Aug 23, 2024
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
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