Skip to content

Commit

Permalink
feat: use getSSRInlineScript function
Browse files Browse the repository at this point in the history
  • Loading branch information
targeral committed Nov 13, 2024
1 parent ec95f77 commit 836cd2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { SSRContainer } from '../../types';
import { SSR_DATA_PLACEHOLDER } from '../constants';
import type { HandleRequestConfig } from '../requestHandler';
import { type BuildHtmlCb, type SSRConfig, buildHtml } from '../shared';
import { attributesToString, safeReplace } from '../utils';
import { attributesToString, getSSRInlineScript, safeReplace } from '../utils';

export type BuildShellAfterTemplateOptions = {
runtimeContext: RuntimeContext;
Expand Down Expand Up @@ -103,8 +103,7 @@ function createReplaceSSRData(options: {
};
const attrsStr = attributesToString({ nonce });

const inlineScript =
typeof ssrConfig === 'boolean' ? true : ssrConfig?.inlineScript !== false;
const inlineScript = getSSRInlineScript(ssrConfig);
const useInlineScript = inlineScript !== false;
const serializeSSRData = serializeJson(ssrData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import type { HeadersData } from '@modern-js/runtime-utils/universal/request';
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from '../../constants';
import type { SSRContainer, SSRServerContext } from '../../types';
import type { SSRConfig } from '../shared';
import { attributesToString, serializeErrors } from '../utils';
import {
attributesToString,
getSSRInlineScript,
serializeErrors,
} from '../utils';
import type { ChunkSet, Collector } from './types';

export interface SSRDataCreatorOptions {
Expand Down Expand Up @@ -83,8 +87,7 @@ export class SSRDataCollector implements Collector {
routerData?: Record<string, any>,
) {
const { nonce, ssrConfig } = this.#options;
const inlineScript =
typeof ssrConfig === 'boolean' ? true : ssrConfig?.inlineScript !== false;
const inlineScript = getSSRInlineScript(ssrConfig);

const useInlineScript = inlineScript !== false;
const serializeSSRData = serializeJson(ssrData);
Expand Down

0 comments on commit 836cd2e

Please sign in to comment.