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

refactor: enhance ssr in SPA mode #590

Merged
merged 7 commits into from
Jan 26, 2021
Merged

Conversation

SoloJiang
Copy link
Contributor

@SoloJiang SoloJiang commented Jan 21, 2021

  • Chore: add test cases
  • Fix: midway plugin ssr error
  • Feat: support import { getInitailData } from 'rax-app'
  • Feat: support execute Page.getInitialProps in SPA
  • Fix: compileDependcies is invalid in SSR

@SoloJiang SoloJiang changed the title fix: ssr document mode error refactor: enhance ssr in spa mode Jan 22, 2021
@SoloJiang SoloJiang changed the title refactor: enhance ssr in spa mode refactor: enhance ssr in SPA mode Jan 22, 2021
// Return null directly if not matched
if (_isNullableComponent(PageComponent)) return null;

if (isWeb) {
const navigationProps = Object.assign(
{ staticConfig, component: PageComponent, history, location: history.location, routes, InitialComponent },
{ ...context.pageInitialProps },
{ staticConfig, component: PageComponent, history, location: history.location, routes, ...pageInitialProps },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

navigationProps = {...props}

const { appConfig, buildConfig = {}, createBaseApp, emitLifeCycles } = options;
const { runtime, appConfig: modifiedAppConfig } = createBaseApp(appConfig, buildConfig, context);
const { runtime, appConfig: modifiedAppConfig } = await createBaseApp(appConfig, buildConfig, context);

options.appConfig = modifiedAppConfig;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waring 看能不能顺手修复掉

@@ -0,0 +1,10 @@
export interface IInitialContext {
pathname: string;
query: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query 类型尽量不用 any


config.merge({
devServer: {
before(app, server) {
// If originalDevServerBefore is before than midway, ssr will shut down
if (typeof originalDevServeBefore === 'function') {
originalDevServerBefore(app, server);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样设置的情况下 如果有 mock 文件夹, faas 的 devServer 应该就失效了,逻辑要重新梳理下

@SoloJiang SoloJiang merged commit 894d9ae into release-next Jan 26, 2021
@SoloJiang SoloJiang deleted the fix/ssr-docuement-mode branch January 26, 2021 02:41
SoloJiang added a commit that referenced this pull request Jan 27, 2021
* chore: bump version

* feat: support mpa spm (#591)

* feat: support global css file in mpa (#592)

* refactor: enhance ssr in SPA mode (#590)

* fix: ssr document mode error

* chore: add test case

* fix: midway plugin ssr

* feat: support getInitialData

* fix: page component getInitial props in spa

* chore: add window fallback

* chore: optimize code

* chore: bump version (#597)

* chore: bump beta version

* chore: bump version

* fix: preserve previous build dir (#596)

* chore: bump version (#598)

Co-authored-by: CattChen <42082890+ChenKS12138@users.noreply.github.com>
SoloJiang added a commit that referenced this pull request Feb 25, 2021
* chore: bump version

* feat: support mpa spm (#591)

* feat: support global css file in mpa (#592)

* refactor: enhance ssr in SPA mode (#590)

* fix: ssr document mode error

* chore: add test case

* fix: midway plugin ssr

* feat: support getInitialData

* fix: page component getInitial props in spa

* chore: add window fallback

* chore: optimize code

* feat: support no document

* feat: add document builder

* chore: add local build plugin

* chore: add emit

* feat: no document with staticExport

* feat: support hash in ssr

* chore: revert example

* chore: optimize code

* chore: remove useless code
SoloJiang added a commit that referenced this pull request Feb 26, 2021
* chore: bump version

* fix: data prefetches do not decamelize (#616)

* [Refactor]: Document (#618)

* chore: bump version

* feat: support mpa spm (#591)

* feat: support global css file in mpa (#592)

* refactor: enhance ssr in SPA mode (#590)

* fix: ssr document mode error

* chore: add test case

* fix: midway plugin ssr

* feat: support getInitialData

* fix: page component getInitial props in spa

* chore: add window fallback

* chore: optimize code

* feat: support no document

* feat: add document builder

* chore: add local build plugin

* chore: add emit

* feat: no document with staticExport

* feat: support hash in ssr

* chore: revert example

* chore: optimize code

* chore: remove useless code

* fix: app json content watch (#612)

* Bump version (#620)

* chore: bump version

* chore: add changelog

* chore: update version

* chore: update version

Co-authored-by: 岭伊 <zhengwang2314@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants