Skip to content

Commit

Permalink
entry.server and entry.client (#8808)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe committed Jul 1, 2023
1 parent 8b2a566 commit 7cc5564
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
28 changes: 28 additions & 0 deletions packages/project-config/src/__tests__/paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ describe('paths', () => {
'storybook.manager.js'
),
dist: path.join(FIXTURE_BASEDIR, 'web', 'dist'),
distEntryServer: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'entry.server.js'
),
distRouteHooks: path.join(
FIXTURE_BASEDIR,
'web',
Expand Down Expand Up @@ -397,6 +404,13 @@ describe('paths', () => {
'storybook.manager.js'
),
dist: path.join(FIXTURE_BASEDIR, 'web', 'dist'),
distEntryServer: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'entry.server.js'
),
distRouteHooks: path.join(
FIXTURE_BASEDIR,
'web',
Expand Down Expand Up @@ -700,6 +714,13 @@ describe('paths', () => {
entryClient: null,
entryServer: null,
dist: path.join(FIXTURE_BASEDIR, 'web', 'dist'),
distEntryServer: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'entry.server.js'
),
distRouteHooks: path.join(
FIXTURE_BASEDIR,
'web',
Expand Down Expand Up @@ -956,6 +977,13 @@ describe('paths', () => {
'storybook.manager.js'
),
dist: path.join(FIXTURE_BASEDIR, 'web', 'dist'),
distEntryServer: path.join(
FIXTURE_BASEDIR,
'web',
'dist',
'server',
'entry.server.js'
),
distRouteHooks: path.join(
FIXTURE_BASEDIR,
'web',
Expand Down
8 changes: 7 additions & 1 deletion packages/project-config/src/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface WebPaths {
storybookManagerConfig: string
dist: string
distServer: string
distEntryServer: string
distRouteHooks: string
routeManifest: string
types: string
Expand Down Expand Up @@ -105,7 +106,7 @@ const PATH_WEB_DIR_CONFIG = 'web/config'
const PATH_WEB_DIR_CONFIG_WEBPACK = 'web/config/webpack.config.js'
const PATH_WEB_DIR_CONFIG_VITE = 'web/vite.config' // .js,.ts
const PATH_WEB_DIR_ENTRY_CLIENT = 'web/src/entry.client' // .jsx,.tsx
const PATH_WEB_DIR_ENTRY_SERVER = 'web/src/entry-server' // .jsx,.tsx
const PATH_WEB_DIR_ENTRY_SERVER = 'web/src/entry.server' // .jsx,.tsx

const PATH_WEB_DIR_CONFIG_POSTCSS = 'web/config/postcss.config.js'
const PATH_WEB_DIR_CONFIG_STORYBOOK_CONFIG = 'web/config/storybook.config.js'
Expand All @@ -114,6 +115,7 @@ const PATH_WEB_DIR_CONFIG_STORYBOOK_MANAGER = 'web/config/storybook.manager.js'

const PATH_WEB_DIR_DIST = 'web/dist'
const PATH_WEB_DIR_DIST_SERVER = 'web/dist/server'
const PATH_WEB_DIR_DIST_SERVER_ENTRY_SERVER = 'web/dist/server/entry.server.js'
const PATH_WEB_DIR_DIST_SERVER_ROUTEHOOKS = 'web/dist/server/routeHooks'
const PATH_WEB_DIR_ROUTE_MANIFEST = 'web/dist/server/route-manifest.json'

Expand Down Expand Up @@ -221,6 +223,10 @@ export const getPaths = (BASE_DIR: string = getBaseDir()): Paths => {
),
dist: path.join(BASE_DIR, PATH_WEB_DIR_DIST),
distServer: path.join(BASE_DIR, PATH_WEB_DIR_DIST_SERVER),
distEntryServer: path.join(
BASE_DIR,
PATH_WEB_DIR_DIST_SERVER_ENTRY_SERVER
),
distRouteHooks: path.join(BASE_DIR, PATH_WEB_DIR_DIST_SERVER_ROUTEHOOKS),
routeManifest: path.join(BASE_DIR, PATH_WEB_DIR_ROUTE_MANIFEST),
types: path.join(BASE_DIR, 'web/types'),
Expand Down
4 changes: 3 additions & 1 deletion packages/vite/src/buildFeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export const buildFeServer = async ({ verbose }: BuildOptions) => {

if (!rwPaths.web.entryServer || !rwPaths.web.entryClient) {
throw new Error(
'Vite entry points not found. Please check that your project has an entry-client.{jsx,tsx} and entry-server.{jsx,tsx} file in the web/src directory.'
'Vite entry points not found. Please check that your project has an ' +
'entry.client.{jsx,tsx} and entry.server.{jsx,tsx} file in the ' +
'web/src directory.'
)
}

Expand Down
4 changes: 3 additions & 1 deletion packages/vite/src/devFeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ async function createServer() {

if (!rwPaths.web.entryServer || !rwPaths.web.entryClient) {
throw new Error(
'Vite entry points not found. Please check that your project has an entry-client.{jsx,tsx} and entry-server.{jsx,tsx} file in the web/src directory.'
'Vite entry points not found. Please check that your project has ' +
'an entry.client.{jsx,tsx} and entry.server.{jsx,tsx} file in ' +
'the web/src directory.'
)
}

Expand Down
4 changes: 1 addition & 3 deletions packages/vite/src/runFeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ export async function runFeServer() {
const currentPathName = stripQueryStringAndHashFromPath(req.originalUrl)

try {
const { serverEntry } = await import(
path.join(rwPaths.web.distServer, '/entry-server.js')
)
const { serverEntry } = await import(rwPaths.web.distEntryServer)

// TODO (STREAMING) should we generate individual express Routes for each Route?
// This would make handling 404s and favicons / public assets etc. easier
Expand Down

0 comments on commit 7cc5564

Please sign in to comment.