build: add bazel integration test (#18733)
It includes sass compilation, and building the bazel package distribution. PR Close #18733
This commit is contained in:
@ -3,72 +3,113 @@
|
||||
# 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
|
||||
|
||||
load("@build_bazel_rules_typescript//internal:build_defs.bzl", "tsc_wrapped_tsconfig")
|
||||
|
||||
load(
|
||||
"@build_bazel_rules_typescript//internal:common/compilation.bzl",
|
||||
"COMMON_ATTRIBUTES", "compile_ts", "ts_providers_dict_to_struct"
|
||||
load(":rules_typescript.bzl",
|
||||
"tsc_wrapped_tsconfig",
|
||||
"COMMON_ATTRIBUTES",
|
||||
"compile_ts",
|
||||
"DEPS_ASPECTS",
|
||||
"ts_providers_dict_to_struct",
|
||||
"json_marshal",
|
||||
)
|
||||
|
||||
load("@build_bazel_rules_typescript//internal:common/json_marshal.bzl", "json_marshal")
|
||||
|
||||
# Calculate the expected output of the template compiler for every source in
|
||||
# in the library. Most of these will be produced as empty files but it is
|
||||
# unknown, without parsing, which will be empty.
|
||||
def _expected_outs(ctx):
|
||||
result = []
|
||||
def _expected_outs(ctx, label):
|
||||
devmode_js_files = []
|
||||
closure_js_files = []
|
||||
declaration_files = []
|
||||
summary_files = []
|
||||
|
||||
codegen_inputs = ctx.files.srcs
|
||||
|
||||
for src in ctx.files.srcs + ctx.files.assets:
|
||||
if src.short_path.endswith(".ts") and not src.short_path.endswith(".d.ts"):
|
||||
basename = src.short_path[len(ctx.label.package) + 1:-len(".ts")]
|
||||
devmode_js = [
|
||||
".ngfactory.js",
|
||||
".ngsummary.js",
|
||||
".js",
|
||||
]
|
||||
summaries = [".ngsummary.json"]
|
||||
|
||||
for src in ctx.files.srcs:
|
||||
if src.short_path.endswith(".ts"):
|
||||
basename = src.short_path[len(ctx.label.package) + 1:-3]
|
||||
result += [ctx.new_file(ctx.bin_dir, basename + ext) for ext in [
|
||||
".ngfactory.js",
|
||||
".ngfactory.d.ts",
|
||||
".ngsummary.js",
|
||||
".ngsummary.d.ts",
|
||||
".ngsummary.json",
|
||||
]]
|
||||
elif src.short_path.endswith(".css"):
|
||||
basename = src.short_path[len(ctx.label.package) + 1:-4]
|
||||
result += [ctx.new_file(ctx.bin_dir, basename + ext) for ext in [
|
||||
".css.shim.ngstyle.js",
|
||||
".css.shim.ngstyle.d.ts",
|
||||
".css.ngstyle.js",
|
||||
".css.ngstyle.d.ts",
|
||||
]]
|
||||
return result
|
||||
basename = src.short_path[len(ctx.label.package) + 1:-len(".css")]
|
||||
devmode_js = [
|
||||
".css.shim.ngstyle.js",
|
||||
".css.ngstyle.js",
|
||||
]
|
||||
summaries = []
|
||||
|
||||
closure_js = [f.replace(".js", ".closure.js") for f in devmode_js]
|
||||
declarations = [f.replace(".js", ".d.ts") for f in devmode_js]
|
||||
|
||||
devmode_js_files += [ctx.new_file(ctx.bin_dir, basename + ext) for ext in devmode_js]
|
||||
closure_js_files += [ctx.new_file(ctx.bin_dir, basename + ext) for ext in closure_js]
|
||||
declaration_files += [ctx.new_file(ctx.bin_dir, basename + ext) for ext in declarations]
|
||||
summary_files += [ctx.new_file(ctx.bin_dir, basename + ext) for ext in summaries]
|
||||
|
||||
return struct(
|
||||
closure_js = closure_js_files,
|
||||
devmode_js = devmode_js_files,
|
||||
declarations = declaration_files,
|
||||
summaries = summary_files,
|
||||
)
|
||||
|
||||
def _ngc_tsconfig(ctx, files, srcs, **kwargs):
|
||||
outs = _expected_outs(ctx, ctx.label)
|
||||
if "devmode_manifest" in kwargs:
|
||||
expected_outs = outs.devmode_js + outs.declarations + outs.summaries
|
||||
else:
|
||||
expected_outs = outs.closure_js
|
||||
|
||||
return dict(tsc_wrapped_tsconfig(ctx, files, srcs, **kwargs), **{
|
||||
"angularCompilerOptions": {
|
||||
"expectedOut": [o.path for o in _expected_outs(ctx)],
|
||||
"generateCodeForLibraries": False,
|
||||
# FIXME: wrong place to de-dupe
|
||||
"expectedOut": depset([o.path for o in expected_outs]).to_list()
|
||||
}
|
||||
})
|
||||
|
||||
def _collect_summaries_aspect_impl(target, ctx):
|
||||
results = target.angular.summaries if hasattr(target, "angular") else depset()
|
||||
|
||||
# If we are visiting empty-srcs ts_library, this is a re-export
|
||||
srcs = target.srcs if hasattr(target, "srcs") else []
|
||||
|
||||
# "re-export" rules should expose all the files of their deps
|
||||
if not srcs:
|
||||
for dep in ctx.rule.attr.deps:
|
||||
if (hasattr(dep, "angular")):
|
||||
results += dep.angular.summaries
|
||||
|
||||
return struct(collect_summaries_aspect_result = results)
|
||||
|
||||
_collect_summaries_aspect = aspect(
|
||||
implementation = _collect_summaries_aspect_impl,
|
||||
attr_aspects = ["deps"],
|
||||
)
|
||||
|
||||
def _compile_action(ctx, inputs, outputs, config_file_path):
|
||||
externs_files = []
|
||||
non_externs_files = []
|
||||
for output in outputs:
|
||||
if output.basename.endswith(".es5.MF"):
|
||||
ctx.file_action(output, content="")
|
||||
else:
|
||||
non_externs_files.append(output)
|
||||
summaries = depset()
|
||||
for dep in ctx.attr.deps:
|
||||
if hasattr(dep, "collect_summaries_aspect_result"):
|
||||
summaries += dep.collect_summaries_aspect_result
|
||||
|
||||
# TODO(alexeagle): For now we mock creation of externs files
|
||||
for externs_file in externs_files:
|
||||
ctx.file_action(output=externs_file, content="")
|
||||
action_inputs = inputs + summaries.to_list() + ctx.files.assets
|
||||
# print("ASSETS", [a.path for a in ctx.files.assets])
|
||||
# print("INPUTS", ctx.label, [o.path for o in summaries if o.path.find("core/src") > 0])
|
||||
|
||||
action_inputs = inputs
|
||||
if hasattr(ctx.attr, "node_modules"):
|
||||
action_inputs += [f for f in ctx.files.node_modules
|
||||
if f.path.endswith(".ts") or f.path.endswith(".json")]
|
||||
if ctx.file.tsconfig:
|
||||
if hasattr(ctx.attr, "tsconfig") and ctx.file.tsconfig:
|
||||
action_inputs += [ctx.file.tsconfig]
|
||||
|
||||
# One at-sign makes this a params-file, enabling the worker strategy.
|
||||
# Two at-signs escapes the argument so it's passed through to ngc
|
||||
# rather than the contents getting expanded.
|
||||
if ctx.attr.supports_workers:
|
||||
if ctx.attr._supports_workers:
|
||||
arguments = ["@@" + config_file_path]
|
||||
else:
|
||||
arguments = ["-p", config_file_path]
|
||||
@ -77,79 +118,75 @@ def _compile_action(ctx, inputs, outputs, config_file_path):
|
||||
progress_message = "Compiling Angular templates (ngc) %s" % ctx.label,
|
||||
mnemonic = "AngularTemplateCompile",
|
||||
inputs = action_inputs,
|
||||
outputs = non_externs_files,
|
||||
outputs = outputs,
|
||||
arguments = arguments,
|
||||
executable = ctx.executable.compiler,
|
||||
execution_requirements = {
|
||||
"supports-workers": str(int(ctx.attr.supports_workers)),
|
||||
"supports-workers": str(int(ctx.attr._supports_workers)),
|
||||
},
|
||||
)
|
||||
|
||||
def _prodmode_compile_action(ctx, inputs, outputs, config_file_path):
|
||||
outs = _expected_outs(ctx, ctx.label)
|
||||
_compile_action(ctx, inputs, outputs + outs.closure_js, config_file_path)
|
||||
|
||||
def _devmode_compile_action(ctx, inputs, outputs, config_file_path):
|
||||
# TODO(alexeagle): compile for feeding to Closure Compiler
|
||||
_compile_action(ctx, inputs, outputs + _expected_outs(ctx), config_file_path)
|
||||
outs = _expected_outs(ctx, ctx.label)
|
||||
_compile_action(ctx, inputs, outputs + outs.devmode_js + outs.declarations + outs.summaries, config_file_path)
|
||||
|
||||
def _compile_ng(ctx):
|
||||
declarations = []
|
||||
for dep in ctx.attr.deps:
|
||||
if hasattr(dep, "typescript"):
|
||||
declarations += dep.typescript.transitive_declarations
|
||||
def ng_module_impl(ctx, ts_compile_actions):
|
||||
providers = ts_compile_actions(
|
||||
ctx, is_library=True, compile_action=_prodmode_compile_action,
|
||||
devmode_compile_action=_devmode_compile_action,
|
||||
tsc_wrapped_tsconfig=_ngc_tsconfig,
|
||||
outputs = _expected_outs)
|
||||
|
||||
tsconfig_json = ctx.new_file(ctx.label.name + "_tsconfig.json")
|
||||
ctx.file_action(output=tsconfig_json, content=json_marshal(
|
||||
_ngc_tsconfig(ctx, ctx.files.srcs + declarations, ctx.files.srcs)))
|
||||
|
||||
_devmode_compile_action(ctx, ctx.files.srcs + declarations + [tsconfig_json], [], tsconfig_json.path)
|
||||
|
||||
return {
|
||||
"files": depset(_expected_outs(ctx)),
|
||||
"typescript": {
|
||||
# FIXME: expose the right outputs so this looks like a ts_library
|
||||
"declarations": [],
|
||||
"transitive_declarations": [],
|
||||
"type_blacklisted_declarations": [],
|
||||
},
|
||||
#addl_declarations = [_expected_outs(ctx)]
|
||||
#providers["typescript"]["declarations"] += addl_declarations
|
||||
#providers["typescript"]["transitive_declarations"] += addl_declarations
|
||||
providers["angular"] = {
|
||||
"summaries": _expected_outs(ctx, ctx.label).summaries
|
||||
}
|
||||
|
||||
return providers
|
||||
|
||||
def _ng_module_impl(ctx):
|
||||
if ctx.attr.write_ng_outputs_only:
|
||||
ts_providers = _compile_ng(ctx)
|
||||
else:
|
||||
ts_providers = compile_ts(ctx, is_library=True,
|
||||
compile_action=_compile_action,
|
||||
devmode_compile_action=_devmode_compile_action,
|
||||
tsc_wrapped_tsconfig=_ngc_tsconfig)
|
||||
return ts_providers_dict_to_struct(ng_module_impl(ctx, compile_ts))
|
||||
|
||||
addl_declarations = [o for o in _expected_outs(ctx) if o.path.endswith(".d.ts")]
|
||||
ts_providers["typescript"]["declarations"] += addl_declarations
|
||||
ts_providers["typescript"]["transitive_declarations"] += addl_declarations
|
||||
NG_MODULE_ATTRIBUTES = {
|
||||
"srcs": attr.label_list(allow_files = [".ts"]),
|
||||
|
||||
return ts_providers_dict_to_struct(ts_providers)
|
||||
"deps": attr.label_list(aspects = DEPS_ASPECTS + [_collect_summaries_aspect]),
|
||||
|
||||
"assets": attr.label_list(allow_files = [
|
||||
".css",
|
||||
# TODO(alexeagle): change this to ".ng.html" when usages updated
|
||||
".html",
|
||||
]),
|
||||
|
||||
# TODO(alexeagle): wire up when we have i18n in bazel
|
||||
"no_i18n": attr.bool(default = False),
|
||||
|
||||
"compiler": attr.label(
|
||||
default = Label("//src/ngc-wrapped"),
|
||||
executable = True,
|
||||
cfg = "host",
|
||||
),
|
||||
|
||||
# TODO(alexeagle): enable workers for ngc
|
||||
"_supports_workers": attr.bool(default = False),
|
||||
}
|
||||
|
||||
ng_module = rule(
|
||||
implementation = _ng_module_impl,
|
||||
attrs = dict(COMMON_ATTRIBUTES, **{
|
||||
"srcs": attr.label_list(allow_files = True),
|
||||
|
||||
# To be used only to bootstrap @angular/core compilation,
|
||||
# since we want to compile @angular/core with ngc, but ngc depends on
|
||||
# @angular/core typescript output.
|
||||
"write_ng_outputs_only": attr.bool(default = False),
|
||||
attrs = COMMON_ATTRIBUTES + NG_MODULE_ATTRIBUTES + {
|
||||
"tsconfig": attr.label(allow_files = True, single_file = True),
|
||||
"no_i18n": attr.bool(default = False),
|
||||
# TODO(alexeagle): enable workers for ngc
|
||||
"supports_workers": attr.bool(default = False),
|
||||
"compiler": attr.label(
|
||||
default = Label("//internal/ngc"),
|
||||
executable = True,
|
||||
cfg = "host",
|
||||
),
|
||||
|
||||
# @// is special syntax for the "main" repository
|
||||
# The default assumes the user specified a target "node_modules" in their
|
||||
# root BUILD file.
|
||||
"node_modules": attr.label(
|
||||
default = Label("@//:node_modules")
|
||||
),
|
||||
}),
|
||||
},
|
||||
)
|
@ -6,9 +6,14 @@ ts_library(
|
||||
name = "ngc_lib",
|
||||
srcs = ["index.ts"],
|
||||
deps = [
|
||||
# BEGIN-INTERNAL
|
||||
# Only needed when compiling within the Angular repo.
|
||||
# Users will get this dependency from node_modules.
|
||||
"//packages/compiler-cli",
|
||||
# END-INTERNAL
|
||||
"@build_bazel_rules_typescript//internal/tsc_wrapped"
|
||||
],
|
||||
tsconfig = ":tsconfig.json",
|
||||
)
|
||||
|
||||
nodejs_binary(
|
||||
|
@ -5,28 +5,185 @@
|
||||
* 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
|
||||
*/
|
||||
|
||||
// TODO(chuckj): Remove the requirement for a fake 'reflect` implementation from
|
||||
// TODO(chuckj): Remove the requirment for a fake 'reflect` implementation from
|
||||
// the compiler
|
||||
import 'reflect-metadata';
|
||||
import 'reflect-metadata'; // from //third_party/javascript/node_modules/reflect_decorators:ts
|
||||
|
||||
import {calcProjectFileAndBasePath, createNgCompilerOptions, formatDiagnostics, performCompilation} from '@angular/compiler-cli';
|
||||
import * as ng from '@angular/compiler-cli';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
// Note, the tsc_wrapped module comes from rules_typescript, not from @angular/tsc-wrapped
|
||||
import {parseTsconfig} from 'tsc_wrapped';
|
||||
// Note, the tsc_wrapped module comes from rules_typescript, not from npm
|
||||
import {CompilerHost, UncachedFileLoader, parseTsconfig} from 'tsc_wrapped';
|
||||
import * as tsickle from 'tsickle';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
function main(args: string[]) {
|
||||
const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
|
||||
// FIXME: we should be able to add the assets to the tsconfig so FileLoader
|
||||
// knows about them
|
||||
const NGC_NON_TS_INPUTS =
|
||||
/(\.(ngsummary|ngstyle|ngfactory)(\.d)?\.ts|\.ngsummary\.json|\.css|\.html)$/;
|
||||
// FIXME should need only summary, css, html
|
||||
|
||||
function topologicalSort(
|
||||
result: tsickle.FileMap<boolean>, current: string, modulesManifest: tsickle.ModulesManifest,
|
||||
visiting: tsickle.FileMap<boolean>) {
|
||||
const referencedModules = modulesManifest.getReferencedModules(current);
|
||||
if (!referencedModules) return; // not in the local set of sources.
|
||||
for (const referencedModule of referencedModules) {
|
||||
const referencedFileName = modulesManifest.getFileNameFromModule(referencedModule);
|
||||
if (!referencedFileName) continue; // Ambient modules.
|
||||
if (!result[referencedFileName]) {
|
||||
if (visiting[referencedFileName]) {
|
||||
const path = current + ' -> ' + Object.keys(visiting).join(' -> ');
|
||||
throw new Error('Cyclical dependency between files:\n' + path);
|
||||
}
|
||||
visiting[referencedFileName] = true;
|
||||
topologicalSort(result, referencedFileName, modulesManifest, visiting);
|
||||
delete visiting[referencedFileName];
|
||||
}
|
||||
}
|
||||
result[current] = true;
|
||||
}
|
||||
// TODO(alexeagle): move to tsc-wrapped in third_party so it's shared
|
||||
export function constructManifest(
|
||||
modulesManifest: tsickle.ModulesManifest,
|
||||
host: {flattenOutDir: (f: string) => string}): string {
|
||||
const result: tsickle.FileMap<boolean> = {};
|
||||
for (const file of modulesManifest.fileNames) {
|
||||
topologicalSort(result, file, modulesManifest, {});
|
||||
}
|
||||
|
||||
// NB: The object literal maintains insertion order.
|
||||
return Object.keys(result).map(fn => host.flattenOutDir(fn)).join('\n') + '\n';
|
||||
}
|
||||
|
||||
export function main(args) {
|
||||
const project = args[1];
|
||||
const [{options: tsOptions, bazelOpts, files, config}] = parseTsconfig(project);
|
||||
const {basePath} = calcProjectFileAndBasePath(project);
|
||||
const ngOptions = createNgCompilerOptions(basePath, config, tsOptions);
|
||||
|
||||
const {diagnostics} = performCompilation({rootNames: files, options: ngOptions});
|
||||
if (diagnostics.length) {
|
||||
console.error(formatDiagnostics(ngOptions, diagnostics));
|
||||
const {basePath} = ng.calcProjectFileAndBasePath(project);
|
||||
const ngOptions = ng.createNgCompilerOptions(basePath, config, tsOptions);
|
||||
if (!bazelOpts.es5Mode) {
|
||||
ngOptions.annotateForClosureCompiler = true;
|
||||
ngOptions.annotationsAs = 'static fields';
|
||||
}
|
||||
|
||||
function relativeToRootDir(filePath: string): string {
|
||||
if (tsOptions.rootDir) {
|
||||
const rel = path.relative(tsOptions.rootDir, filePath);
|
||||
if (rel.indexOf('.') != 0) return rel;
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
const expectedOuts = [...config['angularCompilerOptions']['expectedOut']];
|
||||
const tsHost = ts.createCompilerHost(tsOptions, true);
|
||||
|
||||
const originalWriteFile = tsHost.writeFile.bind(tsHost);
|
||||
tsHost.writeFile =
|
||||
(fileName: string, content: string, writeByteOrderMark: boolean,
|
||||
onError?: (message: string) => void, sourceFiles?: ts.SourceFile[]) => {
|
||||
const relative = relativeToRootDir(fileName);
|
||||
const expectedIdx = expectedOuts.findIndex(o => o === relative);
|
||||
if (expectedIdx >= 0) {
|
||||
expectedOuts.splice(expectedIdx, 1);
|
||||
originalWriteFile(fileName, content, writeByteOrderMark, onError, sourceFiles);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Patch fileExists when resolving modules, so that ngc can ask TypeScript to
|
||||
// resolve non-existing generated files that don't exist on disk, but are
|
||||
// synthetic and added to the `programWithStubs` based on real inputs.
|
||||
const generatedFileModuleResolverHost = Object.create(tsHost);
|
||||
generatedFileModuleResolverHost.fileExists = (fileName: string) => {
|
||||
const match = /^(.*?)\.(ngfactory|ngsummary|ngstyle|shim\.ngstyle)(.*)$/.exec(fileName);
|
||||
if (match) {
|
||||
const [, file, suffix, ext] = match;
|
||||
// Performance: skip looking for files other than .d.ts or .ts
|
||||
if (ext !== '.ts' && ext !== '.d.ts') return false;
|
||||
if (suffix.indexOf('ngstyle') >= 0) {
|
||||
// Look for foo.css on disk
|
||||
fileName = file;
|
||||
} else {
|
||||
// Look for foo.d.ts or foo.ts on disk
|
||||
fileName = file + (ext || '');
|
||||
}
|
||||
}
|
||||
return tsHost.fileExists(fileName);
|
||||
};
|
||||
|
||||
function generatedFileModuleResolver(
|
||||
moduleName: string, containingFile: string,
|
||||
compilerOptions: ts.CompilerOptions): ts.ResolvedModuleWithFailedLookupLocations {
|
||||
return ts.resolveModuleName(
|
||||
moduleName, containingFile, compilerOptions, generatedFileModuleResolverHost);
|
||||
}
|
||||
|
||||
const bazelHost = new CompilerHost(
|
||||
files, tsOptions, bazelOpts, tsHost, new UncachedFileLoader(), generatedFileModuleResolver);
|
||||
bazelHost.allowNonHermeticRead = (filePath: string) =>
|
||||
NGC_NON_TS_INPUTS.test(filePath) || filePath.split(path.sep).indexOf('node_modules') != -1;
|
||||
bazelHost.shouldSkipTsickleProcessing = (fileName: string): boolean =>
|
||||
bazelOpts.compilationTargetSrc.indexOf(fileName) === -1 && !NGC_NON_TS_INPUTS.test(fileName);
|
||||
|
||||
const ngHost = ng.createCompilerHost({options: ngOptions, tsHost: bazelHost});
|
||||
|
||||
ngHost.fileNameToModuleName = (importedFilePath: string, containingFilePath: string) =>
|
||||
relativeToRootDir(importedFilePath).replace(EXT, '');
|
||||
ngHost.toSummaryFileName = (fileName: string, referringSrcFileName: string) =>
|
||||
ngHost.fileNameToModuleName(fileName, referringSrcFileName);
|
||||
|
||||
const tsickleOpts = {
|
||||
googmodule: bazelOpts.googmodule,
|
||||
es5Mode: bazelOpts.es5Mode,
|
||||
prelude: bazelOpts.prelude,
|
||||
untyped: bazelOpts.untyped,
|
||||
typeBlackListPaths: new Set(bazelOpts.typeBlackListPaths),
|
||||
transformDecorators: bazelOpts.tsickle,
|
||||
transformTypesToClosure: bazelOpts.tsickle,
|
||||
};
|
||||
const emitCallback: ng.TsEmitCallback = ({
|
||||
program,
|
||||
targetSourceFile,
|
||||
writeFile,
|
||||
cancellationToken,
|
||||
emitOnlyDtsFiles,
|
||||
customTransformers = {},
|
||||
}) =>
|
||||
tsickle.emitWithTsickle(
|
||||
program, bazelHost, tsickleOpts, bazelHost, ngOptions, targetSourceFile, writeFile,
|
||||
cancellationToken, emitOnlyDtsFiles, {
|
||||
beforeTs: customTransformers.before,
|
||||
afterTs: customTransformers.after,
|
||||
});
|
||||
|
||||
const {diagnostics, emitResult} =
|
||||
ng.performCompilation({rootNames: files, options: ngOptions, host: ngHost, emitCallback});
|
||||
const tsickleEmitResult = emitResult as tsickle.EmitResult;
|
||||
let externs = '/** @externs */\n';
|
||||
if (diagnostics.length) {
|
||||
console.error(ng.formatDiagnostics(ngOptions, diagnostics));
|
||||
} else {
|
||||
if (bazelOpts.tsickleGenerateExterns) {
|
||||
externs += tsickle.getGeneratedExterns(tsickleEmitResult.externs);
|
||||
}
|
||||
if (bazelOpts.manifest) {
|
||||
const manifest = constructManifest(tsickleEmitResult.modulesManifest, bazelHost);
|
||||
fs.writeFileSync(bazelOpts.manifest, manifest);
|
||||
}
|
||||
}
|
||||
|
||||
if (bazelOpts.tsickleExternsPath) {
|
||||
// Note: when tsickleExternsPath is provided, we always write a file as a
|
||||
// marker that compilation succeeded, even if it's empty (just containing an
|
||||
// @externs).
|
||||
fs.writeFileSync(bazelOpts.tsickleExternsPath, externs);
|
||||
}
|
||||
|
||||
for (const missing of expectedOuts) {
|
||||
originalWriteFile(missing, '', false);
|
||||
}
|
||||
|
||||
return diagnostics.some(d => d.category === ts.DiagnosticCategory.Error) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
5
packages/bazel/src/ngc-wrapped/tsconfig.json
Normal file
5
packages/bazel/src/ngc-wrapped/tsconfig.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es5", "es2015.collection", "es2015.core"]
|
||||
}
|
||||
}
|
9
packages/bazel/src/rules_typescript.bzl
Normal file
9
packages/bazel/src/rules_typescript.bzl
Normal file
@ -0,0 +1,9 @@
|
||||
# Allows different paths for these imports in google3
|
||||
load("@build_bazel_rules_typescript//internal:build_defs.bzl", "tsc_wrapped_tsconfig")
|
||||
|
||||
load(
|
||||
"@build_bazel_rules_typescript//internal:common/compilation.bzl",
|
||||
"COMMON_ATTRIBUTES", "compile_ts", "DEPS_ASPECTS", "ts_providers_dict_to_struct"
|
||||
)
|
||||
|
||||
load("@build_bazel_rules_typescript//internal:common/json_marshal.bzl", "json_marshal")
|
Reference in New Issue
Block a user