How to use the tsickle.emit function in tsickle

To help you get started, we’ve selected a few tsickle 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 / tsickle / demo / demo.ts View on Github external
untyped: false,
    logWarning: (warning) => console.error(ts.formatDiagnostics([warning], compilerHost)),
    options,
    moduleResolutionHost: compilerHost,
  };
  const diagnostics = ts.getPreEmitDiagnostics(program);
  if (diagnostics.length > 0) {
    return {
      diagnostics,
      modulesManifest: new tsickle.ModulesManifest(),
      externs: {},
      emitSkipped: true,
      emittedFiles: [],
    };
  }
  return tsickle.emit(program, transformerHost, writeFile);
}
github marcus-sa / svelte-ts / packages / bazel / internal / svelte-bazel-compiler.ts View on Github external
this.overrideBazelHost();

    if (typeof this.bazelOpts.maxCacheSizeMb === 'number') {
      const maxCacheSizeBytes = this.bazelOpts.maxCacheSizeMb * (1 << 20);
      this.fileCache.setMaxCacheSize(maxCacheSizeBytes);
    } else {
      this.fileCache.resetMaxCacheSize();
    }

    this.program = ts.createProgram({
      rootNames: this.files,
      options: this.compilerOpts,
      host: this.bazelHost,
    });

    const emitResult = tsickle.emit(
      this.program,
      this.bazelHost,
      this.bazelHost.writeFile,
    );

    const allDiagnostics = this.gatherDiagnosticsForInputsOnly();
    allDiagnostics.push(...emitResult.diagnostics);

    let externs = '/** @externs */\n';
    if (!emitResult.diagnostics.length) {
      if (this.bazelOpts.tsickleGenerateExterns) {
        externs += tsickle.getGeneratedExterns(emitResult.externs);
      }
      if (this.bazelOpts.manifest) {
        const manifest = constructManifest(
          emitResult.modulesManifest,