Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@angular/bazel

Package Overview
Dependencies
Maintainers
1
Versions
566
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@angular/bazel - npm Package Compare versions

Comparing version 5.0.0-rc.2 to 5.0.0-rc.3

test/ngc-wrapped/BUILD.bazel

6

package.json
{
"name": "@angular/bazel",
"version": "5.0.0-rc.2",
"version": "5.0.0-rc.3",
"description": "Angular - bazel build rules",

@@ -8,4 +8,4 @@ "author": "angular",

"peerDependencies": {
"@angular/compiler-cli": "5.0.0-rc.2",
"typescript": "^2.4.2"
"@angular/compiler-cli": "5.0.0-rc.3",
"typescript": ">=2.4.2 <2.5"
},

@@ -12,0 +12,0 @@ "dependencies": {

@@ -14,4 +14,4 @@ /**

const args = process.argv.slice(2);
console.error('>>> not yet implemented!');
console.error('>>> now yet implemented!');
process.exitCode = 1;
}

@@ -11,3 +11,3 @@ /**

import * as ng from '@angular/compiler-cli';
import {BazelOptions, CachedFileLoader, CompilerHost, FileCache, FileLoader, UncachedFileLoader, constructManifest, debug, parseTsconfig, runAsWorker, runWorkerLoop} from '@bazel/typescript';
import {BazelOptions, CachedFileLoader, CompilerHost, FileCache, FileLoader, UncachedFileLoader, constructManifest, debug, fixUmdModuleDeclarations, parseTsconfig, runAsWorker, runWorkerLoop} from '@bazel/typescript';
import * as fs from 'fs';

@@ -18,4 +18,2 @@ import * as path from 'path';

import {emitWithCache, getCachedGeneratedFile} from './emit_cache';
const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;

@@ -47,3 +45,3 @@ const NGC_GEN_FILES = /^(.*?)\.(ngfactory|ngsummary|ngstyle|shim\.ngstyle)(.*)$/;

function runOneBuild(args: string[], inputs?: {[path: string]: string}): boolean {
export function runOneBuild(args: string[], inputs?: {[path: string]: string}): boolean {
if (args[0] === '-p') args.shift();

@@ -82,4 +80,3 @@ // Strip leading at-signs, used to indicate a params file

export function compile({allowNonHermeticReads, allDepsCompiledWithBazel = true, compilerOpts,
tsHost, bazelOpts, files, inputs, expectedOuts,
gatherDiagnostics = defaultGatherDiagnostics}: {
tsHost, bazelOpts, files, inputs, expectedOuts, gatherDiagnostics}: {
allowNonHermeticReads: boolean,

@@ -91,8 +88,5 @@ allDepsCompiledWithBazel?: boolean,

files: string[],
expectedOuts: string[],
gatherDiagnostics?: (program: ng.Program, inputsToCheck: ts.SourceFile[],
genFilesToCheck: ng.GeneratedFile[]) => ng.Diagnostics
expectedOuts: string[], gatherDiagnostics?: (program: ng.Program) => ng.Diagnostics
}): {diagnostics: ng.Diagnostics, program: ng.Program} {
let fileLoader: FileLoader;
const oldFiles = new Map<string, ts.SourceFile>();

@@ -104,8 +98,3 @@ if (inputs) {

for (const key of Object.keys(inputs)) {
const resolvedKey = path.resolve(key);
resolvedInputs[resolvedKey] = inputs[key];
const cachedSf = fileCache.getCache(resolvedKey);
if (cachedSf) {
oldFiles.set(resolvedKey, cachedSf);
}
resolvedInputs[path.resolve(key)] = inputs[key];
}

@@ -198,52 +187,36 @@ fileCache.updateCache(resolvedInputs);

const oldProgram = {
getSourceFile: (fileName: string) => { return oldFiles.get(fileName); },
getGeneratedFile: (srcFileName: string, genFileName: string) => {
const sf = oldFiles.get(srcFileName);
return sf ? getCachedGeneratedFile(sf, genFileName) : undefined;
},
};
const program =
ng.createProgram({rootNames: files, host: ngHost, options: compilerOpts, oldProgram});
let inputsChanged = files.some(fileName => program.hasChanged(fileName));
const emitCallback: ng.TsEmitCallback = ({
program,
targetSourceFile,
writeFile,
cancellationToken,
emitOnlyDtsFiles,
customTransformers = {},
}) =>
tsickle.emitWithTsickle(
program, bazelHost, bazelHost, compilerOpts, targetSourceFile, writeFile,
cancellationToken, emitOnlyDtsFiles, {
beforeTs: customTransformers.before,
afterTs: [
...(customTransformers.after || []),
fixUmdModuleDeclarations((sf: ts.SourceFile) => bazelHost.amdModuleName(sf)),
],
});
let genFilesToCheck: ng.GeneratedFile[];
let inputsToCheck: ts.SourceFile[];
if (inputsChanged) {
// if an input file changed, we need to type check all
// of our compilation sources as well as all generated files.
inputsToCheck = bazelOpts.compilationTargetSrc.map(
fileName => program.getTsProgram().getSourceFile(fileName));
genFilesToCheck = program.getGeneratedFiles().filter(gf => gf.genFileName.endsWith('.ts'));
} else {
// if no input file changed, only type check the changed generated files
// as these don't influence each other nor the type check of the input files.
inputsToCheck = [];
genFilesToCheck = program.getGeneratedFiles().filter(
gf => program.hasChanged(gf.genFileName) && gf.genFileName.endsWith('.ts'));
if (!gatherDiagnostics) {
gatherDiagnostics = (program) =>
gatherDiagnosticsForInputsOnly(compilerOpts, bazelOpts, program);
}
debug(
`TypeChecking ${inputsToCheck ? inputsToCheck.length : 'all'} inputs and ${genFilesToCheck ? genFilesToCheck.length : 'all'} generated files`);
const diagnostics = [...gatherDiagnostics(program !, inputsToCheck, genFilesToCheck)];
let emitResult: tsickle.EmitResult|undefined;
if (!diagnostics.length) {
const targetFileNames = [...bazelOpts.compilationTargetSrc];
for (const genFile of program.getGeneratedFiles()) {
if (genFile.genFileName.endsWith('.ts')) {
targetFileNames.push(genFile.genFileName);
}
}
emitResult = emitWithCache(program, inputsChanged, targetFileNames, compilerOpts, bazelHost);
diagnostics.push(...emitResult.diagnostics);
}
const {diagnostics, emitResult, program} = ng.performCompilation(
{rootNames: files, options: compilerOpts, host: ngHost, emitCallback, gatherDiagnostics});
const tsickleEmitResult = emitResult as tsickle.EmitResult;
let externs = '/** @externs */\n';
if (diagnostics.length) {
console.error(ng.formatDiagnostics(compilerOpts, diagnostics));
} else if (emitResult) {
console.error(ng.formatDiagnostics(diagnostics));
} else {
if (bazelOpts.tsickleGenerateExterns) {
externs += tsickle.getGeneratedExterns(emitResult.externs);
externs += tsickle.getGeneratedExterns(tsickleEmitResult.externs);
}
if (bazelOpts.manifest) {
const manifest = constructManifest(emitResult.modulesManifest, bazelHost);
const manifest = constructManifest(tsickleEmitResult.modulesManifest, bazelHost);
fs.writeFileSync(bazelOpts.manifest, manifest);

@@ -267,5 +240,10 @@ }

function defaultGatherDiagnostics(
ngProgram: ng.Program, inputsToCheck: ts.SourceFile[],
genFilesToCheck: ng.GeneratedFile[]): (ng.Diagnostic | ts.Diagnostic)[] {
function isCompilationTarget(bazelOpts: BazelOptions, sf: ts.SourceFile): boolean {
return !NGC_GEN_FILES.test(sf.fileName) &&
(bazelOpts.compilationTargetSrc.indexOf(sf.fileName) !== -1);
}
function gatherDiagnosticsForInputsOnly(
options: ng.CompilerOptions, bazelOpts: BazelOptions,
ngProgram: ng.Program): (ng.Diagnostic | ts.Diagnostic)[] {
const tsProgram = ngProgram.getTsProgram();

@@ -278,3 +256,3 @@ const diagnostics: (ng.Diagnostic | ts.Diagnostic)[] = [];

diagnostics.push(...tsProgram.getGlobalDiagnostics());
for (const sf of inputsToCheck) {
for (const sf of tsProgram.getSourceFiles().filter(f => isCompilationTarget(bazelOpts, f))) {
// Note: We only get the diagnostics for individual files

@@ -289,5 +267,3 @@ // to e.g. not check libraries.

diagnostics.push(...ngProgram.getNgStructuralDiagnostics());
for (const genFile of genFilesToCheck) {
diagnostics.push(...ngProgram.getNgSemanticDiagnostics(genFile));
}
diagnostics.push(...ngProgram.getNgSemanticDiagnostics());
}

@@ -294,0 +270,0 @@ return diagnostics;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc