提交 96614d35 编写于 作者: fxy060608's avatar fxy060608

wip(uts): automator

上级 2c9e11e5
export function initAutomator() {
console.log('initAutomator')
}
......@@ -156,11 +156,15 @@ function normalizeCode(code: string, isMain = false) {
if (!isMain) {
return code
}
const automatorCode = process.env.UNI_AUTOMATOR_WS_ENDPOINT
? 'initAutomator();'
: ''
return `
${code}
export function main(app: IApp) {
defineAppConfig();
definePageRoutes();
${automatorCode}
(createApp()['app'] as VueApp).mount(app);
}
`
......
......@@ -162,12 +162,12 @@ export async function transformVue(
templateCode = templateResult.code
}
// 生成 script 文件
const utsCode =
let utsCode =
genScript(descriptor, { filename: className }) +
'\n' +
genStyle(descriptor, { filename: fileName, className }) +
'\n' +
templateCode
'\n'
utsCode += templateCode
let jsCode = ''
const content = descriptor.script?.content
if (content) {
......
......@@ -28,6 +28,13 @@ exports.default = [
}
if (opts.filter(id)) {
const platform = process.env.UNI_PLATFORM;
if (platform === 'app' && process.env.UNI_APP_X === 'true') {
const automatorPath = (0, uni_cli_shared_1.normalizePath)((0, uni_cli_shared_1.resolveBuiltIn)(`@dcloudio/uni-app-uts/lib/automator/index.uts`));
return {
code: code + `;import { initAutomator } = '${automatorPath}';`,
map: null,
};
}
const automatorPath = (0, uni_cli_shared_1.normalizePath)((0, uni_cli_shared_1.resolveBuiltIn)(`@dcloudio/uni-${platform === 'app' ? 'app-plus' : platform}/lib/automator.js`));
return {
code: code + `;import '${automatorPath}';`,
......
......@@ -37,6 +37,15 @@ export default [
}
if (opts.filter(id)) {
const platform = process.env.UNI_PLATFORM
if (platform === 'app' && process.env.UNI_APP_X === 'true') {
const automatorPath = normalizePath(
resolveBuiltIn(`@dcloudio/uni-app-uts/lib/automator/index.uts`)
)
return {
code: code + `;import { initAutomator } = '${automatorPath}';`,
map: null,
}
}
const automatorPath = normalizePath(
resolveBuiltIn(
`@dcloudio/uni-${
......
......@@ -27,7 +27,7 @@ export async function runDev(options: CliOptions & ServerOptions) {
;(options as BuildOptions).minify = true
}
initEnv('dev', options)
if (process.env.UNI_APP_X === 'true') {
if (process.env.UNI_APP_X === 'true' && options.platform === 'app') {
return runUVueDev(options)
}
const createLogger = await import('vite').then(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册