mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(compiler-cli): move JIT transforms into ngtsc (#56892)
This commit moves the JIT transforms into the ngtsc folder. They existed outside of ngtsc mostly as an historic artifact— and now with compiler relying on them even more deeply, it makes sense to move them into `ngtsc/transform`. PR Close #56892
This commit is contained in:
parent
98ed5b609e
commit
7f550ea0c8
23 changed files with 78 additions and 69 deletions
|
|
@ -84,11 +84,11 @@ ts_library(
|
|||
"//packages/compiler-cli/src/ngtsc/program_driver",
|
||||
"//packages/compiler-cli/src/ngtsc/reflection",
|
||||
"//packages/compiler-cli/src/ngtsc/shims",
|
||||
"//packages/compiler-cli/src/ngtsc/transform/jit",
|
||||
"//packages/compiler-cli/src/ngtsc/translator",
|
||||
"//packages/compiler-cli/src/ngtsc/typecheck",
|
||||
"//packages/compiler-cli/src/ngtsc/typecheck/api",
|
||||
"//packages/compiler-cli/src/ngtsc/util",
|
||||
"//packages/compiler-cli/src/transformers/jit_transforms",
|
||||
"@npm//@bazel/concatjs",
|
||||
"@npm//@types/node",
|
||||
"@npm//@types/yargs",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {NodeJSFileSystem, setFileSystem} from './src/ngtsc/file_system';
|
|||
|
||||
export {VERSION} from './src/version';
|
||||
|
||||
export * from './src/transformers/jit_transforms';
|
||||
export * from './src/ngtsc/transform/jit';
|
||||
export * from './src/transformers/api';
|
||||
export * from './src/transformers/entry_points';
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ ts_library(
|
|||
"//packages/compiler-cli/src/ngtsc/perf",
|
||||
"//packages/compiler-cli/src/ngtsc/reflection",
|
||||
"//packages/compiler-cli/src/ngtsc/sourcemaps",
|
||||
"//packages/compiler-cli/src/ngtsc/transform/jit",
|
||||
"//packages/compiler-cli/src/ngtsc/typecheck/api",
|
||||
"//packages/compiler-cli/src/transformers/jit_transforms",
|
||||
"@npm//typescript",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
import ts from 'typescript';
|
||||
|
||||
import {angularJitApplicationTransform} from '../src/transformers/jit_transforms/index';
|
||||
import {angularJitApplicationTransform} from '../src/ngtsc/transform/jit/index';
|
||||
|
||||
/**
|
||||
* Known values for global variables in `@angular/core` that Terser should set using
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ ts_library(
|
|||
"//packages/compiler-cli/src/ngtsc/shims",
|
||||
"//packages/compiler-cli/src/ngtsc/shims:api",
|
||||
"//packages/compiler-cli/src/ngtsc/transform",
|
||||
"//packages/compiler-cli/src/ngtsc/transform/jit",
|
||||
"//packages/compiler-cli/src/ngtsc/typecheck",
|
||||
"//packages/compiler-cli/src/ngtsc/typecheck/api",
|
||||
"//packages/compiler-cli/src/ngtsc/typecheck/diagnostics",
|
||||
|
|
@ -44,7 +45,6 @@ ts_library(
|
|||
"//packages/compiler-cli/src/ngtsc/util",
|
||||
"//packages/compiler-cli/src/ngtsc/validation",
|
||||
"//packages/compiler-cli/src/ngtsc/xi18n",
|
||||
"//packages/compiler-cli/src/transformers/jit_transforms",
|
||||
"@npm//@types/semver",
|
||||
"@npm//semver",
|
||||
"@npm//typescript",
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ import {DiagnosticCategoryLabel, NgCompilerAdapter, NgCompilerOptions} from '../
|
|||
|
||||
import {coreHasSymbol} from './core_version';
|
||||
import {coreVersionSupportsFeature} from './feature_detection';
|
||||
import {angularJitApplicationTransform} from '@angular/compiler-cli/src/transformers/jit_transforms';
|
||||
import {angularJitApplicationTransform} from '../../transform/jit';
|
||||
|
||||
/**
|
||||
* State information about a compilation which is only generated once some data is requested from
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ load("//tools:defaults.bzl", "ts_library")
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
ts_library(
|
||||
name = "jit_transforms",
|
||||
name = "jit",
|
||||
srcs = glob(["**/*.ts"]),
|
||||
deps = [
|
||||
"//packages/compiler",
|
||||
13
packages/compiler-cli/src/ngtsc/transform/jit/index.ts
Normal file
13
packages/compiler-cli/src/ngtsc/transform/jit/index.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* @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.io/license
|
||||
*/
|
||||
|
||||
export {
|
||||
angularJitApplicationTransform,
|
||||
getDownlevelDecoratorsTransform,
|
||||
getInitializerApiJitTransform,
|
||||
} from './src/index';
|
||||
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
import ts from 'typescript';
|
||||
|
||||
import {isAliasImportDeclaration, loadIsReferencedAliasDeclarationPatch} from '../../ngtsc/imports';
|
||||
import {Decorator, ReflectionHost} from '../../ngtsc/reflection';
|
||||
import {isAliasImportDeclaration, loadIsReferencedAliasDeclarationPatch} from '../../../imports';
|
||||
import {Decorator, ReflectionHost} from '../../../reflection';
|
||||
|
||||
/**
|
||||
* Whether a given decorator should be treated as an Angular decorator.
|
||||
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
import ts from 'typescript';
|
||||
|
||||
import {ImportedSymbolsTracker} from '../../ngtsc/imports';
|
||||
import {TypeScriptReflectionHost} from '../../ngtsc/reflection';
|
||||
import {ImportedSymbolsTracker} from '../../../imports';
|
||||
import {TypeScriptReflectionHost} from '../../../reflection';
|
||||
|
||||
import {getDownlevelDecoratorsTransform} from './downlevel_decorators_transform';
|
||||
import {getInitializerApiJitTransform} from './initializer_api_transforms/transform';
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
import {core} from '@angular/compiler';
|
||||
import ts from 'typescript';
|
||||
|
||||
import {isAngularDecorator, tryParseSignalInputMapping} from '../../../ngtsc/annotations';
|
||||
import {isAngularDecorator, tryParseSignalInputMapping} from '../../../../annotations';
|
||||
|
||||
import {
|
||||
castAsAny,
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
import {Decorator} from '@angular/compiler-cli/src/ngtsc/reflection';
|
||||
import ts from 'typescript';
|
||||
|
||||
import {isAngularDecorator, tryParseSignalModelMapping} from '../../../ngtsc/annotations';
|
||||
import {ImportManager} from '../../../ngtsc/translator';
|
||||
import {isAngularDecorator, tryParseSignalModelMapping} from '../../../../annotations';
|
||||
import {ImportManager} from '../../../../translator';
|
||||
|
||||
import {createSyntheticAngularCoreDecoratorAccess, PropertyTransform} from './transform_api';
|
||||
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {isAngularDecorator, tryParseInitializerBasedOutput} from '../../../ngtsc/annotations';
|
||||
import {isAngularDecorator, tryParseInitializerBasedOutput} from '../../../../annotations';
|
||||
|
||||
import {createSyntheticAngularCoreDecoratorAccess, PropertyTransform} from './transform_api';
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ import {
|
|||
queryDecoratorNames,
|
||||
QueryFunctionName,
|
||||
tryParseSignalQueryFromInitializer,
|
||||
} from '../../../ngtsc/annotations';
|
||||
} from '../../../../annotations';
|
||||
|
||||
import {
|
||||
castAsAny,
|
||||
|
|
@ -6,13 +6,13 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {reflectClassMember} from '@angular/compiler-cli/src/ngtsc/reflection/src/typescript';
|
||||
import ts from 'typescript';
|
||||
|
||||
import {isAngularDecorator} from '../../../ngtsc/annotations';
|
||||
import {ImportedSymbolsTracker} from '../../../ngtsc/imports';
|
||||
import {ReflectionHost} from '../../../ngtsc/reflection';
|
||||
import {ImportManager} from '../../../ngtsc/translator';
|
||||
import {isAngularDecorator} from '../../../../annotations';
|
||||
import {ImportedSymbolsTracker} from '../../../../imports';
|
||||
import {ReflectionHost} from '../../../../reflection';
|
||||
import {reflectClassMember} from '../../../../reflection/src/typescript';
|
||||
import {ImportManager} from '../../../../translator';
|
||||
|
||||
import {signalInputsTransform} from './input_function';
|
||||
import {signalModelTransform} from './model_function';
|
||||
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
import ts from 'typescript';
|
||||
|
||||
import {ImportedSymbolsTracker} from '../../../ngtsc/imports';
|
||||
import {ClassMember, Decorator, ReflectionHost} from '../../../ngtsc/reflection';
|
||||
import {ImportManager} from '../../../ngtsc/translator';
|
||||
import {ImportedSymbolsTracker} from '../../../../imports';
|
||||
import {ClassMember, Decorator, ReflectionHost} from '../../../../reflection';
|
||||
import {ImportManager} from '../../../../translator';
|
||||
|
||||
/** Function that can be used to transform class properties. */
|
||||
export type PropertyTransform = (
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"downlevel_decorators_transform_spec.ts",
|
||||
"initializer_api_transforms_spec.ts",
|
||||
"signal_queries_metadata_transform_spec.ts",
|
||||
],
|
||||
deps = [
|
||||
"//packages/compiler-cli/src/ngtsc/imports",
|
||||
"//packages/compiler-cli/src/ngtsc/partial_evaluator",
|
||||
"//packages/compiler-cli/src/ngtsc/reflection",
|
||||
"//packages/compiler-cli/src/ngtsc/transform/jit",
|
||||
"//packages/compiler-cli/test:test_utils",
|
||||
"@npm//typescript",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
name = "test",
|
||||
bootstrap = ["//tools/testing:node"],
|
||||
deps = [
|
||||
":test_lib",
|
||||
],
|
||||
)
|
||||
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
import ts from 'typescript';
|
||||
|
||||
import {TypeScriptReflectionHost} from '../src/ngtsc/reflection';
|
||||
import {getDownlevelDecoratorsTransform} from '../src/transformers/jit_transforms/index';
|
||||
import {TypeScriptReflectionHost} from '../../../reflection';
|
||||
import {getDownlevelDecoratorsTransform} from '../index';
|
||||
|
||||
import {MockAotContext, MockCompilerHost} from './mocks';
|
||||
import {MockAotContext, MockCompilerHost} from '../../../../../test/mocks';
|
||||
|
||||
const TEST_FILE_INPUT = '/test.ts';
|
||||
const TEST_FILE_OUTPUT = `/test.js`;
|
||||
|
|
@ -8,14 +8,11 @@
|
|||
|
||||
import ts from 'typescript';
|
||||
|
||||
import {ImportedSymbolsTracker} from '../src/ngtsc/imports';
|
||||
import {TypeScriptReflectionHost} from '../src/ngtsc/reflection';
|
||||
import {
|
||||
getDownlevelDecoratorsTransform,
|
||||
getInitializerApiJitTransform,
|
||||
} from '../src/transformers/jit_transforms';
|
||||
import {ImportedSymbolsTracker} from '../../../imports';
|
||||
import {TypeScriptReflectionHost} from '../../../reflection';
|
||||
import {getDownlevelDecoratorsTransform, getInitializerApiJitTransform} from '../index';
|
||||
|
||||
import {MockAotContext, MockCompilerHost} from './mocks';
|
||||
import {MockAotContext, MockCompilerHost} from '../../../../../test/mocks';
|
||||
|
||||
const TEST_FILE_INPUT = '/test.ts';
|
||||
const TEST_FILE_OUTPUT = `/test.js`;
|
||||
|
|
@ -8,14 +8,11 @@
|
|||
|
||||
import ts from 'typescript';
|
||||
|
||||
import {ImportedSymbolsTracker} from '../src/ngtsc/imports';
|
||||
import {TypeScriptReflectionHost} from '../src/ngtsc/reflection';
|
||||
import {
|
||||
getDownlevelDecoratorsTransform,
|
||||
getInitializerApiJitTransform,
|
||||
} from '../src/transformers/jit_transforms';
|
||||
import {ImportedSymbolsTracker} from '../../../imports';
|
||||
import {TypeScriptReflectionHost} from '../../../reflection';
|
||||
import {getDownlevelDecoratorsTransform, getInitializerApiJitTransform} from '../index';
|
||||
|
||||
import {MockAotContext, MockCompilerHost} from './mocks';
|
||||
import {MockAotContext, MockCompilerHost} from '../../../../../test/mocks';
|
||||
|
||||
const TEST_FILE_INPUT = '/test.ts';
|
||||
const TEST_FILE_OUTPUT = `/test.js`;
|
||||
|
|
@ -11,6 +11,7 @@ ts_library(
|
|||
],
|
||||
visibility = [
|
||||
":__subpackages__",
|
||||
"//packages/compiler-cli/src/ngtsc/transform/jit/test:__pkg__",
|
||||
"//packages/language-service/test:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
|
|
@ -52,32 +53,6 @@ jasmine_node_test(
|
|||
],
|
||||
)
|
||||
|
||||
ts_library(
|
||||
name = "jit_transforms_test_lib",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"downlevel_decorators_transform_spec.ts",
|
||||
"initializer_api_transforms_spec.ts",
|
||||
"signal_queries_metadata_transform_spec.ts",
|
||||
],
|
||||
deps = [
|
||||
":test_utils",
|
||||
"//packages/compiler-cli/src/ngtsc/imports",
|
||||
"//packages/compiler-cli/src/ngtsc/partial_evaluator",
|
||||
"//packages/compiler-cli/src/ngtsc/reflection",
|
||||
"//packages/compiler-cli/src/transformers/jit_transforms",
|
||||
"@npm//typescript",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
name = "jit_transforms_test",
|
||||
bootstrap = ["//tools/testing:node"],
|
||||
deps = [
|
||||
":jit_transforms_test_lib",
|
||||
],
|
||||
)
|
||||
|
||||
# perform_watch_spec
|
||||
ts_library(
|
||||
name = "perform_watch_lib",
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ ts_library(
|
|||
"//packages/compiler-cli/src/ngtsc/imports",
|
||||
"//packages/compiler-cli/src/ngtsc/partial_evaluator",
|
||||
"//packages/compiler-cli/src/ngtsc/reflection",
|
||||
"//packages/compiler-cli/src/transformers/jit_transforms",
|
||||
"//packages/compiler-cli/src/ngtsc/transform/jit",
|
||||
"@npm//typescript",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {ImportedSymbolsTracker} from '@angular/compiler-cli/src/ngtsc/imports';
|
||||
import {TypeScriptReflectionHost} from '@angular/compiler-cli/src/ngtsc/reflection';
|
||||
import {getInitializerApiJitTransform} from '@angular/compiler-cli/src/transformers/jit_transforms';
|
||||
import {getInitializerApiJitTransform} from '@angular/compiler-cli/src/ngtsc/transform/jit';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import ts from 'typescript';
|
||||
|
|
|
|||
Loading…
Reference in a new issue