提交 0d20abe5 编写于 作者: fxy060608's avatar fxy060608

wip(x-android): tsc

上级 b8ac8570
......@@ -78,7 +78,7 @@ export function uniAppPlugin(): UniVitePlugin {
}
emptyTscDir()
let watcher: WatchProgramHelper
let watcher: WatchProgramHelper | undefined
return {
name: 'uni:app-uts',
......@@ -206,17 +206,24 @@ export function uniAppPlugin(): UniVitePlugin {
} else {
process.env.UNI_APP_X_UNICLOUD_OBJECT = 'false'
}
const { compileApp, runUTS2KotlinDev } = resolveUTSCompiler()
const { compileApp, runUTS2Kotlin } = resolveUTSCompiler()
if (process.env.UNI_APP_X_TSC === 'true') {
if (!watcher) {
watcher = runUTS2KotlinDev({
inputDir: tscOutputDir,
cacheDir: path.resolve(process.env.UNI_APP_X_CACHE_DIR, 'tsc'),
outputDir: uvueOutputDir,
normalizeFileName: normalizeNodeModules,
}).watcher
watcher = runUTS2Kotlin(
process.env.NODE_ENV === 'development'
? 'development'
: 'production',
{
inputDir: tscOutputDir,
cacheDir: path.resolve(process.env.UNI_APP_X_CACHE_DIR, 'tsc'),
outputDir: uvueOutputDir,
normalizeFileName: normalizeNodeModules,
}
).watcher
}
if (watcher) {
await watcher.wait()
}
await watcher.wait()
}
const res = await compileApp(path.join(uvueOutputDir, 'main.uts'), {
pageCount,
......
import type { CompilerOptions, EmitResult } from 'typescript'
export { uts2js } from './javascript'
export { runUTS2KotlinDev } from './kotlin'
export { runUTS2Kotlin } from './kotlin'
export interface UTSEmitDeclarationOptions {
typescript?: typeof import('typescript')
......
......@@ -4,7 +4,6 @@ import { extend } from '@vue/shared'
import type {
CompilerOptions,
SemanticDiagnosticsBuilderProgram,
WatchOfFilesAndCompilerOptions,
} from 'typescript'
import {
type RawSourceMap,
......@@ -29,9 +28,11 @@ export declare class WatchProgramHelper {
watch(timeout?: number): void
wait(): Promise<void>
}
export function runUTS2KotlinDev(options: UTS2KotlinOptions): {
program: WatchOfFilesAndCompilerOptions<SemanticDiagnosticsBuilderProgram>
watcher: WatchProgramHelper
export function runUTS2Kotlin(
mode: 'development' | 'production',
options: UTS2KotlinOptions
): {
watcher?: WatchProgramHelper
} {
const { /* check, noCache, */ tsconfig, typescript, tsconfigOverride } =
createBasicUtsOptions(options.inputDir)
......@@ -83,7 +84,7 @@ export function runUTS2KotlinDev(options: UTS2KotlinOptions): {
}
>
return require('../../../lib/kotlin').runDev({
return require('../../../lib/kotlin').compile(mode, {
typescript,
inputDir: options.inputDir,
cacheDir: options.cacheDir,
......
{
"extends": "../../tsconfig.node.json",
"compilerOptions": {
"outDir": "dist"
"outDir": "dist",
"resolveJsonModule": true
},
"include": ["src", "../shims-node.d.ts", "../shims-uni-app.d.ts"]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册