How to use the tsickle.emitWithTsickle 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 / angular / packages / tsc-wrapped / src / main.ts View on Github external
// Add the generated files to the configuration so they will become part of the program.
      if (ngOptions.alwaysCompileGeneratedCode) {
        genFiles.forEach(genFileName => addGeneratedFileName(genFileName));
      }
      if (!ngOptions.skipMetadataEmit) {
        host = new MetadataWriterHost(host, ngOptions, true);
      }

      // Create a new program since codegen files were created after making the old program
      let programWithCodegen = createProgram(host, program);
      tsc.typeCheck(host, programWithCodegen);

      if (diagnostics) console.time('Emit');
      const {diagnostics: emitDiags} =
          tsickle.emitWithTsickle(programWithCodegen, tsickleHost, host, ngOptions);
      if (diagnostics) console.timeEnd('Emit');
      check(emitDiags);

      if (diagnostics) {
        (ts as any).performance.forEachMeasure(
            (name: string, duration: number) => { console.error(`TS ${name}: ${duration}ms`); });
      }
    });
  } catch (e) {
github johandb / svg-drawing-tool / node_modules / @angular / compiler-cli / src / main.js View on Github external
return function (_a) {
                var program = _a.program, targetSourceFile = _a.targetSourceFile, writeFile = _a.writeFile, cancellationToken = _a.cancellationToken, emitOnlyDtsFiles = _a.emitOnlyDtsFiles, _b = _a.customTransformers, customTransformers = _b === void 0 ? {} : _b, host = _a.host, options = _a.options;
                // tslint:disable-next-line:no-require-imports only depend on tsickle if requested
                return require('tsickle').emitWithTsickle(program, tslib_1.__assign({}, tsickleHost, { options: options, host: host }), host, options, targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, {
                    beforeTs: customTransformers.before,
                    afterTs: customTransformers.after,
                });
            };
        }
github ampproject / amphtml / build-system / compile / typescript.js View on Github external
fileName = fileName.replace(/\.js$/, '');
    if (fileName[0] === '.') {
      // './foo' or '../foo'.
      // Resolve the path against the dirname of the current module.
      fileName = path.join(path.dirname(context), fileName);
    }
    return fileName;
  };
  const transformerHost = {
    host: compilerHost,
    options: tsOptions,
    pathToModuleName,
    shouldSkipTsickleProcessing: () => false,
    transformTypesToClosure: true,
  };
  return tsickle
    .emitWithTsickle(
      program,
      transformerHost,
      compilerHost,
      tsOptions,
      undefined,
      (filePath, contents) => {
        fs.writeFileSync(filePath, contents, {encoding: 'utf-8'});
      }
    )
    .then(emitResult => {
      const diagnostics = ts
        .getPreEmitDiagnostics(program)
        .concat(emitResult.diagnostics);
      if (diagnostics.length) {
        log(colors.red('TSickle:'), tsickle.formatDiagnostics(diagnostics));
github angular / angular / packages / compiler-cli / src / main.ts View on Github external
return ({
             program,
             targetSourceFile,
             writeFile,
             cancellationToken,
             emitOnlyDtsFiles,
             customTransformers = {},
             host,
             options
           }) =>
               // tslint:disable-next-line:no-require-imports only depend on tsickle if requested
        require('tsickle').emitWithTsickle(
            program, {...tsickleHost, options, host, moduleResolutionHost: host}, host, options,
            targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, {
              beforeTs: customTransformers.before,
              afterTs: customTransformers.after,
            });
  } else {
github ng-packagr / ng-packagr / src / lib / ngc / create-emit-callback.ts View on Github external
return ({
      program,
      targetSourceFile,
      writeFile,
      cancellationToken,
      emitOnlyDtsFiles,
      customTransformers = {},
      host,
      options,
    }) =>
      // tslint:disable-next-line:no-require-imports only depend on tsickle if requested
      require('tsickle').emitWithTsickle(
        program,
        { ...tsickleHost, options, host, moduleResolutionHost: host },
        host,
        options,
        targetSourceFile,
        writeFile,
        cancellationToken,
        emitOnlyDtsFiles,
        {
          beforeTs: customTransformers.before,
          afterTs: customTransformers.after,
        },
      );
  }
github angular / angular / packages / bazel / src / ngc-wrapped / index.ts View on Github external
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,
            afterDeclarations: customTransformers.afterDeclarations,
          });
github daviddbarrero / Ionic-4-firebase / node_modules / @angular / compiler-cli / src / main.js View on Github external
return function (_a) {
        var program = _a.program, targetSourceFile = _a.targetSourceFile, writeFile = _a.writeFile, cancellationToken = _a.cancellationToken, emitOnlyDtsFiles = _a.emitOnlyDtsFiles, _b = _a.customTransformers, customTransformers = _b === void 0 ? {} : _b, host = _a.host, options = _a.options;
        return tsickle.emitWithTsickle(program, tsickleHost, host, options, targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, {
            beforeTs: customTransformers.before,
            afterTs: customTransformers.after,
        });
    };
}
github shlomiassaf / ngc-webpack / src / cli / util.ts View on Github external
return ({
            program,
            targetSourceFile,
            writeFile,
            cancellationToken,
            emitOnlyDtsFiles,
            customTransformers = {},
            host,
            options
          }) =>
    tsickle.emitWithTsickle(
      program,
      tsickleHost,
      host,
      options,
      targetSourceFile,
      writeFile,
      cancellationToken,
      emitOnlyDtsFiles,
      {
        beforeTs: customTransformers.before,
        afterTs: customTransformers.after,
      }
    );
}
github angular / angular / packages / compiler-cli / src / main.ts View on Github external
return ({
           program,
           targetSourceFile,
           writeFile,
           cancellationToken,
           emitOnlyDtsFiles,
           customTransformers = {},
           host,
           options
         }) =>
             tsickle.emitWithTsickle(
                 program, tsickleHost, tsickleOptions, host, options, targetSourceFile, writeFile,
                 cancellationToken, emitOnlyDtsFiles, {
                   beforeTs: customTransformers.before,
                   afterTs: customTransformers.after,
                 });
}