test.js 1.2 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, bundle } = 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
start = Date.now()
bundle({
  input: {
fxy060608's avatar
fxy060608 已提交
22
    root: projectDir,
fxy060608's avatar
fxy060608 已提交
23 24 25 26 27 28
    filename: path.resolve(
      projectDir,
      'uni_modules/test-uniplugin/app-android/index.uts'
    ),
  },
  output: {
fxy060608's avatar
fxy060608 已提交
29
    outDir: path.resolve(projectDir, 'unpackage/dist/app'),
fxy060608's avatar
fxy060608 已提交
30 31
    package: 'uts.modules.testUniPlugin',
    imports: ['kotlinx.coroutines.*', 'io.dcloud.uts.runtime.*'],
fxy060608's avatar
fxy060608 已提交
32 33
    sourceMap: true,
    extname: 'kt',
fxy060608's avatar
fxy060608 已提交
34
    logFilename: true,
fxy060608's avatar
fxy060608 已提交
35 36 37 38
  },
}).then((res) => {
  console.log('bundle: ' + (Date.now() - start) + 'ms')
  console.log(JSON.stringify(res))
fxy060608's avatar
fxy060608 已提交
39 40 41 42 43 44 45 46 47
  console.log(
    fs.readFileSync(
      path.resolve(
        projectDir,
        'unpackage/dist/app/uni_modules/test-uniplugin/app-android/index.kt'
      ),
      'utf8'
    )
  )
fxy060608's avatar
fxy060608 已提交
48
})