Created
September 18, 2022 02:40
-
-
Save nitedani/b13584a4596ddc4b735b91ac1b2f0b39 to your computer and use it in GitHub Desktop.
Compile angular components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgtscProgram, readConfiguration } from '@angular/compiler-cli'; | |
import { dirname, resolve } from 'path'; | |
import ts from 'typescript'; | |
import { fileURLToPath } from 'url'; | |
const __dirname = dirname(fileURLToPath(import.meta.url)); | |
const { options, rootNames } = readConfiguration( | |
resolve(__dirname, '..', 'tsconfig.angular.json') | |
); | |
const host = ts.createIncrementalCompilerHost(options); | |
const program = new NgtscProgram(rootNames, options, host); | |
const ngtsc = program.getTsProgram(); | |
const transformers = program.compiler.prepareEmit().transformers; | |
for (const r of rootNames) { | |
const file = ngtsc.getSourceFile(r); | |
ngtsc.emit(file, undefined, undefined, undefined, transformers); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment