Skip to content

Commit

Permalink
wip(x-android): tsc
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Jul 8, 2024
1 parent b4eab5e commit e9ded9d
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 34 deletions.
3 changes: 2 additions & 1 deletion packages/uni-app-uts/src/plugins/android/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export function uniAppPlugin(): UniVitePlugin {
},
watchChange() {
if (process.env.UNI_APP_X_TSC === 'true') {
watcher && watcher.watch()
watcher && watcher.watch(3000)
}
},
async writeBundle() {
Expand Down Expand Up @@ -211,6 +211,7 @@ export function uniAppPlugin(): UniVitePlugin {
if (!watcher) {
watcher = runUTS2KotlinDev({
inputDir: tscOutputDir,
cacheDir: path.resolve(process.env.UNI_APP_X_CACHE_DIR, 'tsc'),
outputDir: uvueOutputDir,
normalizeFileName: normalizeNodeModules,
}).watcher
Expand Down
2 changes: 1 addition & 1 deletion packages/uni-uts-v1/lib/kotlin/dist/index.js

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions packages/uni-uts-v1/lib/typescript/lib/tsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -115288,7 +115288,10 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
sourceMaps: sourceMapDataList
};
function emitSourceFileOrBundle({ jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath }, sourceFileOrBundle) {
var _a, _b, _c, _d, _e, _f;
var _a, _b, _c, _d, _e, _f, _g;
if ((_a = host.beforeEmitSourceFileOrBundle) == null ? void 0 : _a.call(host, sourceFileOrBundle)) {
return;
}
let buildInfoDirectory;
if (buildInfoPath && sourceFileOrBundle && isBundle(sourceFileOrBundle)) {
buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
Expand All @@ -115297,15 +115300,15 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
sourceFiles: sourceFileOrBundle.sourceFiles.map((file) => relativeToBuildInfo(getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())))
};
}
(_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
(_b = tracing) == null ? void 0 : _b.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
(_b = tracing) == null ? void 0 : _b.pop();
(_c = tracing) == null ? void 0 : _c.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
(_c = tracing) == null ? void 0 : _c.pop();
(_d = tracing) == null ? void 0 : _d.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
(_d = tracing) == null ? void 0 : _d.pop();
(_e = tracing) == null ? void 0 : _e.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
(_e = tracing) == null ? void 0 : _e.pop();
(_f = tracing) == null ? void 0 : _f.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
emitBuildInfo(bundleBuildInfo, buildInfoPath);
(_f = tracing) == null ? void 0 : _f.pop();
(_g = tracing) == null ? void 0 : _g.pop();
if (!emitSkipped && emittedFilesList) {
if (!emitOnly) {
if (jsFilePath) {
Expand Down Expand Up @@ -122736,7 +122739,12 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
getSourceFileFromReference: (file, ref) => program.getSourceFileFromReference(file, ref),
redirectTargetsMap,
getFileIncludeReasons: program.getFileIncludeReasons,
createHash: maybeBind(host, host.createHash)
createHash: maybeBind(host, host.createHash),
// @ts-expect-error fixed by uts
beforeEmitSourceFileOrBundle: (sourceFileOrBundle) => {
var _a2;
return (_a2 = program.beforeEmitSourceFileOrBundle) == null ? void 0 : _a2.call(program, sourceFileOrBundle);
}
};
}
function writeFile2(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
Expand Down
24 changes: 16 additions & 8 deletions packages/uni-uts-v1/lib/typescript/lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -117599,7 +117599,10 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
sourceMaps: sourceMapDataList
};
function emitSourceFileOrBundle({ jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath }, sourceFileOrBundle) {
var _a, _b, _c, _d, _e, _f;
var _a, _b, _c, _d, _e, _f, _g;
if ((_a = host.beforeEmitSourceFileOrBundle) == null ? void 0 : _a.call(host, sourceFileOrBundle)) {
return;
}
let buildInfoDirectory;
if (buildInfoPath && sourceFileOrBundle && isBundle(sourceFileOrBundle)) {
buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
Expand All @@ -117608,15 +117611,15 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
sourceFiles: sourceFileOrBundle.sourceFiles.map((file) => relativeToBuildInfo(getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())))
};
}
(_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
(_b = tracing) == null ? void 0 : _b.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
(_b = tracing) == null ? void 0 : _b.pop();
(_c = tracing) == null ? void 0 : _c.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
(_c = tracing) == null ? void 0 : _c.pop();
(_d = tracing) == null ? void 0 : _d.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
(_d = tracing) == null ? void 0 : _d.pop();
(_e = tracing) == null ? void 0 : _e.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
(_e = tracing) == null ? void 0 : _e.pop();
(_f = tracing) == null ? void 0 : _f.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
emitBuildInfo(bundleBuildInfo, buildInfoPath);
(_f = tracing) == null ? void 0 : _f.pop();
(_g = tracing) == null ? void 0 : _g.pop();
if (!emitSkipped && emittedFilesList) {
if (!emitOnly) {
if (jsFilePath) {
Expand Down Expand Up @@ -125047,7 +125050,12 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
getSourceFileFromReference: (file, ref) => program.getSourceFileFromReference(file, ref),
redirectTargetsMap,
getFileIncludeReasons: program.getFileIncludeReasons,
createHash: maybeBind(host, host.createHash)
createHash: maybeBind(host, host.createHash),
// @ts-expect-error fixed by uts
beforeEmitSourceFileOrBundle: (sourceFileOrBundle) => {
var _a2;
return (_a2 = program.beforeEmitSourceFileOrBundle) == null ? void 0 : _a2.call(program, sourceFileOrBundle);
}
};
}
function writeFile2(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
Expand Down
24 changes: 16 additions & 8 deletions packages/uni-uts-v1/lib/typescript/lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -113732,7 +113732,10 @@ ${lanes.join("\n")}
sourceMaps: sourceMapDataList
};
function emitSourceFileOrBundle({ jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath }, sourceFileOrBundle) {
var _a, _b, _c, _d, _e, _f;
var _a, _b, _c, _d, _e, _f, _g;
if ((_a = host.beforeEmitSourceFileOrBundle) == null ? void 0 : _a.call(host, sourceFileOrBundle)) {
return;
}
let buildInfoDirectory;
if (buildInfoPath && sourceFileOrBundle && isBundle(sourceFileOrBundle)) {
buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
Expand All @@ -113741,15 +113744,15 @@ ${lanes.join("\n")}
sourceFiles: sourceFileOrBundle.sourceFiles.map((file) => relativeToBuildInfo(getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())))
};
}
(_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
(_b = tracing) == null ? void 0 : _b.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
(_b = tracing) == null ? void 0 : _b.pop();
(_c = tracing) == null ? void 0 : _c.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
(_c = tracing) == null ? void 0 : _c.pop();
(_d = tracing) == null ? void 0 : _d.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
(_d = tracing) == null ? void 0 : _d.pop();
(_e = tracing) == null ? void 0 : _e.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
(_e = tracing) == null ? void 0 : _e.pop();
(_f = tracing) == null ? void 0 : _f.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
emitBuildInfo(bundleBuildInfo, buildInfoPath);
(_f = tracing) == null ? void 0 : _f.pop();
(_g = tracing) == null ? void 0 : _g.pop();
if (!emitSkipped && emittedFilesList) {
if (!emitOnly) {
if (jsFilePath) {
Expand Down Expand Up @@ -121074,7 +121077,12 @@ ${lanes.join("\n")}
getSourceFileFromReference: (file, ref) => program.getSourceFileFromReference(file, ref),
redirectTargetsMap,
getFileIncludeReasons: program.getFileIncludeReasons,
createHash: maybeBind(host, host.createHash)
createHash: maybeBind(host, host.createHash),
// @ts-expect-error fixed by uts
beforeEmitSourceFileOrBundle: (sourceFileOrBundle) => {
var _a2;
return (_a2 = program.beforeEmitSourceFileOrBundle) == null ? void 0 : _a2.call(program, sourceFileOrBundle);
}
};
}
function writeFile2(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
Expand Down
24 changes: 16 additions & 8 deletions packages/uni-uts-v1/lib/typescript/lib/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -113732,7 +113732,10 @@ ${lanes.join("\n")}
sourceMaps: sourceMapDataList
};
function emitSourceFileOrBundle({ jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath }, sourceFileOrBundle) {
var _a, _b, _c, _d, _e, _f;
var _a, _b, _c, _d, _e, _f, _g;
if ((_a = host.beforeEmitSourceFileOrBundle) == null ? void 0 : _a.call(host, sourceFileOrBundle)) {
return;
}
let buildInfoDirectory;
if (buildInfoPath && sourceFileOrBundle && isBundle(sourceFileOrBundle)) {
buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
Expand All @@ -113741,15 +113744,15 @@ ${lanes.join("\n")}
sourceFiles: sourceFileOrBundle.sourceFiles.map((file) => relativeToBuildInfo(getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())))
};
}
(_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
(_b = tracing) == null ? void 0 : _b.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
(_b = tracing) == null ? void 0 : _b.pop();
(_c = tracing) == null ? void 0 : _c.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
(_c = tracing) == null ? void 0 : _c.pop();
(_d = tracing) == null ? void 0 : _d.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
(_d = tracing) == null ? void 0 : _d.pop();
(_e = tracing) == null ? void 0 : _e.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
(_e = tracing) == null ? void 0 : _e.pop();
(_f = tracing) == null ? void 0 : _f.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
emitBuildInfo(bundleBuildInfo, buildInfoPath);
(_f = tracing) == null ? void 0 : _f.pop();
(_g = tracing) == null ? void 0 : _g.pop();
if (!emitSkipped && emittedFilesList) {
if (!emitOnly) {
if (jsFilePath) {
Expand Down Expand Up @@ -121074,7 +121077,12 @@ ${lanes.join("\n")}
getSourceFileFromReference: (file, ref) => program.getSourceFileFromReference(file, ref),
redirectTargetsMap,
getFileIncludeReasons: program.getFileIncludeReasons,
createHash: maybeBind(host, host.createHash)
createHash: maybeBind(host, host.createHash),
// @ts-expect-error fixed by uts
beforeEmitSourceFileOrBundle: (sourceFileOrBundle) => {
var _a2;
return (_a2 = program.beforeEmitSourceFileOrBundle) == null ? void 0 : _a2.call(program, sourceFileOrBundle);
}
};
}
function writeFile2(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
Expand Down
2 changes: 2 additions & 0 deletions packages/uni-uts-v1/src/tsc/kotlin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { isInHBuilderX, normalizePath } from '../../shared'
export interface UTS2KotlinOptions {
typescript?: typeof import('typescript')
inputDir: string
cacheDir: string
outputDir: string
tsconfig?: string
rootFiles?: string[]
Expand Down Expand Up @@ -85,6 +86,7 @@ export function runUTS2KotlinDev(options: UTS2KotlinOptions): {
return require('../../../lib/kotlin').runDev({
typescript,
inputDir: options.inputDir,
cacheDir: options.cacheDir,
tsconfig,
rootFiles,
compilerOptions: extend(tsconfigOverride.compilerOptions, {
Expand Down

0 comments on commit e9ded9d

Please sign in to comment.