Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,12 @@ export function createSsrEntryCodeBundleOptions(
function getEsBuildServerCommonOptions(options: NormalizedApplicationBuildOptions): BuildOptions {
const isNodePlatform = options.ssrOptions?.platform !== ExperimentalPlatform.Neutral;

const commonOptons = getEsBuildCommonOptions(options);
commonOptons.define ??= {};
commonOptons.define['ngServerMode'] = 'true';

return {
...getEsBuildCommonOptions(options),
...commonOptons,
platform: isNodePlatform ? 'node' : 'neutral',
outExtension: { '.js': '.mjs' },
// Note: `es2015` is needed for RxJS v6. If not specified, `module` would
Expand Down Expand Up @@ -587,6 +591,7 @@ function getEsBuildCommonOptions(options: NormalizedApplicationBuildOptions): Bu
// which a constant true value would break.
...(optimizationOptions.scripts ? { 'ngDevMode': 'false' } : undefined),
'ngJitMode': jit ? 'true' : 'false',
'ngServerMode': 'false',
},
loader: loaderExtensions,
footer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
if (scriptsOptimization) {
extraMinimizers.push(
new JavaScriptOptimizerPlugin({
define: buildOptions.aot ? GLOBAL_DEFS_FOR_TERSER_WITH_AOT : GLOBAL_DEFS_FOR_TERSER,
define: {
...(buildOptions.aot ? GLOBAL_DEFS_FOR_TERSER_WITH_AOT : GLOBAL_DEFS_FOR_TERSER),
'ngServerMode': isPlatformServer,
},
sourcemap: scriptsSourceMap,
supportedBrowsers: buildOptions.supportedBrowsers,
keepIdentifierNames: !allowMangle || isPlatformServer,
Expand Down