Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support signal input in 17.1 #2255

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
"prepublishOnly": "pinst --disable",
"postpublish": "pinst --enable",
"update-e2e": "node scripts/update-e2e.js"
"update-e2e": "node scripts/update-e2e.js",
"build-ng-source": "node scripts/prebuild.js"
},
"dependencies": {
"bs-logger": "^0.2.6",
Expand Down
65 changes: 10 additions & 55 deletions scripts/prebuild.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,10 @@
const chalk = require('chalk');
const execa = require('execa');

const buildDir = 'build';
const ngTransformerPath = `./src/transformers/downlevel_decorators_transform`;
const bazelFileGlob = 'src/**/BUILD.bazel';
const ngTestFolder = 'src/ngtsc/reflection/test';
const ngTransformerURL =
'https://github.com/angular/angular/blob/15.0.4/packages/compiler-cli/src/transformers/downlevel_decorators_transform';
const ngReflectionURL = 'https://github.com/angular/angular/blob/15.0.4/packages/compiler-cli/src/ngtsc/reflection';
const tsCompatUrl = 'https://github.com/angular/angular/blob/15.0.4/packages/compiler-cli/src/ngtsc/ts_compatibility';
const transformersFolder = './src/transformers';
const ngtscFolder = './src/ngtsc';

process.stdout.write(chalk.green(' \u2022 ') + 'clean up ' + chalk.blue(buildDir) + '\n');

execa.sync('yarn', ['rimraf', buildDir]);

process.stdout.write(
chalk.green(' \u2022 ') +
'clean up previously downloaded assets' +
chalk.blue(`${ngTransformerPath}, ${ngtscFolder}`) +
'\n'
);

execa.sync('yarn', ['rimraf', ngTransformerPath, ngtscFolder]);

process.stdout.write(
chalk.green(' \u2022 ') +
`downloading Angular Downlevel Decorator Transformer from ${ngTransformerURL}` +
chalk.green(' \u21D2 ') +
transformersFolder +
'\n'
);

execa.sync('yarn', ['fetcher', `--url=${ngTransformerURL}`, `--out=${transformersFolder}`]);

process.stdout.write(
chalk.green(' \u2022 ') +
`downloading dependencies for Angular Downlevel Decorator Transformer from ${[ngReflectionURL, tsCompatUrl]}` +
chalk.green(' \u21D2 ') +
ngtscFolder +
'\n'
);

execa.sync('yarn', ['fetcher', `--url=${ngReflectionURL}`, `--out=${ngtscFolder}`]);
execa.sync('yarn', ['fetcher', `--url=${tsCompatUrl}`, `--out=${ngtscFolder}`]);

process.stdout.write(chalk.green(' \u2022 ') + 'clean up Bazel files ' + chalk.blue(bazelFileGlob) + '\n');

execa.sync('yarn', ['rimraf', bazelFileGlob]);

process.stdout.write(chalk.green(' \u2022 ') + 'clean up Angular test files ' + chalk.blue(ngTestFolder) + '\n');

execa.sync('yarn', ['rimraf', ngTestFolder]);
const { buildSync } = require('esbuild');

buildSync({
entryPoints: ['src/transformers/downlevel-ctor.ts'],
outdir: 'build',
external: ['esbuild', 'ts-jest', 'typescript'],
platform: 'node',
target: 'node16',
bundle: true,
});
15 changes: 14 additions & 1 deletion src/transformers/downlevel-ctor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getInputSignalsMetadataTransform } from '@angular/compiler-cli/src/transformers/jit_transforms';
import type ts from 'typescript';

import { TypeScriptReflectionHost } from '../ngtsc/reflection';
Expand All @@ -7,6 +8,18 @@
export const constructorParametersDownlevelTransform = (program: ts.Program): ts.TransformerFactory<ts.SourceFile> => {
const typeChecker = program.getTypeChecker();
const reflectionHost = new TypeScriptReflectionHost(typeChecker);
const inputSignalMetadataTransform = getInputSignalsMetadataTransform(reflectionHost, false);

Check failure on line 11 in src/transformers/downlevel-ctor.ts

View workflow job for this annotation

GitHub Actions / lint

Argument of type 'TypeScriptReflectionHost' is not assignable to parameter of type 'ReflectionHost'.

Check failure on line 11 in src/transformers/downlevel-ctor.ts

View workflow job for this annotation

GitHub Actions / test-ubuntu / Node v18.x on ubuntu-latest

Argument of type 'TypeScriptReflectionHost' is not assignable to parameter of type 'ReflectionHost'.

Check failure on line 11 in src/transformers/downlevel-ctor.ts

View workflow job for this annotation

GitHub Actions / test-ubuntu / Node v20.x on ubuntu-latest

Argument of type 'TypeScriptReflectionHost' is not assignable to parameter of type 'ReflectionHost'.

Check failure on line 11 in src/transformers/downlevel-ctor.ts

View workflow job for this annotation

GitHub Actions / test-windows / Node v18.x on windows-latest

Argument of type 'TypeScriptReflectionHost' is not assignable to parameter of type 'ReflectionHost'.

Check failure on line 11 in src/transformers/downlevel-ctor.ts

View workflow job for this annotation

GitHub Actions / test-windows / Node v20.x on windows-latest

Argument of type 'TypeScriptReflectionHost' is not assignable to parameter of type 'ReflectionHost'.

return getDownlevelDecoratorsTransform(typeChecker, reflectionHost, [], false, false, true);
return (ctx) => {
return (sourceFile) => {
if (inputSignalMetadataTransform) {
sourceFile = inputSignalMetadataTransform(ctx)(sourceFile);
}
sourceFile = getDownlevelDecoratorsTransform(typeChecker, reflectionHost, [], false, false, true)(ctx)(
sourceFile,
);

return sourceFile;
};
};
};
Loading