How to use the @parcel/ts-utils.CompilerHost function in @parcel/ts-utils

To help you get started, we’ve selected a few @parcel/ts-utils 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 parcel-bundler / parcel / packages / transformers / typescript-types / src / TSTypesTransformer.js View on Github external
);

    let opts: CompilerOptions = {
      ...config,
      // Always emit output
      noEmit: false,
      noEmitOnError: false,
      declaration: true,
      declarationMap: true,
      isolatedModules: false,
      emitDeclarationOnly: true,
      outFile: 'index.d.ts',
      moduleResolution: ts.ModuleResolutionKind.NodeJs,
    };

    let host = new CompilerHost(options.inputFS, ts);
    // $FlowFixMe
    let program = ts.createProgram([asset.filePath], opts, host);

    let includedFiles = program
      .getSourceFiles()
      .filter(file => path.normalize(file.fileName) !== asset.filePath)
      .map(file => ({filePath: file.fileName}));

    let mainModuleName = path
      .relative(program.getCommonSourceDirectory(), asset.filePath)
      .slice(0, -path.extname(asset.filePath).length);
    let moduleGraph = new TSModuleGraph(ts, mainModuleName);

    program.emit(undefined, undefined, undefined, true, {
      afterDeclarations: [
        // 1. Build module graph

@parcel/ts-utils

MIT
Latest version published 8 months ago

Package Health Score

85 / 100
Full package analysis

Similar packages