mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
This commit migrates the remaining pieces of `compiler-cli` to `ts_project`. This involves a few more things during migration: - the `ng_module` ngc_wrapped rule broke as part of this change, so we switched it to `ts_project` too. This logic is soon gone anyway. - we needed an extra pnpm "package.json" for the linker babel test. This test is loading from the real compiler-cli npm package. Babel needs a real node module for this, so this solution seems reasonable. It may be worth exploring in the future to move this test into an integration test though. - the older integrationtest in compiler-cli is removed as the coverage is much better with the compliance test suite and this test. PR Close #61826
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.dev/license
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview
|
|
*
|
|
* Script that copies the npm package contents of e.g. `@angular/cdk` over into
|
|
* a new output directory while performing Angular linking using the local
|
|
* Angular compiler-cli version.
|
|
*
|
|
* This is necessary for the devtools as we don't want to rely on JIT compilation,
|
|
* and consumed libraries like Angular CDK, or Angular Material are only shipping
|
|
* partial compilation output to npm.
|
|
*/
|
|
|
|
import linkerBabelPlugin from '../../../packages/compiler-cli/linker/babel';
|
|
import {transformAsync} from '@babel/core';
|
|
import {readFile, writeFile, mkdir} from 'node:fs/promises';
|
|
import {globSync} from 'tinyglobby';
|
|
import path from 'path';
|
|
|
|
async function main() {
|
|
const [packageDir, outDir] = process.argv.slice(2);
|
|
|
|
// Copy without preserving readonly permissions from Bazel.
|
|
await Promise.all(
|
|
globSync('**/*', {cwd: packageDir}).map(async (filePath) => {
|
|
await mkdir(path.dirname(path.join(outDir, filePath)), {recursive: true});
|
|
await writeFile(path.join(outDir, filePath), await readFile(path.join(packageDir, filePath)));
|
|
}),
|
|
);
|
|
|
|
process.chdir(outDir);
|
|
|
|
// We compile with an unstamped version of the compiler, so ignore.
|
|
process.env['LINKER_UNKNOWN_DECLARATION_VERSION_HANDLING'] = 'ignore';
|
|
|
|
// Run linking in cwd.
|
|
import('@nginfra/angular-linking');
|
|
}
|
|
|
|
main().catch((e) => {
|
|
console.error(e, e.stack);
|
|
process.exitCode = 1;
|
|
});
|