-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6481 from alibaba/release/next
Release 3.3.0
- Loading branch information
Showing
127 changed files
with
4,063 additions
and
1,312 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,4 @@ async function getData(ctx) { | |
}); | ||
|
||
return fakeData; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@rspack/dev-server'; |
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,3 @@ | ||
import runtime from 'react-refresh/runtime'; | ||
|
||
export default runtime; |
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 @@ | ||
export * from '@rspack/core'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import detectPort from 'detect-port'; | ||
import type { CommandArgs } from 'build-scripts'; | ||
import type { Configuration } from 'webpack-dev-server'; | ||
import { DEFAULT_HOST, DEFAULT_PORT } from '../../constant.js'; | ||
|
||
async function getDefaultServerConfig(devServerConfig: Configuration, commandArgs: CommandArgs) { | ||
// Get the value of the host and port from the command line, environment variables, and webpack config. | ||
// Value priority: process.env.PORT > commandArgs > webpackConfig > DEFAULT. | ||
const host = process.env.HOST || | ||
commandArgs.host || | ||
devServerConfig?.host || | ||
DEFAULT_HOST; | ||
const port = process.env.PORT || | ||
commandArgs.port || | ||
devServerConfig?.port || | ||
await detectPort(DEFAULT_PORT); | ||
|
||
return { host, port }; | ||
} | ||
|
||
export default getDefaultServerConfig; |
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,33 @@ | ||
import type { TaskConfig } from 'build-scripts'; | ||
import type { Config } from '@ice/shared-config/types'; | ||
import type { AppConfig } from '@ice/runtime/types'; | ||
import type { Configuration as DevServerConfiguration } from 'webpack-dev-server'; | ||
import prepareURLs from '../../utils/prepareURLs.js'; | ||
import getRouterBasename from '../../utils/getRouterBasename.js'; | ||
|
||
interface Options { | ||
taskConfig: TaskConfig<Config>; | ||
appConfig: AppConfig; | ||
devServerConfig: DevServerConfiguration; | ||
} | ||
|
||
const getUrls = ({ | ||
taskConfig, | ||
appConfig, | ||
devServerConfig, | ||
}: Options) => { | ||
const urlPathname = getRouterBasename(taskConfig, appConfig) || '/'; | ||
const protocol = devServerConfig.https ? 'https' : 'http'; | ||
const enabledHashRouter = appConfig.router?.type === 'hash'; | ||
const urls = prepareURLs( | ||
protocol, | ||
devServerConfig.host, | ||
devServerConfig.port as number, | ||
urlPathname.endsWith('/') ? urlPathname : `${urlPathname}/`, | ||
enabledHashRouter, | ||
); | ||
|
||
return urls; | ||
}; | ||
|
||
export default getUrls; |
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,64 @@ | ||
import type { Configuration as DevServerConfiguration } from 'webpack-dev-server'; | ||
import type { TaskConfig } from 'build-scripts'; | ||
import type { RenderMode } from '@ice/runtime'; | ||
import type { Config } from '@ice/shared-config/types'; | ||
import createMockMiddleware from '../../middlewares/mock/createMiddleware.js'; | ||
import createRenderMiddleware from '../../middlewares/renderMiddleware.js'; | ||
import type { UserConfig } from '../../types/userConfig.js'; | ||
import type RouteManifest from '../../utils/routeManifest.js'; | ||
import type { GetAppConfig } from '../../types/plugin.js'; | ||
|
||
interface SetupOptions { | ||
userConfig: UserConfig; | ||
taskConfig: TaskConfig<Config>; | ||
routeManifest: RouteManifest; | ||
getAppConfig: GetAppConfig; | ||
excuteServerEntry: () => Promise<any>; | ||
mock: boolean; | ||
rootDir: string; | ||
} | ||
|
||
function setupMiddlewares(middlewares: Parameters<DevServerConfiguration['setupMiddlewares']>[0], { | ||
userConfig, | ||
taskConfig, | ||
routeManifest, | ||
getAppConfig, | ||
excuteServerEntry, | ||
mock, | ||
rootDir, | ||
}: SetupOptions) { | ||
const { ssr, ssg } = userConfig; | ||
let renderMode: RenderMode; | ||
// If ssr is set to true, use ssr for preview. | ||
if (ssr) { | ||
renderMode = 'SSR'; | ||
} else if (ssg) { | ||
renderMode = 'SSG'; | ||
} | ||
// Both ssr and ssg, should render the whole page in dev mode. | ||
const documentOnly = !ssr && !ssg; | ||
const serverRenderMiddleware = createRenderMiddleware({ | ||
documentOnly, | ||
renderMode, | ||
getAppConfig, | ||
taskConfig, | ||
userConfig, | ||
routeManifest, | ||
excuteServerEntry, | ||
}); | ||
// @ts-ignore property of name is exist. | ||
const insertIndex = middlewares.findIndex(({ name }) => name === 'serve-index'); | ||
middlewares.splice( | ||
insertIndex, 0, | ||
serverRenderMiddleware, | ||
); | ||
|
||
if (mock) { | ||
const mockMiddleware = createMockMiddleware({ rootDir, exclude: userConfig?.mock?.exclude }); | ||
middlewares.splice(insertIndex, 0, mockMiddleware); | ||
} | ||
return middlewares; | ||
} | ||
|
||
|
||
export default setupMiddlewares; |
Oops, something went wrong.