Skip to content

Commit 515bb3a

Browse files
committed
docs: Add @let block entry to the API
1 parent 8626d6c commit 515bb3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+612
-14
lines changed

goldens/public-api/compiler-cli/compiler_options.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface LegacyNgcOptions {
5656
// @public
5757
export interface MiscOptions {
5858
compileNonExportedClasses?: boolean;
59+
disableImageImports?: boolean;
5960
disableTypeScriptVersionCheck?: boolean;
6061
forbidOrphanComponents?: boolean;
6162
}

packages/bazel/src/ng_module/ng_module.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def _ngc_tsconfig(ctx, files, srcs, **kwargs):
165165
"fullTemplateTypeCheck": ctx.attr.type_check,
166166
"strictTemplates": ctx.attr.strict_templates,
167167
"compilationMode": compilation_mode,
168+
"disableImageImports": ctx.attr.disable_impage_imports,
168169
# In Google3 we still want to use the symbol factory re-exports in order to
169170
# not break existing apps inside Google. Unlike Bazel, Google3 does not only
170171
# enforce strict dependencies of source files, but also for generated files
@@ -461,6 +462,7 @@ NG_MODULE_ATTRIBUTES = {
461462
"type_check": attr.bool(default = True),
462463
"strict_templates": attr.bool(default = False),
463464
"inline_resources": attr.bool(default = True),
465+
"disable_impage_imports": attr.bool(default = True),
464466
"no_i18n": attr.bool(default = False),
465467
"compiler": attr.label(
466468
doc = """Sets a different ngc compiler binary to use for this library.

packages/bazel/src/ngc-wrapped/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export async function runOneBuild(
9292
'onlyExplicitDeferDependencyImports',
9393
'generateExtraImportsInLocalMode',
9494
'_enableLetSyntax',
95+
'disableImageImports',
9596
]);
9697

9798
const userOverrides = Object.entries(userOptions)

packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_component_linker_1.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export class PartialComponentLinkerVersion1<TStatement, TExpression>
120120
i18nNormalizeLineEndingsInICUs: isInline,
121121
enableBlockSyntax,
122122
enableLetSyntax,
123+
disableImageImports: false /* TODO **/,
123124
});
124125
if (template.errors !== null) {
125126
const errors = template.errors.map((err) => err.toString()).join('\n');
@@ -239,6 +240,7 @@ export class PartialComponentLinkerVersion1<TStatement, TExpression>
239240
relativeContextFilePath: this.sourceUrl,
240241
i18nUseExternalIds: false,
241242
declarations,
243+
disableImageImports: false /** TODO */,
242244
};
243245
}
244246

packages/compiler-cli/src/ngtsc/annotations/component/src/handler.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ export class ComponentDecoratorHandler
249249
private readonly forbidOrphanRendering: boolean,
250250
private readonly enableBlockSyntax: boolean,
251251
private readonly enableLetSyntax: boolean,
252+
private readonly disableImageImports: boolean,
252253
private readonly localCompilationExtraImportsTracker: LocalCompilationExtraImportsTracker | null,
253254
private readonly jitDeclarationRegistry: JitDeclarationRegistry,
254255
) {
@@ -258,6 +259,7 @@ export class ComponentDecoratorHandler
258259
usePoisonedData: this.usePoisonedData,
259260
enableBlockSyntax: this.enableBlockSyntax,
260261
enableLetSyntax: this.enableLetSyntax,
262+
disableImageImports: this.disableImageImports,
261263
};
262264
}
263265

@@ -278,6 +280,7 @@ export class ComponentDecoratorHandler
278280
usePoisonedData: boolean;
279281
enableBlockSyntax: boolean;
280282
enableLetSyntax: boolean;
283+
disableImageImports: boolean;
281284
};
282285

283286
readonly precedence = HandlerPrecedence.PRIMARY;
@@ -629,6 +632,7 @@ export class ComponentDecoratorHandler
629632
usePoisonedData: this.usePoisonedData,
630633
enableBlockSyntax: this.enableBlockSyntax,
631634
enableLetSyntax: this.enableLetSyntax,
635+
disableImageImports: this.disableImageImports,
632636
},
633637
this.compilationMode,
634638
);
@@ -794,6 +798,7 @@ export class ComponentDecoratorHandler
794798
i18nUseExternalIds: this.i18nUseExternalIds,
795799
relativeContextFilePath,
796800
rawImports: rawImports !== null ? new o.WrappedNodeExpr(rawImports) : undefined,
801+
disableImageImports: this.disableImageImports,
797802
},
798803
typeCheckMeta: extractDirectiveTypeCheckMeta(node, inputs, this.reflector),
799804
classMetadata: this.includeClassMetadata
@@ -1536,6 +1541,7 @@ export class ComponentDecoratorHandler
15361541
...analysis.meta,
15371542
...resolution,
15381543
defer: this.compileDeferBlocks(resolution),
1544+
disableImageImports: this.disableImageImports,
15391545
};
15401546
const fac = compileNgFactoryDefField(toFactoryMetadata(meta, FactoryTarget.Component));
15411547

packages/compiler-cli/src/ngtsc/annotations/component/src/resources.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export interface ExtractTemplateOptions {
133133
i18nNormalizeLineEndingsInICUs: boolean;
134134
enableBlockSyntax: boolean;
135135
enableLetSyntax: boolean;
136+
disableImageImports: boolean;
136137
}
137138

138139
export function extractTemplate(
@@ -270,6 +271,7 @@ function parseExtractedTemplate(
270271
escapedString,
271272
enableBlockSyntax: options.enableBlockSyntax,
272273
enableLetSyntax: options.enableLetSyntax,
274+
disableImageImports: options.disableImageImports,
273275
};
274276

275277
const parsedTemplate = parseTemplate(sourceStr, sourceMapUrl ?? '', {

packages/compiler-cli/src/ngtsc/annotations/component/test/component_spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ function setup(
145145
/* forbidOrphanRenderering */ false,
146146
/* enableBlockSyntax */ true,
147147
/* enableLetSyntax */ true,
148+
/* disableImageImports */ false,
148149
/* localCompilationExtraImportsTracker */ null,
149150
jitDeclarationRegistry,
150151
);

packages/compiler-cli/src/ngtsc/core/api/src/public_options.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,4 +436,9 @@ export interface MiscOptions {
436436
* another library without option set will not issue error if rendered in orphan way.
437437
*/
438438
forbidOrphanComponents?: boolean;
439+
440+
/**
441+
* Disables the generation of import statements for local images referenced by ngSrc
442+
*/
443+
disableImageImports?: boolean;
439444
}

packages/compiler-cli/src/ngtsc/core/src/compiler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ export class NgCompiler {
389389
readonly enableTemplateTypeChecker: boolean;
390390
private readonly enableBlockSyntax: boolean;
391391
private readonly enableLetSyntax: boolean;
392+
private readonly disableImageImports: boolean;
392393
private readonly angularCoreVersion: string | null;
393394

394395
/**
@@ -462,6 +463,9 @@ export class NgCompiler {
462463
this.enableBlockSyntax = options['_enableBlockSyntax'] ?? true;
463464
this.enableLetSyntax = options['_enableLetSyntax'] ?? true;
464465
this.angularCoreVersion = options['_angularCoreVersion'] ?? null;
466+
467+
this.disableImageImports = options['disableImageImports'] === true;
468+
465469
this.constructionDiagnostics.push(
466470
...this.adapter.constructionDiagnostics,
467471
...verifyCompatibleTypeCheckOptions(this.options),
@@ -1444,6 +1448,7 @@ export class NgCompiler {
14441448
!!this.options.forbidOrphanComponents,
14451449
this.enableBlockSyntax,
14461450
this.enableLetSyntax,
1451+
this.disableImageImports,
14471452
localCompilationExtraImportsTracker,
14481453
jitDeclarationRegistry,
14491454
),

packages/compiler-cli/src/ngtsc/translator/src/api/import_generator.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export interface ImportRequest<TFile> {
4141
* with anything in the file.
4242
*/
4343
unsafeAliasOverride?: string;
44+
45+
/**
46+
* Attributes to add to the import statement
47+
*/
48+
attributes?: Record<string, string> | null;
4449
}
4550

4651
/**

0 commit comments

Comments
 (0)