提交 7b180c3d 编写于 作者: fxy060608's avatar fxy060608

wip(uts): compiler

上级 3ba21c0d
......@@ -52,24 +52,30 @@ export function initModulePaths() {
}
}
function resolveEsbuildModule(name: string) {
try {
return path.dirname(
require.resolve(name + '/package.json', {
paths: [path.dirname(resolveBuiltIn('esbuild/package.json'))],
})
)
} catch (e) {}
return ''
}
export function fixBinaryPath() {
// cli 工程在 HBuilderX 中运行
if (!isInHBuilderX() && runByHBuilderX()) {
if (!isWindows) {
process.env.ESBUILD_BINARY_PATH = path.join(
resolveBuiltIn('esbuild/package.json'),
'../bin/esbuild'
)
}
try {
if (isWindows) {
process.env.UTS_BINARY_PATH = resolveBuiltIn(
'@dcloudio/uts-win32-x64-msvc'
)
} else {
// 强制使用 arm64 也不行,会报错:have 'arm64', need 'x86_64'
// process.env.UTS_BINARY_PATH = resolveBuiltIn('@dcloudio/uts-darwin-arm64')
if (isWindows) {
const win64 = resolveEsbuildModule('esbuild-windows-64')
if (win64) {
process.env.ESBUILD_BINARY_PATH = path.join(win64, 'esbuild.exe')
}
} else {
const arm64 = resolveEsbuildModule('esbuild-darwin-arm64')
if (arm64) {
process.env.ESBUILD_BINARY_PATH = path.join(arm64, 'bin/esbuild')
}
} catch (e) {}
}
}
}
......@@ -95,12 +95,12 @@ export function resolveUTSCompiler(): typeof UTSCompiler {
paths: [process.env.UNI_CLI_CONTEXT],
})
} catch (e) {
let version = require('@dcloudio/uni-cli-shared/package.json').version
if (version.startsWith('2.0.')) {
version = '^3.0.0-alpha-3060920221117001'
}
console.error(
installDepTips(
'devDependencies',
'@dcloudio/uni-uts-v1',
require('@dcloudio/uni-cli-shared/package.json').version
)
installDepTips('devDependencies', '@dcloudio/uni-uts-v1', version)
)
process.exit(0)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册