CompileOptions
인터페이스, 작성 분류
How one compile() call is set up.
import type { CompileOptions } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
interface CompileOptions { readonly fileName?: string; readonly consoleSink?: ConsoleSink; readonly deprecations?: boolean; readonly console?: 'cpu' | 'gpu'; readonly readDocument?: (fileName: string) => string | undefined; readonly resolveImport?: (fromFile: string, specifier: string) => string | undefined;}설명
Every field is optional, and the defaults are what
compile(source) did before this interface existed.
인스턴스 속성
fileName선택 사항읽기 전용stringThe name this source is compiled under. It is the
fileof everySourceSpanthe front end stamps on the IR, and thefileNameof every diagnostic, so it is how a consumer that holds a span says which of the author’s files a statement came from.That default is fine for a compile whose output is shader text, since nothing reads the name, but not for one whose output is stepped: a
DebugBreakpointcarries the path the editor knows the file by, and matches it againstspan.file, so a session compiled under the placeholder silently arms no breakpoint at all. An adapter that has a path should pass it.Nothing resolves or reads it: it is a label carried to the spans, not a path the compiler opens. An adapter does not have to care: a
DebugBreakpoint’s path is normalized the same way before it is compared, so either spelling matches.consoleSink선택 사항읽기 전용ConsoleSinkHost sink for
console.*calls made by CPU/debug evaluation.deprecations선택 사항읽기 전용booleanReport deprecation warnings for spellings whose meaning is scheduled to change. One today: an integer-written literal in a declaration with no annotation or declared integer use still types as
f32and will type asi32(§13).Off by default, and off is the whole of the compiler’s behaviour: the flag adds
category: 'warning'diagnostics and moves no emitted byte, sowgslandglslare byte-identical with it on and with it off. It is how a build finds the lines the flip will move, one release ahead of it.console선택 사항읽기 전용'cpu' | 'gpu'Where a
consolecall is recorded.'cpu', the default, is whatcompile()always did: the CPU run delivers each call toCompileOptions.consoleSink, and the WGSL and GLSL record nothing, so no emitted byte depends on a console call.'gpu'makes the WGSL also record each call a compute or fragment entry reaches, in a_consolestorage buffer the compiler binds at group 0 past the module’s own bindings;CompileResult.consolesays where, anddecodeConsoleturns the buffer the host copies back into the same events. A call the WGSL cannot record is aTS8071warning. GLSL ES 3.00 records nothing either way. Surface §66, Rule 11.9.readDocument선택 사항읽기 전용(fileName: string) => string | undefinedReads a file this source imports (Rule 3.9, surface §68): its text, or
undefinedwhen there is none. The source and every shader file it imports, directly or through another, are one program, compiled into one module, and a diagnostic located in an imported file carries that file’s name and offsets. It is asked for a package’spackage.jsontoo, which the defaultresolveImportreads to find a package innode_modules, so areadDocumentthat reads from disk follows a package with no change. Without it nothing is read: a source with no import compiles as it always has, and an import isTS8072. The same hook as the language service’sTypeshadeLanguageServiceHost.readDocument, so both halves read one program.resolveImport선택 사항읽기 전용(fromFile: string, specifier: string) => string | undefinedThe file a specifier written in
fromFilenames, orundefinedwhen it names none. The default, which the language service applies too, resolves a relative specifier against the importing file (fileNamefor the source), reads.jsand.mjsas.ts, and appends.tsto any other path. Any other specifier names a package: the firstnode_modules/<name>/package.jsonfrom the importing file’s directory up, read throughreadDocument, and the file itsexportspublishes under thetypeshadecondition (surface §68, change 0024). A hook passed here replaces the rule for every specifier.
함께 보기
소스
src/compiler/ts/compile.ts, 88행, 커밋 c66579bf 기준