How to use the @bazel/typescript.FileCache function in @bazel/typescript

To help you get started, we’ve selected a few @bazel/typescript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / angular / packages / bazel / src / ngc-wrapped / index.ts View on Github external
// Note: We compile the content of node_modules with plain ngc command line.
const ALL_DEPS_COMPILED_WITH_BAZEL = false;

const NODE_MODULES = 'node_modules/';

export function main(args) {
  if (runAsWorker(args)) {
    runWorkerLoop(runOneBuild);
  } else {
    return runOneBuild(args) ? 0 : 1;
  }
  return 0;
}

/** The one FileCache instance used in this process. */
const fileCache = new FileCache(debug);

export function runOneBuild(args: string[], inputs?: {[path: string]: string}): boolean {
  if (args[0] === '-p') args.shift();
  // Strip leading at-signs, used to indicate a params file
  const project = args[0].replace(/^@+/, '');

  const [parsedOptions, errors] = parseTsconfig(project);
  if (errors && errors.length) {
    console.error(ng.formatDiagnostics(errors));
    return false;
  }
  const {options: tsOptions, bazelOpts, files, config} = parsedOptions;
  const angularCompilerOptions: {[k: string]: unknown} = config['angularCompilerOptions'] || {};

  // Allow Bazel users to control some of the bazel options.
  // Since TypeScript's "extends" mechanism applies only to "compilerOptions"
github marcus-sa / svelte-ts / packages / bazel / internal / svelte-bazel-compiler.ts View on Github external
} from './ts-ast-helpers';

export const defaultCompilerOptions: ts.CompilerOptions = {
  target: ts.ScriptTarget.ESNext,
  module: ts.ModuleKind.ES2015,
  moduleResolution: ts.ModuleResolutionKind.NodeJs,
  alwaysStrict: false,
  inlineSourceMap: false,
  sourceMap: true,
  allowNonTsExtensions: true,
};

export class SvelteBazelCompiler {
  /** The one FileCache instance used in this process. */
  private readonly svelteCompilationCache: SvelteCompilationCache = new Map();
  private readonly fileCache = new FileCache(debug);
  private readonly compilerOpts: ts.CompilerOptions;
  private readonly bazelOpts: BazelOptions;
  private readonly options: SvelteCompilerOptions;
  private readonly tsHost: ts.CompilerHost;
  private readonly fileLoader: FileLoader;
  private readonly bazelHost: CompilerHost;
  private readonly files: string[];
  private readonly bazelBin: string;
  private originalWriteFile: ts.CompilerHost['writeFile'];
  private originalGetSourceFile: CompilerHost['getSourceFile'];
  private program: ts.Program;

  constructor(args: string[], inputs?: Record) {
    if (args[0] === '-p') args.shift();
    // Strip leading at-signs, used to indicate a params file
    const project = args[0].replace(/^@+/, '');