How to use the @bazel/typescript.CompilerHost 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
// 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);
  }

  if (!bazelHost) {
    bazelHost = new CompilerHost(
        files, compilerOpts, bazelOpts, tsHost, fileLoader, generatedFileModuleResolver);
  }

  // Also need to disable decorator downleveling in the BazelHost in Ivy mode.
  if (isInIvyMode) {
    bazelHost.transformDecorators = false;
  }

  // Prevent tsickle adding any types at all if we don't want closure compiler annotations.
  if (compilerOpts.annotateForClosureCompiler) {
    bazelHost.transformTypesToClosure = true;
    bazelHost.transformDecorators = true;
  }
  const origBazelHostFileExist = bazelHost.fileExists;
  bazelHost.fileExists = (fileName: string) => {
    if (NGC_ASSETS.test(fileName)) {
github marcus-sa / svelte-ts / packages / bazel / internal / svelte-bazel-compiler.ts View on Github external
);
    }

    const options = config['svelteCompilerOptions'] as SvelteCompilerOptions;

    options.expectedOuts = options.expectedOuts.map(p => p.replace(/\\/g, '/'));
    // TODO
    options.suppressWarnings = options.suppressWarnings || [];
    options.dev = bazelOpts.es5Mode;
    options.immutable = bazelOpts.es5Mode;
    this.options = options;

    this.tsHost = ts.createCompilerHost(this.compilerOpts, true);
    this.fileLoader = createFileLoader(this.fileCache, inputs);

    this.bazelHost = new CompilerHost(
      this.files,
      this.compilerOpts,
      this.bazelOpts,
      this.tsHost,
      this.fileLoader,
    );

    this.bazelHost.transformTypesToClosure = Boolean(
      this.compilerOpts.annotateForClosureCompiler,
    );
  }