2025-03-21 13:48:04 +00:00
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
|
|
|
|
|
2025-06-02 14:18:09 +00:00
|
|
|
import linkerBabelPlugin from '../../../packages/compiler-cli/linker/babel';
|
2025-03-21 13:48:04 +00:00
|
|
|
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)));
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
|
2025-04-10 07:47:21 +00:00
|
|
|
process.chdir(outDir);
|
2025-03-21 13:48:04 +00:00
|
|
|
|
2025-04-10 07:47:21 +00:00
|
|
|
// We compile with an unstamped version of the compiler, so ignore.
|
|
|
|
|
process.env['LINKER_UNKNOWN_DECLARATION_VERSION_HANDLING'] = 'ignore';
|
2025-03-21 13:48:04 +00:00
|
|
|
|
2025-04-10 07:47:21 +00:00
|
|
|
// Run linking in cwd.
|
|
|
|
|
import('@nginfra/angular-linking');
|
2025-03-21 13:48:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main().catch((e) => {
|
|
|
|
|
console.error(e, e.stack);
|
|
|
|
|
process.exitCode = 1;
|
|
|
|
|
});
|