Skip to content
Open
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 @@ -151,15 +151,19 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
.not.toBeNull();

const mapping = JSON.parse(mappingSource![1]) as Record<string, string[]>;
const mainServerContent = harness.readFile('dist/server/main.server.mjs');

// Every lazy route entry point must retain a mapping entry after optimization.
// Every lazy route entry point must retain a mapping entry after optimization
// that matches the ɵentryName emitted into the server bundle.
for (const name of LAZY_ROUTE_NAMES) {
const key = Object.keys(mapping).find((entryPoint) =>
entryPoint.endsWith(`${name}.component.ts`),
);
expect(key)
.withContext(`mapping entry for lazy route '${name}' should exist`)
const expectedEntryPoint = `src/app/${name}.component.ts`;
expect(mapping[expectedEntryPoint])
.withContext(`mapping entry for '${expectedEntryPoint}' should exist`)
.toBeDefined();

expect(mainServerContent)
.withContext(`main.server.mjs should contain ɵentryName '${expectedEntryPoint}'`)
.toContain(expectedEntryPoint);
}

// Every browser file referenced by the mapping must exist on disk.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,17 +326,23 @@ describe('AngularCompilation', () => {
it('applies override options correctly', () => {
const { compilerOptions } = transformCompilerOptions(
ts,
{ target: ts.ScriptTarget.ES2022, isolatedModules: true },
{
target: ts.ScriptTarget.ES2022,
isolatedModules: true,
basePath: '/workspace/projects/app',
},
{
sourcemap: true,
preserveSymlinks: true,
externalRuntimeStyles: true,
enableHmr: true,
instrumentForCoverage: true,
includeTestMetadata: true,
basePath: '/workspace',
},
);

expect(compilerOptions.basePath).toBe('/workspace');
expect(compilerOptions.inlineSources).toBe(true);
expect(compilerOptions.inlineSourceMap).toBe(true);
expect(compilerOptions.preserveSymlinks).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface CompilerOptionOverrides {
includeTestMetadata?: boolean;
customConditions?: string[];
rootFiles?: string[];
basePath?: string;
}

export function transformCompilerOptions(
Expand Down Expand Up @@ -113,6 +114,7 @@ export function transformCompilerOptions(
return {
compilerOptions: {
...compilerOptions,
basePath: overrides?.basePath ?? compilerOptions.basePath,
noEmitOnError: false,
composite: false,
inlineSources: !!overrides?.sourcemap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ export function createCompilerPlugin(
includeTestMetadata: !!pluginOptions.includeTestMetadata,
customConditions: build.initialOptions.conditions,
rootFiles: pluginOptions.rootFiles,
basePath: build.initialOptions.absWorkingDir,
Comment thread
alan-agius4 marked this conversation as resolved.
},
);

Expand Down
Loading