test.js 1.1 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1
const fs = require('fs')
fxy060608's avatar
fxy060608 已提交
2
const path = require('path')
fxy060608's avatar
fxy060608 已提交
3
const { parse, runBuild, bundle, UtsTarget } = require('../packages/uts/dist')
fxy060608's avatar
fxy060608 已提交
4
const projectDir = path.resolve(__dirname, '../packages/playground/uts')
fxy060608's avatar
fxy060608 已提交
5

fxy060608's avatar
fxy060608 已提交
6
let start = Date.now()
fxy060608's avatar
fxy060608 已提交
7 8
parse(
  fs.readFileSync(
fxy060608's avatar
fxy060608 已提交
9 10 11 12
    path.resolve(
      projectDir,
      'uni_modules/test-uniplugin/app-android/index.uts'
    ),
fxy060608's avatar
fxy060608 已提交
13 14 15 16 17 18
    'utf8'
  )
).then((res) => {
  console.log('parse: ' + (Date.now() - start) + 'ms')
  console.log(JSON.stringify(res))
})
fxy060608's avatar
fxy060608 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32
start = Date.now()
bundle({
  input: {
    root: path.resolve(projectDir, 'uni_modules/test-uniplugin'),
    filename: path.resolve(
      projectDir,
      'uni_modules/test-uniplugin/app-android/index.uts'
    ),
  },
  output: {
    outDir: path.resolve(
      projectDir,
      'unpackage/dist/app-plus/uni_modules/test-uniplugin/'
    ),
fxy060608's avatar
fxy060608 已提交
33 34
    package: 'uts.modules.testUniPlugin',
    imports: ['kotlinx.coroutines.*', 'io.dcloud.uts.runtime.*'],
fxy060608's avatar
fxy060608 已提交
35 36
    sourceMap: true,
    extname: 'kt',
fxy060608's avatar
fxy060608 已提交
37
    logFilename: true,
fxy060608's avatar
fxy060608 已提交
38 39 40 41 42
  },
}).then((res) => {
  console.log('bundle: ' + (Date.now() - start) + 'ms')
  console.log(JSON.stringify(res))
})