unjs / mkdist

Lightweight file-to-file transpiler.
MIT License
367 stars 25 forks source link

fix(dts): compatible with vue-tsc 2.1.2 #240

Closed Teages closed 2 months ago

Teages commented 2 months ago

Resolves #239

add support for vue-tsc >= 2.1.2, and add a test to make sure it wouldn't break the builds with ~2.0.21

Additional

I notice that the test case of vue-tsc@^1 didn't do the right test so I also fix it in this pr.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 78.90%. Comparing base (9000888) to head (d2fc318). Report is 40 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #240 +/- ## ========================================== - Coverage 82.86% 78.90% -3.96% ========================================== Files 12 12 Lines 852 730 -122 Branches 133 150 +17 ========================================== - Hits 706 576 -130 - Misses 144 152 +8 Partials 2 2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Teages commented 2 months ago

I got the error after bumping mkdist alone, so I came back and rechecked again.

I try to log the test: console.log('createVueLanguagePlugin', vueLanguageCore.createVueLanguagePlugin, vueLanguageCore.createVueLanguagePlugin2)

# using 2.1.2, it remove the func, and createVueLanguagePlugin have been removed too
stdout | test/index.test.ts > mkdist > mkdist (emit types)
vue-tsc { run: [Function: run] }
createVueLanguagePlugin [Function: createVueLanguagePlugin] undefined

# using 2.0.29, but it select the wrong @vue/language-core version (createVueLanguagePlugin2 is missed)
stdout | test/index.test.ts > mkdist with vue-tsc ~v2.0.21 > mkdist (emit types)
vue-tsc {
  run: [Function: run],
  removeEmitGlobalTypes: [Function: removeEmitGlobalTypes]
}
createVueLanguagePlugin [Function: createVueLanguagePlugin] undefined

It seems createRequire didn't get the expected dependence and the ~v2.0.21 test case run with the wrong version of language/core. So it will break the build with vue-tsc@~v2.0.21 instead of keeping it compatible with 2.0.x as in description of the pr.

(Obviously, because they rearranged the order of function arguments. But I thought they might did something compatible and trusted the test result)

@danielroe I can make another pr to fix my mistake (by check is createVueLanguagePlugin2 still there), or we can just drop the vue-tsc@~v2.0.21 support and remove the misleading test cases