Skip to content
Merged
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
1 change: 1 addition & 0 deletions apps/code-of-conduct/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ng_project(
":node_modules/@angular/animations",
":node_modules/@angular/common",
":node_modules/@angular/compiler",
":node_modules/@angular/core",
":node_modules/@angular/fire",
":node_modules/@angular/platform-browser",
":node_modules/@angular/router",
Expand Down
1 change: 1 addition & 0 deletions apps/code-of-conduct/app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ng_project(
deps = [
"//apps/code-of-conduct:node_modules/@angular/common",
"//apps/code-of-conduct:node_modules/@angular/core",
"//apps/code-of-conduct:node_modules/@angular/material",
"//apps/code-of-conduct:node_modules/@angular/router",
"//apps/code-of-conduct/app/account",
"//apps/code-of-conduct/app/block-user",
Expand Down
2 changes: 0 additions & 2 deletions apps/code-of-conduct/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {Component} from '@angular/core';
import {MatToolbarModule} from '@angular/material/toolbar';
import {RouterModule} from '@angular/router';
import {AccountComponent} from './account/account.component.js';
import {BlockUserComponent} from './block-user/block-user.component.js';
import {UserTableComponent} from './user-table/user-table.component.js';

@Component({
standalone: true,
Expand Down
1 change: 1 addition & 0 deletions apps/code-of-conduct/app/login/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ng_project(
"//apps/code-of-conduct:node_modules/@angular/common",
"//apps/code-of-conduct:node_modules/@angular/core",
"//apps/code-of-conduct:node_modules/@angular/material",
"//apps/code-of-conduct:node_modules/@angular/router",
"//apps/code-of-conduct/app/account",
],
)
Expand Down
4 changes: 1 addition & 3 deletions bazel/ts_project/strict_deps/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ function checkPathsForMatch(moduleSpecifier: string, paths?: ts.MapLike<string[]
const knownModuleSpecifiersWithExtensions = new Set(['highlight.js', 'zone.js']);

for (const fileExecPath of manifest.testFiles) {
const content = await fs.readFile(fileExecPath, 'utf8');
const sf = ts.createSourceFile(fileExecPath, content, ts.ScriptTarget.ESNext, true);
const imports = getImportsInSourceFile(sf);
const imports = getImportsInSourceFile(fileExecPath);

for (const i of imports) {
const moduleSpecifier = knownModuleSpecifiersWithExtensions.has(i.moduleSpecifier)
Expand Down
13 changes: 12 additions & 1 deletion bazel/ts_project/strict_deps/visitor.mts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,28 @@
*/

import ts from 'typescript';
import fs from 'node:fs';

export interface Import {
diagnosticNode: ts.Node;
moduleSpecifier: string;
}

export function getImportsInSourceFile(sf: ts.SourceFile): Import[] {
export function getImportsInSourceFile(fileExecPath: string): Import[] {
const content = fs.readFileSync(fileExecPath, 'utf8');
const sf = ts.createSourceFile(fileExecPath, content, ts.ScriptTarget.ESNext, true);
const result: Import[] = [];

const visitor = (node: ts.Node) => {
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
const leadingComments = ts.getLeadingCommentRanges(content, node.pos) || [];
for (const comment of leadingComments) {
const commentText = content.substring(comment.pos, comment.end);
if (/@ts-ignore.*strict-deps/.test(commentText)) {
return;
}
}

const moduleSpecifier = node.moduleSpecifier as ts.StringLiteral;
// If not moduleSpecifier is included in the declaration, it is infered to be the local file,
// essentially a self import and can be ignored.
Expand Down
2 changes: 1 addition & 1 deletion github-actions/bazel/configure-remote/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

// @ts-ignore-next-line
// @ts-ignore-next-line strict-deps
import tokenRaw from './gcp_token.data';
import {k, iv, alg, at} from './constants.js';
import {createDecipheriv} from 'crypto';
Expand Down
2 changes: 1 addition & 1 deletion github-actions/browserstack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

// @ts-ignore
// @ts-ignore-next-line strict-deps
import tokenRaw from './browserstack_token.data';
import {k, iv, alg, at} from './constants.js';
import {createDecipheriv} from 'crypto';
Expand Down
2 changes: 1 addition & 1 deletion github-actions/saucelabs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

// @ts-ignore
// @ts-ignore-next-line strict-deps
import tokenRaw from './saucelabs_token.data';
import {k, iv, alg, at} from './constants.js';
import {createDecipheriv} from 'crypto';
Expand Down
13 changes: 0 additions & 13 deletions ng-dev/utils/yarn-lock-file.d.ts

This file was deleted.

25 changes: 23 additions & 2 deletions tools/defaults.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ load("@rules_angular//src/ng_project:index.bzl", _ng_project = "ng_project")
load("@rules_angular//src/ts_project:index.bzl", _ts_project = "ts_project")
load("@rules_sass//src:index.bzl", _npm_sass_library = "npm_sass_library", _sass_binary = "sass_binary")
load("//bazel:extract_types.bzl", _extract_types = "extract_types")
load("//bazel/ts_project:index.bzl", _strict_deps_test = "strict_deps_test")

copy_to_bin = _copy_to_bin
ts_config = _ts_config
Expand All @@ -28,6 +29,8 @@ def _determine_tsconfig(testonly):

def ts_project(
name,
srcs = [],
deps = [],
source_map = True,
testonly = False,
tsconfig = None,
Expand All @@ -38,35 +41,53 @@ def ts_project(

_ts_project(
name,
deps = deps,
srcs = srcs,
source_map = source_map,
testonly = testonly,
tsconfig = tsconfig,
declaration = declaration,
**kwargs
)

_strict_deps_test(
name = "%s_strict_deps_test" % name,
tsconfig = tsconfig,
deps = deps,
srcs = srcs,
)

def ng_project(
name,
srcs = [],
deps = [],
source_map = True,
testonly = False,
tsconfig = None,
declaration = True,
deps = [],
**kwargs):
if tsconfig == None:
tsconfig = _determine_tsconfig(testonly)

deps = deps + ["//:node_modules/tslib"]
_ng_project(
name,
deps = deps,
srcs = srcs,
source_map = source_map,
declaration = declaration,
testonly = testonly,
tsconfig = tsconfig,
deps = deps,
**kwargs
)

_strict_deps_test(
name = "%s_strict_deps_test" % name,
tsconfig = tsconfig,
deps = deps,
srcs = srcs,
)

def npm_package(name, srcs = [], substitutions = {}, **kwargs):
_text_replace(
name = "%s_substituted" % name,
Expand Down