diff --git a/integration/module-tests/BUILD.bazel b/integration/module-tests/BUILD.bazel index ae8882384d44..5479627f2dc0 100644 --- a/integration/module-tests/BUILD.bazel +++ b/integration/module-tests/BUILD.bazel @@ -20,6 +20,7 @@ module_test( "//src/cdk:npm_package": "src/cdk/npm_package", "//src/material:npm_package": "src/material/npm_package", }, + shard_count = 4, skipped_entry_points = [ # This entry-point is JIT and would fail the AOT test. "@angular/material/dialog/testing", diff --git a/integration/module-tests/index.bzl b/integration/module-tests/index.bzl index 0db7fe80206a..54ca6da86809 100644 --- a/integration/module-tests/index.bzl +++ b/integration/module-tests/index.bzl @@ -1,7 +1,7 @@ load("@aspect_rules_js//js:defs.bzl", "js_test") load("@bazel_skylib//rules:write_file.bzl", "write_file") -def module_test(name, npm_packages, skipped_entry_points = [], additional_deps = []): +def module_test(name, npm_packages, skipped_entry_points = [], additional_deps = [], **kwargs): write_file( name = "%s_config" % name, out = "%s_config.json" % name, @@ -21,4 +21,5 @@ def module_test(name, npm_packages, skipped_entry_points = [], additional_deps = ] + additional_deps + [pkg[0] for pkg in npm_packages.items()], entry_point = ":index.mjs", fixed_args = ["$(rootpath :%s_config)" % name], + **kwargs ) diff --git a/integration/module-tests/index.mts b/integration/module-tests/index.mts index f5a587483e8b..e8db8b42e042 100644 --- a/integration/module-tests/index.mts +++ b/integration/module-tests/index.mts @@ -17,27 +17,38 @@ async function main() { config.packages.map(pkgPath => findAllEntryPointsAndExportedModules(pkgPath)), ); - const exports = packages + const allExports = packages .map(p => p.moduleExports) .flat() - .filter(e => !config.skipEntryPoints.includes(e.importPath)); + .filter(e => !config.skipEntryPoints.includes(e.importPath)) + .sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b))); - const testFile = ` - import {NgModule, Component} from '@angular/core'; - ${exports.map(e => `import {${e.symbolName}} from '${e.importPath}';`).join('\n')} + // Distribute the exports based on the current test shard. + // Controlled via Bazel's `shard_count` attribute. See: + // https://bazel.build/reference/test-encyclopedia#initial-conditions. + const testShardIndex = + process.env['TEST_SHARD_INDEX'] !== undefined ? Number(process.env['TEST_SHARD_INDEX']) : 0; + const testMaxShards = + process.env['TEST_TOTAL_SHARDS'] !== undefined ? Number(process.env['TEST_TOTAL_SHARDS']) : 1; + const testChunkSize = Math.ceil(allExports.length / testMaxShards); + const testChunkStart = testChunkSize * testShardIndex; + const shardExports = allExports.slice(testChunkStart, testChunkStart + testChunkSize); - @NgModule({ - exports: [ - ${exports.map(e => e.symbolName).join(', ')} - ] - }) - export class TestModule {} + const testFiles = shardExports.map(e => ({ + content: ` + import {NgModule, Component} from '@angular/core'; + import {${e.symbolName}} from '${e.importPath}'; - @Component({imports: [TestModule], template: ''}) - export class TestComponent {} - `; + @NgModule({ + exports: [${e.symbolName}] + }) + export class TestModule {} - await fs.writeFile(path.join(tmpDir, 'test.ts'), testFile); + @Component({imports: [TestModule], template: ''}) + export class TestComponent {} + `, + path: path.join(tmpDir, `${e.symbolName.toLowerCase()}.ts`), + })); // Prepare node modules to resolve e.g. `@angular/core` await fs.symlink(path.resolve('./node_modules'), path.join(tmpDir, 'node_modules')); @@ -47,26 +58,34 @@ async function main() { await fs.symlink(path.resolve(packagePath), `./node_modules/${name}`); } - const result = performCompilation({ - options: { - rootDir: tmpDir, - skipLibCheck: true, - noEmit: true, - module: ts.ModuleKind.ESNext, - moduleResolution: ts.ModuleResolutionKind.Bundler, - strictTemplates: true, - preserveSymlinks: true, - strict: true, - // Note: HMR is needed as it will disable the Angular compiler's tree-shaking of used - // directives/components. This is critical for this test as it allows us to simply all - // modules and automatically validate that all symbols are reachable/importable. - _enableHmr: true, - }, - rootNames: [path.join(tmpDir, 'test.ts')], - }); + const diagnostics: ts.Diagnostic[] = []; + + for (const testFile of testFiles) { + await fs.writeFile(testFile.path, testFile.content); + + const result = performCompilation({ + options: { + rootDir: tmpDir, + skipLibCheck: true, + noEmit: true, + module: ts.ModuleKind.ESNext, + moduleResolution: ts.ModuleResolutionKind.Bundler, + strictTemplates: true, + preserveSymlinks: true, + strict: true, + // Note: HMR is needed as it will disable the Angular compiler's tree-shaking of used + // directives/components. This is critical for this test as it allows us to simply all + // modules and automatically validate that all symbols are reachable/importable. + _enableHmr: true, + }, + rootNames: [testFile.path], + }); + + diagnostics.push(...result.diagnostics); + } console.error( - ts.formatDiagnosticsWithColorAndContext(result.diagnostics, { + ts.formatDiagnosticsWithColorAndContext(diagnostics, { getCanonicalFileName: f => f, getCurrentDirectory: () => '/', getNewLine: () => '\n', @@ -75,7 +94,7 @@ async function main() { await fs.rm(tmpDir, {recursive: true, force: true, maxRetries: 2}); - if (result.diagnostics.length > 0) { + if (diagnostics.length > 0) { process.exitCode = 1; } } diff --git a/src/cdk/overlay/overlay-module.ts b/src/cdk/overlay/overlay-module.ts index fbdc64f710a2..ef50725235cd 100644 --- a/src/cdk/overlay/overlay-module.ts +++ b/src/cdk/overlay/overlay-module.ts @@ -36,3 +36,4 @@ export { CdkVirtualScrollableWindow as ɵɵCdkVirtualScrollableWindow, CdkVirtualScrollableElement as ɵɵCdkVirtualScrollableElement, } from '../scrolling'; +export {Dir as ɵɵDir} from '../bidi';